blob: afbe161844fe02d7857b5532e2ed0d0f392373af [file] [log] [blame]
Adrià Vilanova Martínezfe694782024-11-09 20:40:43 +01001import { ScriptPage } from '../../../../common/architecture/scripts/Script';
2import StylesheetScript from '../../../../common/architecture/scripts/stylesheet/StylesheetScript';
Adrià Vilanova Martínez917797e2024-05-25 22:41:25 +02003
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}