mirror of
https://github.com/CompassConnections/Compass.git
synced 2025-12-23 22:18:43 -05:00
10 lines
376 B
JavaScript
10 lines
376 B
JavaScript
// run this in <head> as blocking to prevent flash of unstyled content. See theme-provider.tsx
|
|
{
|
|
const localTheme = localStorage.getItem('theme')
|
|
const theme = localTheme ? JSON.parse(localTheme) : 'auto'
|
|
|
|
if (theme === 'dark' || (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
document.documentElement.classList.add('dark')
|
|
}
|
|
}
|