diff --git a/app/soapbox/features/preferences/index.js b/app/soapbox/features/preferences/index.js index 148a70c57..80a49a7b7 100644 --- a/app/soapbox/features/preferences/index.js +++ b/app/soapbox/features/preferences/index.js @@ -79,8 +79,6 @@ const languages = { const messages = defineMessages({ heading: { id: 'column.preferences', defaultMessage: 'Preferences' }, - themeLight: { id: 'preferences.options.theme_light', defaultMessage: 'Light' }, - themeDark: { id: 'preferences.options.theme_dark', defaultMessage: 'Dark' }, }); const mapStateToProps = state => ({ @@ -114,15 +112,6 @@ class Preferences extends ImmutablePureComponent { return ( - - } - items={{ light: intl.formatMessage(messages.themeLight), dark: intl.formatMessage(messages.themeDark) }} - defaultValue={settings.get('themeMode')} - onChange={this.onSelectChange(['themeMode'])} - /> - - } diff --git a/app/soapbox/features/ui/components/tabs_bar.js b/app/soapbox/features/ui/components/tabs_bar.js index 391ca3a2b..ce10d5c7d 100644 --- a/app/soapbox/features/ui/components/tabs_bar.js +++ b/app/soapbox/features/ui/components/tabs_bar.js @@ -13,9 +13,12 @@ import ActionBar from 'soapbox/features/compose/components/action_bar'; import { openModal } from '../../../actions/modal'; import { openSidebar } from '../../../actions/sidebar'; import Icon from '../../../components/icon'; +import { changeSetting } from 'soapbox/actions/settings'; const messages = defineMessages({ post: { id: 'tabs_bar.post', defaultMessage: 'Post' }, + switchToLight: { id: 'tabs_bar.theme_toggle_light', defaultMessage: 'Switch to light theme' }, + switchToDark: { id: 'tabs_bar.theme_toggle_dark', defaultMessage: 'Switch to dark theme' }, }); @withRouter @@ -26,8 +29,10 @@ class TabsBar extends React.PureComponent { history: PropTypes.object.isRequired, onOpenCompose: PropTypes.func, onOpenSidebar: PropTypes.func.isRequired, + toggleTheme: PropTypes.func, logo: PropTypes.string, account: ImmutablePropTypes.map, + settings: ImmutablePropTypes.map, } state = { @@ -102,6 +107,16 @@ class TabsBar extends React.PureComponent { })); } + getNewThemeValue() { + if (this.props.settings.get('themeMode') === 'light') return 'dark'; + + return 'light'; + } + + handleToggleTheme = () => { + this.props.toggleTheme(this.getNewThemeValue()); + } + handleScroll = throttle(() => { if (this.window) { const { pageYOffset, innerWidth } = this.window; @@ -124,7 +139,7 @@ class TabsBar extends React.PureComponent { }); render() { - const { account, onOpenCompose, onOpenSidebar, intl } = this.props; + const { account, onOpenCompose, onOpenSidebar, intl, settings } = this.props; const { collapsed } = this.state; const classes = classNames('tabs-bar', { @@ -143,6 +158,9 @@ class TabsBar extends React.PureComponent { { account &&
+