Move ThemeToggle to separate class, style it, and fix it on mobile
This commit is contained in:
parent
796bf9c844
commit
277f4b5f22
|
@ -15,6 +15,7 @@ import { shortNumberFormat } from '../utils/numbers';
|
||||||
import { isStaff } from '../utils/accounts';
|
import { isStaff } from '../utils/accounts';
|
||||||
import { makeGetAccount } from '../selectors';
|
import { makeGetAccount } from '../selectors';
|
||||||
import { logOut } from 'soapbox/actions/auth';
|
import { logOut } from 'soapbox/actions/auth';
|
||||||
|
import ThemeToggle from '../features/ui/components/theme_toggle';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
followers: { id: 'account.followers', defaultMessage: 'Followers' },
|
followers: { id: 'account.followers', defaultMessage: 'Followers' },
|
||||||
|
@ -119,6 +120,12 @@ class SidebarMenu extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='sidebar-menu__section sidebar-menu__section--borderless'>
|
<div className='sidebar-menu__section sidebar-menu__section--borderless'>
|
||||||
|
<div className='sidebar-menu-item theme-toggle'>
|
||||||
|
<ThemeToggle showLabel />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='sidebar-menu__section sidebar-menu__section'>
|
||||||
<NavLink className='sidebar-menu-item' to={`/@${acct}`} onClick={onClose}>
|
<NavLink className='sidebar-menu-item' to={`/@${acct}`} onClick={onClose}>
|
||||||
<Icon id='user' />
|
<Icon id='user' />
|
||||||
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.profile)}</span>
|
<span className='sidebar-menu-item__title'>{intl.formatMessage(messages.profile)}</span>
|
||||||
|
|
|
@ -12,13 +12,10 @@ import ActionBar from 'soapbox/features/compose/components/action_bar';
|
||||||
import { openModal } from '../../../actions/modal';
|
import { openModal } from '../../../actions/modal';
|
||||||
import { openSidebar } from '../../../actions/sidebar';
|
import { openSidebar } from '../../../actions/sidebar';
|
||||||
import Icon from '../../../components/icon';
|
import Icon from '../../../components/icon';
|
||||||
import { changeSetting, getSettings } from 'soapbox/actions/settings';
|
import ThemeToggle from '../../ui/components/theme_toggle';
|
||||||
import SettingToggle from '../../notifications/components/setting_toggle';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
post: { id: 'tabs_bar.post', defaultMessage: 'Post' },
|
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
|
@withRouter
|
||||||
|
@ -29,10 +26,8 @@ class TabsBar extends React.PureComponent {
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired,
|
||||||
onOpenCompose: PropTypes.func,
|
onOpenCompose: PropTypes.func,
|
||||||
onOpenSidebar: PropTypes.func.isRequired,
|
onOpenSidebar: PropTypes.func.isRequired,
|
||||||
toggleTheme: PropTypes.func,
|
|
||||||
logo: PropTypes.string,
|
logo: PropTypes.string,
|
||||||
account: ImmutablePropTypes.map,
|
account: ImmutablePropTypes.map,
|
||||||
settings: ImmutablePropTypes.map.isRequired,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -84,12 +79,8 @@ class TabsBar extends React.PureComponent {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleToggleTheme = () => {
|
|
||||||
this.props.toggleTheme(this.props.settings.get('themeMode') === 'light' ? 'dark' : 'light');
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, onOpenCompose, onOpenSidebar, intl, settings } = this.props;
|
const { account, onOpenCompose, onOpenSidebar, intl } = this.props;
|
||||||
const { collapsed } = this.state;
|
const { collapsed } = this.state;
|
||||||
|
|
||||||
const classes = classNames('tabs-bar', {
|
const classes = classNames('tabs-bar', {
|
||||||
|
@ -108,7 +99,7 @@ class TabsBar extends React.PureComponent {
|
||||||
</div>
|
</div>
|
||||||
{ account &&
|
{ account &&
|
||||||
<div className='flex'>
|
<div className='flex'>
|
||||||
<SettingToggle settings={settings} settingPath={['themeMode']} condition={'light'} onChange={this.handleToggleTheme} icons={{ checked: <Icon id='sun' />, unchecked: <Icon id='moon' /> }} ariaLabel={settings.get('themeMode') === 'light' ? intl.formatMessage(messages.switchToDark) : intl.formatMessage(messages.switchToLight)} />
|
<ThemeToggle />
|
||||||
<div className='tabs-bar__profile'>
|
<div className='tabs-bar__profile'>
|
||||||
<Avatar account={account} />
|
<Avatar account={account} />
|
||||||
<button className='tabs-bar__sidebar-btn' onClick={onOpenSidebar} />
|
<button className='tabs-bar__sidebar-btn' onClick={onOpenSidebar} />
|
||||||
|
@ -140,11 +131,9 @@ class TabsBar extends React.PureComponent {
|
||||||
|
|
||||||
const mapStateToProps = state => {
|
const mapStateToProps = state => {
|
||||||
const me = state.get('me');
|
const me = state.get('me');
|
||||||
const settings = getSettings(state);
|
|
||||||
return {
|
return {
|
||||||
account: state.getIn(['accounts', me]),
|
account: state.getIn(['accounts', me]),
|
||||||
logo: state.getIn(['soapbox', 'logo']),
|
logo: state.getIn(['soapbox', 'logo']),
|
||||||
settings: settings,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -155,9 +144,6 @@ const mapDispatchToProps = (dispatch) => ({
|
||||||
onOpenSidebar() {
|
onOpenSidebar() {
|
||||||
dispatch(openSidebar());
|
dispatch(openSidebar());
|
||||||
},
|
},
|
||||||
toggleTheme(setting) {
|
|
||||||
dispatch(changeSetting(['themeMode'], setting));
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default injectIntl(
|
export default injectIntl(
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
@import 'components/still-image';
|
@import 'components/still-image';
|
||||||
@import 'components/timeline-queue-header';
|
@import 'components/timeline-queue-header';
|
||||||
@import 'components/badge';
|
@import 'components/badge';
|
||||||
|
@import 'components/theme-toggle';
|
||||||
@import 'components/trends';
|
@import 'components/trends';
|
||||||
@import 'components/wtf-panel';
|
@import 'components/wtf-panel';
|
||||||
@import 'components/profile-info-panel';
|
@import 'components/profile-info-panel';
|
||||||
|
|
|
@ -161,6 +161,10 @@
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.theme-toggle {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
&__title {
|
&__title {
|
||||||
color: var(--primary-text-color);
|
color: var(--primary-text-color);
|
||||||
|
|
|
@ -111,14 +111,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__button-theme-toggle {
|
|
||||||
margin-left: 10px;
|
|
||||||
padding: 0 10px;
|
|
||||||
font-size: 20px;
|
|
||||||
|
|
||||||
.fa { margin-right: 0; }
|
|
||||||
}
|
|
||||||
|
|
||||||
&__button-compose {
|
&__button-compose {
|
||||||
display: block;
|
display: block;
|
||||||
@media screen and (max-width: $nav-breakpoint-3) {display: none;}
|
@media screen and (max-width: $nav-breakpoint-3) {display: none;}
|
||||||
|
@ -149,15 +141,12 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.setting-toggle {
|
.theme-toggle {
|
||||||
margin-top: 5px;
|
@media screen and (max-width: $nav-breakpoint-3) {display: none;}
|
||||||
margin-left: 10px;
|
|
||||||
|
|
||||||
.react-toggle-track-check,
|
.setting-toggle {
|
||||||
.react-toggle-track-x {
|
margin-top: 3px;
|
||||||
height: 15px;
|
margin-left: 10px;
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.react-toggle--checked {
|
.react-toggle--checked {
|
||||||
.react-toggle-track {
|
.react-toggle-track {
|
||||||
|
@ -168,6 +157,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs-bar__link {
|
.tabs-bar__link {
|
||||||
|
|
Loading…
Reference in New Issue