Files
riseup_squad_03/src/utils/theme.js
Squad03_Leticia_Lacerda 8f0e616d2b modified: src/App.jsx
modified:   src/components/AppShell.jsx
modified:   src/components/Brand.jsx
modified:   src/index.css
modified:   src/pages/MedicalRecordsPage.jsx
modified:   src/pages/PatientsPage.jsx
modified:   src/pages/ReportsPage.jsx
modified:   src/pages/SettingsPage.jsx
modified:   src/repositories/authRepository.js
modified:   src/repositories/professionalRepository.js
modified:   src/repositories/repositoryUtils.js
modified:   src/repositories/settingsRepository.js
modified:   src/utils/theme.js
2026-05-11 15:26:55 -03:00

28 lines
809 B
JavaScript

export const THEME_STORAGE_KEY = 'mediconnect.theme'
export function getStoredTheme() {
if (typeof window === 'undefined') return 'light'
const storedTheme = window.localStorage.getItem(THEME_STORAGE_KEY)
return storedTheme === 'dark' ? 'dark' : 'light'
}
export function applyTheme(theme) {
if (typeof document === 'undefined') return
const normalizedTheme = theme === 'light' ? 'light' : 'dark'
document.documentElement.dataset.theme = normalizedTheme
document.documentElement.style.colorScheme = normalizedTheme
}
export function setStoredTheme(theme) {
const normalizedTheme = theme === 'light' ? 'light' : 'dark'
if (typeof window !== 'undefined') {
window.localStorage.setItem(THEME_STORAGE_KEY, normalizedTheme)
}
applyTheme(normalizedTheme)
return normalizedTheme
}