cleanup
This commit is contained in:
@@ -377,7 +377,7 @@ const Sidebar = ({
|
||||
}, [cycleThemeMode]);
|
||||
|
||||
const themeMenuSection =
|
||||
typeof neutralHue === 'number' || typeof neutralHue === 'string'
|
||||
neutralHue != null
|
||||
? (
|
||||
<div className="menu__section">
|
||||
<div className="menu__heading menu__heading--with-actions">
|
||||
@@ -604,9 +604,7 @@ const Sidebar = ({
|
||||
size={16}
|
||||
/>
|
||||
</button>
|
||||
{tenantMenuOpen
|
||||
&& tenantMenuStyle
|
||||
&& typeof document !== 'undefined'
|
||||
{tenantMenuOpen && tenantMenuStyle
|
||||
? createPortal(
|
||||
<div
|
||||
className={menuClassName}
|
||||
|
||||
@@ -26,21 +26,6 @@ const loadInitialThemeSettings = () => {
|
||||
mode: DEFAULT_THEME_MODE,
|
||||
};
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
if (typeof document !== 'undefined') {
|
||||
const root = document.documentElement;
|
||||
const current = root.style.getPropertyValue('--neutral-hue');
|
||||
const parsed = Number.parseInt(current, 10);
|
||||
return {
|
||||
neutralHue: Number.isNaN(parsed) ? defaults.neutralHue : parsed,
|
||||
neutralChroma: defaults.neutralChroma,
|
||||
neutralContrast: defaults.neutralContrast,
|
||||
mode: defaults.mode,
|
||||
};
|
||||
}
|
||||
return defaults;
|
||||
}
|
||||
|
||||
const root = document.documentElement;
|
||||
const readNumberVar = (name, fallback) => {
|
||||
const inlineValue = root.style.getPropertyValue(name);
|
||||
@@ -48,12 +33,10 @@ const loadInitialThemeSettings = () => {
|
||||
if (!Number.isNaN(inlineParsed)) {
|
||||
return inlineParsed;
|
||||
}
|
||||
if (typeof window !== 'undefined' && window.getComputedStyle) {
|
||||
const computedValue = window.getComputedStyle(root).getPropertyValue(name);
|
||||
const computedParsed = Number.parseFloat(computedValue);
|
||||
if (!Number.isNaN(computedParsed)) {
|
||||
return computedParsed;
|
||||
}
|
||||
const computedValue = window.getComputedStyle(root).getPropertyValue(name);
|
||||
const computedParsed = Number.parseFloat(computedValue);
|
||||
if (!Number.isNaN(computedParsed)) {
|
||||
return computedParsed;
|
||||
}
|
||||
return fallback;
|
||||
};
|
||||
@@ -120,9 +103,6 @@ const loadInitialThemeSettings = () => {
|
||||
};
|
||||
|
||||
const loadInitialCollapsedState = (defaultValue) => {
|
||||
if (typeof window === 'undefined') {
|
||||
return Boolean(defaultValue);
|
||||
}
|
||||
try {
|
||||
const stored = window.sessionStorage.getItem(SIDEBAR_COLLAPSE_STORAGE_KEY);
|
||||
if (stored === '1' || stored === 'true') {
|
||||
@@ -146,30 +126,18 @@ export const SidebarProvider = ({ initialCollapsed = false, children }) => {
|
||||
const [themeMode, setThemeModeState] = useState(initialTheme.mode);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
document.documentElement.style.setProperty('--neutral-hue', `${neutralHue}deg`);
|
||||
}, [neutralHue]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
document.documentElement.style.setProperty('--neutral-chroma', String(neutralChroma));
|
||||
}, [neutralChroma]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
document.documentElement.style.setProperty('--neutral-contrast', String(neutralContrast));
|
||||
}, [neutralContrast]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const root = document.documentElement;
|
||||
if (themeMode === 'system') {
|
||||
root.removeAttribute('data-theme');
|
||||
@@ -179,9 +147,6 @@ export const SidebarProvider = ({ initialCollapsed = false, children }) => {
|
||||
}, [themeMode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const payload = JSON.stringify({
|
||||
neutralHue,
|
||||
@@ -199,7 +164,7 @@ export const SidebarProvider = ({ initialCollapsed = false, children }) => {
|
||||
|
||||
const setNeutralHue = useCallback((value) => {
|
||||
setNeutralHueState((prev) => {
|
||||
if (value === '' || value === null || typeof value === 'undefined') {
|
||||
if (value === '' || value === null || value === undefined) {
|
||||
return DEFAULT_NEUTRAL_HUE;
|
||||
}
|
||||
const parsed = Number(value);
|
||||
@@ -213,7 +178,7 @@ export const SidebarProvider = ({ initialCollapsed = false, children }) => {
|
||||
|
||||
const setNeutralChroma = useCallback((value) => {
|
||||
setNeutralChromaState((prev) => {
|
||||
if (value === '' || value === null || typeof value === 'undefined') {
|
||||
if (value === '' || value === null || value === undefined) {
|
||||
return DEFAULT_NEUTRAL_CHROMA;
|
||||
}
|
||||
const parsed = Number(value);
|
||||
@@ -231,7 +196,7 @@ export const SidebarProvider = ({ initialCollapsed = false, children }) => {
|
||||
|
||||
const setNeutralContrast = useCallback((value) => {
|
||||
setNeutralContrastState((prev) => {
|
||||
if (value === '' || value === null || typeof value === 'undefined') {
|
||||
if (value === '' || value === null || value === undefined) {
|
||||
return DEFAULT_NEUTRAL_CONTRAST;
|
||||
}
|
||||
const parsed = Number(value);
|
||||
@@ -265,9 +230,6 @@ export const SidebarProvider = ({ initialCollapsed = false, children }) => {
|
||||
}, [themeMode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
window.sessionStorage.setItem(SIDEBAR_COLLAPSE_STORAGE_KEY, collapsed ? '1' : '0');
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user