blob: c462a03320320a50ad4c374afa9f7a99396e4a05 [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
4export default class InjectAutoDarkTheme extends StylesheetScript {
5 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}