mirror of
https://github.com/unraid/api.git
synced 2026-01-02 14:40:01 -06:00
refactor: enhance CSS reset and improve Vue app mounting logic
- Updated the `.unraid-reset` class in `main.css` to include additional properties for better styling consistency across Unraid components. - Refined the `autoMountComponent` function in `vue-mount-app.ts` to check for element existence before mounting, improving robustness and preventing errors during the mounting process.
This commit is contained in:
@@ -8,20 +8,31 @@
|
||||
@source "../../unraid-ui/src/**/*.{vue,ts}";
|
||||
@source "../**/*.{vue,ts,js}";
|
||||
|
||||
/* Reset all inherited styles from webgui for Unraid components */
|
||||
.unraid-reset,
|
||||
.unraid-reset * {
|
||||
/* Reset all inherited properties to initial values */
|
||||
all: unset;
|
||||
/* Reset inherited styles from webgui for Unraid components */
|
||||
.unraid-reset {
|
||||
/* Create a new stacking context */
|
||||
isolation: isolate;
|
||||
|
||||
/* Restore essential display properties */
|
||||
display: revert;
|
||||
/* Reset text and spacing properties that commonly leak from webgui */
|
||||
font-size: 1rem;
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
word-spacing: normal;
|
||||
|
||||
/* Reset box model */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
|
||||
/* Ensure proper box sizing */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.unraid-reset * {
|
||||
/* Ensure all children use border-box */
|
||||
box-sizing: border-box;
|
||||
|
||||
/* Ensure text is visible */
|
||||
color: inherit;
|
||||
font-family: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
/* Specific resets for interactive elements to restore functionality */
|
||||
|
||||
@@ -256,13 +256,19 @@ export function getMountedApp(appId: string): VueApp | undefined {
|
||||
|
||||
// Auto-mount function for script tags
|
||||
export function autoMountComponent(component: Component, selector: string, options?: Partial<MountOptions>) {
|
||||
const tryMount = () => {
|
||||
// Check if elements exist before attempting to mount
|
||||
if (document.querySelector(selector)) {
|
||||
mountVueApp({ component, selector, ...options });
|
||||
}
|
||||
// Silently skip if no elements found - this is expected for most components
|
||||
};
|
||||
|
||||
// Wait for DOM to be ready
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
mountVueApp({ component, selector, ...options });
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', tryMount);
|
||||
} else {
|
||||
// DOM is already ready
|
||||
mountVueApp({ component, selector, ...options });
|
||||
tryMount();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user