modo-claro
modified: src/hooks/useAgenda.js modified: src/index.css modified: src/main.jsx modified: src/mappers/reportMapper.js modified: src/pages/AgendaPage.jsx modified: src/pages/AuthPages.jsx modified: src/pages/MedicalRecordsPage.jsx modified: src/pages/PatientsPage.jsx modified: src/pages/ReportsPage.jsx modified: src/pages/SettingsPage.jsx modified: src/repositories/analyticsRepository.js modified: src/repositories/authRepository.js modified: src/repositories/patientRepository.js modified: src/repositories/reportRepository.js modified: src/repositories/repositoryUtils.js new file: src/utils/theme.js new file: vercel.json
This commit is contained in:
27
src/utils/theme.js
Normal file
27
src/utils/theme.js
Normal file
@@ -0,0 +1,27 @@
|
||||
export const THEME_STORAGE_KEY = 'mediconnect.theme'
|
||||
|
||||
export function getStoredTheme() {
|
||||
if (typeof window === 'undefined') return 'dark'
|
||||
|
||||
const storedTheme = window.localStorage.getItem(THEME_STORAGE_KEY)
|
||||
return storedTheme === 'light' ? 'light' : 'dark'
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user