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

Check for dark theme preference #837

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
13 changes: 10 additions & 3 deletions app/scripts/HiGlassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,17 +671,24 @@ class HiGlassComponent extends React.Component {
);
this.theme = isDarkTheme ? 'dark' : 'light';
} else {
const prefersDark =
window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches;
switch (newTheme) {
case 'dark':
this.theme = THEME_DARK;
break;
case 'light':
case undefined:
this.theme = THEME_LIGHT;
break;
case undefined:
this.theme = prefersDark ? THEME_DARK : THEME_LIGHT;
break;
default:
console.warn(`Unknown theme "${newTheme}". Using light theme.`);
this.theme = THEME_LIGHT;
this.theme = prefersDark ? THEME_DARK : THEME_LIGHT;
console.warn(
`Unknown theme "${newTheme}". Using ${this.theme.toString()} theme.`
);
break;
}
}
Expand Down