blob: c1bf0a11170d104ec7b9a6d90326110aff1e928e [file] [log] [blame]
Adrià Vilanova Martínez917797e2024-05-25 22:41:25 +02001import { ScriptPage } from '../../../common/architecture/scripts/Script';
2import StylesheetScript from '../../../common/architecture/scripts/stylesheet/StylesheetScript';
3
Adrià Vilanova Martínez6ecaa0d2024-10-26 17:04:32 +02004export default class CCDarkThemeInjectAutoDarkTheme extends StylesheetScript {
Adrià Vilanova Martínez917797e2024-05-25 22:41:25 +02005 stylesheet = 'ccDarkTheme.bundle.css';
6 attributes = { media: '(prefers-color-scheme: dark)' };
7 page = ScriptPage.CommunityConsole;
8
9 async shouldBeInjected(): Promise<boolean> {
10 const ccDarkThemeEnabled =
11 await this.optionsProvider.isEnabled('ccdarktheme');
12 const ccDarkThemeMode =
13 await this.optionsProvider.getOptionValue('ccdarktheme_mode');
14
15 return ccDarkThemeEnabled && ccDarkThemeMode === 'system';
16 }
17}