From ab1a08681dcd0ebb6d915f3e6a818926a81d2d23 Mon Sep 17 00:00:00 2001 From: Milan Klanjsek Date: Mon, 26 Oct 2020 12:33:15 -0600 Subject: [PATCH] Use system theme by default Signed-off-by: Milan Klanjsek --- web/src/app/modules/shared/services/theme/theme.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/src/app/modules/shared/services/theme/theme.service.ts b/web/src/app/modules/shared/services/theme/theme.service.ts index e6fea94497..1509aa2961 100644 --- a/web/src/app/modules/shared/services/theme/theme.service.ts +++ b/web/src/app/modules/shared/services/theme/theme.service.ts @@ -34,7 +34,10 @@ export const lightTheme: Theme = { assetPath: 'assets/css/clr-ui.min.css', }; -export const defaultTheme = lightTheme; +export const defaultTheme = window.matchMedia('(prefers-color-scheme:dark)') + .matches + ? darkTheme + : lightTheme; @Injectable({ providedIn: 'root', @@ -53,6 +56,7 @@ export class ThemeService implements OnDestroy { const themeType = localStorage.getItem('theme') as ThemeType; this.themeType = themeType || defaultTheme.type; + this.renderer = rendererFactory.createRenderer(null, null); this.storageEventHandler = (e: StorageEvent): void => {