-
Notifications
You must be signed in to change notification settings - Fork 563
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
Make system setting the default theme preference #1581
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default (themeSetting, isElectron) => { | ||
if (themeSetting === 'system') { | ||
if (isElectron) { | ||
const { remote } = __non_webpack_require__('electron'); // eslint-disable-line no-undef | ||
return remote.systemPreferences.isDarkMode ? 'dark' : 'light'; | ||
} | ||
return window.matchMedia('(prefers-color-scheme: dark)').matches | ||
? 'dark' | ||
: 'light'; | ||
} | ||
return themeSetting; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
maybe it's easier to pass it in from it's probably also awkward to think about defining this function in okay so this is bad but here's an idea. it hooks into the point where we are supposedly initializing Electron specifics and replaces the class App extends Component {
initializeElectron = () => {
const { remote } = __non_webpack_require('electron');
// replace theme selection to get system setting
this.getTheme = () => {
const { settings: { theme } } = this.props;
return 'system' === theme
? ( remote.systemPreferences.isDarkMode ? 'dark' : 'light' )
: theme;
}
this.setState( … );
}
…
getTheme = () => {
const { settings: { theme } } = this.props;
return 'system' === theme
? ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches ? 'dark' : 'light' )
: theme;
}
…
} broken apart… getSystemColorMode = () => window.matchMedia('(prefers-color-scheme: dark)').match ? 'dark' : 'light';
getTheme = () => {
const { settings: { theme } } = this.props;
return 'system' === theme
? this.getSystemColorMode()
: theme;
}
initializeElectron = () => {
…
this.getSystemColorMode = () => remote.systemPreferences.isDarkMode ? 'dark' : 'light';
…
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the label we use on the other apps? Is
System
enough to explainSystem setting
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggled with what to call this option for the setting. Is it
Default
? Is itOS Setting
? System seemed to be the best answer.