Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set prefers-color-scheme (#93) #94

Merged
merged 4 commits into from
Aug 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/background/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default class Extension {
const template = this.state.getTemplate();
const colorscheme = Generators.colorscheme(mode, pywalColors, customColors, template);

this.setBrowserTheme(colorscheme.browser);
this.setBrowserTheme(colorscheme.browser, mode);
this.updateExtensionPagesTheme(colorscheme.extension);

if (this.state.getDDGThemeEnabled()) {
Expand Down Expand Up @@ -300,8 +300,18 @@ export default class Extension {
}
}

private setBrowserTheme(browserTheme: IBrowserTheme) {
browser.theme.update({ colors: browserTheme });
private setBrowserTheme(browserTheme: IBrowserTheme, mode?: ThemeModes.Dark | ThemeModes.Light) {
const modeString = (mode === ThemeModes.Dark) ? 'dark' : 'light';

browser.theme.update({
colors: browserTheme,
properties: {
// @ts-ignore
color_scheme: modeString,
// @ts-ignore
content_color_scheme: modeString,
},
});
}

private setDDGEnabled({ option, enabled }: IOptionSetData) {
Expand Down