Adrià Vilanova MartÃnez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 1 | import { ScriptPage } from '../../../common/architecture/scripts/Script'; |
| 2 | import StylesheetScript from '../../../common/architecture/scripts/stylesheet/StylesheetScript'; |
| 3 | |
| 4 | export 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 | } |