diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 9b0eebbe8..bf9d837b0 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -2,6 +2,10 @@ ## Future release +### Enhancements + + - Add ability to select system as a theme option and make it the default + ### Fixes - Rework WordPress.com signin to prevent infinite looping and login failures [#1627](https://github.com/Automattic/simplenote-electron/pull/1627) diff --git a/lib/app.jsx b/lib/app.jsx index b9e8dfbd7..b51f04b54 100644 --- a/lib/app.jsx +++ b/lib/app.jsx @@ -309,8 +309,20 @@ export const App = connect( preferencesBucket: this.props.preferencesBucket, }); + getSystemColorMode = () => + window.matchMedia('(prefers-color-scheme: dark)').matches + ? 'dark' + : 'light'; + + getTheme = () => { + const { + settings: { theme }, + } = this.props; + return 'system' === theme ? this.getSystemColorMode() : theme; + }; + initializeElectron = () => { - const remote = __non_webpack_require__('electron').remote; // eslint-disable-line no-undef + const { remote } = __non_webpack_require__('electron'); // eslint-disable-line no-undef this.setState({ electron: { @@ -404,7 +416,7 @@ export const App = connect( } = this.props; const isMacApp = isElectronMac(); - const themeClass = `theme-${settings.theme}`; + const themeClass = `theme-${this.getTheme()}`; const appClasses = classNames('app', themeClass, { 'is-line-length-full': settings.lineLength === 'full', diff --git a/lib/dialogs/settings-group.jsx b/lib/dialogs/settings-group.jsx index 5aa2dc776..0749c0a1c 100644 --- a/lib/dialogs/settings-group.jsx +++ b/lib/dialogs/settings-group.jsx @@ -27,11 +27,13 @@ export const SettingsGroup = ({ ); + const childElements = React.Children.toArray(children).filter(o => o); + return (
{groupTitle}
- {React.Children.map(children, ({ props: { slug, title } }) => ( + {childElements.map(({ props: { slug, title } }) => (