Bluesky app fork with some witchin' additions 馃挮
at main 670 B view raw
1export type ColorModeValues = 'system' | 'light' | 'dark' 2 3export function assertColorModeValues(value: string): value is ColorModeValues { 4 return ['system', 'light', 'dark'].includes(value) 5} 6 7export function applyTheme(theme: 'light' | 'dark') { 8 document.documentElement.classList.remove('light', 'dark') 9 document.documentElement.classList.add(theme) 10} 11 12export function initSystemColorMode() { 13 applyTheme( 14 window.matchMedia('(prefers-color-scheme: dark)').matches 15 ? 'dark' 16 : 'light', 17 ) 18 window 19 .matchMedia('(prefers-color-scheme: dark)') 20 .addEventListener('change', mql => { 21 applyTheme(mql.matches ? 'dark' : 'light') 22 }) 23}