uber-642: use system theme as the default value for application theme (#3534)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2023-07-29 13:20:40 +04:00 committed by GitHub
parent 98055e4dc4
commit f7d68ee7da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,10 +27,18 @@ export const setDefaultLanguage = (language: string): void => {
}
}
function isSystemThemeDark (): boolean {
return window.matchMedia('(prefers-color-scheme: dark)').matches
}
function getDefaultTheme (): string {
return isSystemThemeDark() ? 'theme-dark' : 'theme-light'
}
/**
* @public
*/
export const getCurrentTheme = (): string => localStorage.getItem('theme') ?? 'theme-dark'
export const getCurrentTheme = (): string => localStorage.getItem('theme') ?? getDefaultTheme()
/**
* @public
*/