Adrià Vilanova Martínez | fe69478 | 2024-11-09 20:40:43 +0100 | [diff] [blame] | 1 | import { ScriptPage } from '../../../../common/architecture/scripts/Script'; |
| 2 | import StylesheetScript from '../../../../common/architecture/scripts/stylesheet/StylesheetScript'; |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 3 | |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 4 | export default class CCDarkThemeInjectAutoDarkTheme extends StylesheetScript { |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 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 | } |