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..04dd8def9 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,12 +29,15 @@ 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 = { collapsed: false, + isLight: this.props.settings.get('themeMode') === 'light' ? true : false, } static contextTypes = { @@ -102,6 +108,18 @@ class TabsBar extends React.PureComponent { })); } + getNewThemeValue() { + if (this.props.settings.get('themeMode') === 'light') return 'dark'; + + return 'light'; + } + + handleToggleTheme = () => { + this.props.toggleTheme(this.getNewThemeValue()); + + this.setState({ isLight: !this.state.isLight }); + } + handleScroll = throttle(() => { if (this.window) { const { pageYOffset, innerWidth } = this.window; @@ -125,7 +143,7 @@ class TabsBar extends React.PureComponent { render() { const { account, onOpenCompose, onOpenSidebar, intl } = this.props; - const { collapsed } = this.state; + const { collapsed, isLight } = this.state; const classes = classNames('tabs-bar', { 'tabs-bar--collapsed': collapsed, @@ -143,6 +161,9 @@ class TabsBar extends React.PureComponent { { account &&
+