move docs toggle to settings

This commit is contained in:
David Lechner
2021-01-14 10:55:00 -06:00
parent b6bda26484
commit b15b2e1dea
16 changed files with 93 additions and 257 deletions
+23 -2
View File
@@ -7,7 +7,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { Action, Dispatch } from '../actions';
import { closeSettings } from '../actions/app';
import { toggleDarkMode } from '../actions/settings';
import { toggleDarkMode, toggleDocs } from '../actions/settings';
import { RootState } from '../reducers';
import { SettingsStringId } from './settings-i18n';
import en from './settings-i18n.en.json';
@@ -16,11 +16,13 @@ import './settings.scss';
type StateProps = {
open: boolean;
showDocs: boolean;
darkMode: boolean;
};
type DispatchProps = {
onClose: () => void;
onShowDocsChanged: () => void;
onDarkModeChanged: () => void;
};
@@ -28,16 +30,33 @@ type SettingsProps = StateProps & DispatchProps & WithI18nProps;
class SettingsDrawer extends React.PureComponent<SettingsProps> {
render(): JSX.Element {
const { i18n, open, onClose, darkMode, onDarkModeChanged } = this.props;
const {
i18n,
open,
onClose,
showDocs,
onShowDocsChanged,
darkMode,
onDarkModeChanged,
} = this.props;
return (
<Drawer
isOpen={open}
icon="cog"
size={Drawer.SIZE_SMALL}
title={i18n.translate(SettingsStringId.Title)}
onClose={() => onClose()}
>
<div className="pb-settings">
<FormGroup label={i18n.translate(SettingsStringId.AppearanceTitle)}>
<Switch
label={i18n.translate(
SettingsStringId.AppearanceDocumentationLabel,
)}
large={true}
checked={showDocs}
onChange={() => onShowDocsChanged()}
/>
<Switch
label={i18n.translate(
SettingsStringId.AppearanceDarkModeLabel,
@@ -55,11 +74,13 @@ class SettingsDrawer extends React.PureComponent<SettingsProps> {
const mapStateToProps = (state: RootState): StateProps => ({
open: state.app.showSettings,
showDocs: state.settings.showDocs,
darkMode: state.settings.darkMode,
});
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
onClose: (): Action => dispatch(closeSettings()),
onShowDocsChanged: (): Action => dispatch(toggleDocs()),
onDarkModeChanged: (): Action => dispatch(toggleDarkMode()),
});