mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 11:04:49 +00:00
move docs toggle to settings
This commit is contained in:
@@ -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()),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user