fix: OS Detection of theme removed.
All checks were successful
Deploy to Staging / Build Images (push) Successful in 4m34s
Deploy to Staging / Deploy to Staging (push) Successful in 37s
Deploy to Staging / Verify Staging (push) Successful in 6s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped

This commit is contained in:
Eric Gullickson
2026-01-01 10:30:08 -06:00
parent f79fda79b9
commit ffd8ecd1d0
5 changed files with 10 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
/**
* @ai-summary Theme context for managing light/dark mode across the app
* Supports: system preference detection, localStorage persistence, backend sync
* Supports: localStorage persistence, backend sync, defaults to light theme
* Applies Tailwind dark class to document root
*/
@@ -27,28 +27,6 @@ interface ThemeProviderProps {
children: ReactNode;
}
// Detect system dark mode preference
const getSystemPreference = (): boolean => {
if (typeof window !== 'undefined' && window.matchMedia) {
return window.matchMedia('(prefers-color-scheme: dark)').matches;
}
return false;
};
// Check if user has explicitly set a preference in localStorage
const hasStoredPreference = (): boolean => {
try {
const stored = localStorage.getItem(SETTINGS_STORAGE_KEY);
if (stored) {
const settings = JSON.parse(stored);
return settings.darkMode !== undefined && settings.darkMode !== null;
}
} catch {
// Ignore parse errors
}
return false;
};
// Read dark mode preference from localStorage
const getStoredDarkMode = (): boolean | undefined => {
try {
@@ -65,13 +43,13 @@ const getStoredDarkMode = (): boolean | undefined => {
return undefined;
};
// Get initial dark mode: localStorage > system preference
// Get initial dark mode: localStorage > default to light
const getInitialDarkMode = (): boolean => {
const stored = getStoredDarkMode();
if (stored !== undefined) {
return stored;
}
return getSystemPreference();
return false; // Default to light theme
};
// Update dark mode in localStorage while preserving other settings
@@ -97,23 +75,6 @@ export const ThemeProvider = ({ children }: ThemeProviderProps) => {
setIsInitialized(true);
}, []);
// Listen for system preference changes (only when no explicit preference set)
useEffect(() => {
if (typeof window === 'undefined' || !window.matchMedia) return;
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
const handleChange = (e: MediaQueryListEvent) => {
// Only react to system changes if user hasn't set explicit preference
if (!hasStoredPreference()) {
setIsDarkMode(e.matches);
}
};
mediaQuery.addEventListener('change', handleChange);
return () => mediaQuery.removeEventListener('change', handleChange);
}, []);
// Apply dark class to document root for Tailwind
useEffect(() => {
const root = document.documentElement;