1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-08 15:06:08 +02:00

System theme support on Safari

This commit is contained in:
Chen-I Lim 2021-03-31 22:03:16 -07:00
parent 41ccd7651c
commit 3b7f5d9b51

View File

@ -142,11 +142,17 @@ export function loadTheme(): Theme {
export function initThemes(): void {
const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)')
darkThemeMq.addEventListener('change', () => {
const changeHandler = () => {
const themeStr = localStorage.getItem('theme')
if (!themeStr) {
setTheme(null)
}
})
}
if (darkThemeMq.addEventListener) {
darkThemeMq.addEventListener('change', changeHandler)
} else if (darkThemeMq.addListener) {
// Safari and Mac app support
darkThemeMq.addListener(changeHandler)
}
loadTheme()
}