diff --git a/src/components/modals/settings/sections/Appearance.jsx b/src/components/modals/settings/sections/Appearance.jsx index 7a00e895..251832dd 100644 --- a/src/components/modals/settings/sections/Appearance.jsx +++ b/src/components/modals/settings/sections/Appearance.jsx @@ -1,15 +1,46 @@ import React from 'react'; + import Checkbox from '../Checkbox'; +import { toast } from 'react-toastify'; + export default class AppearanceSettings extends React.PureComponent { constructor(...args) { super(...args); this.state = { - zoom: 100, - toast_duration: 2500 + zoom: localStorage.getItem('zoom'), + toast_duration: localStorage.getItem('toastDisplayTime') }; } + resetItem(key) { + switch (key) { + case 'zoom': + localStorage.setItem('zoom', 100); + this.setState({ + zoom: 100 + }); + break; + + case 'toast_duration': + localStorage.setItem('toastDisplayTime', 2500); + this.setState({ + toast_duration: 2500 + }); + break; + + default: + toast('resetItem requires a key!'); + } + + toast(this.props.language.toasts.reset); + } + + componentDidUpdate() { + localStorage.setItem('zoom', this.state.zoom); + localStorage.setItem('toastDisplayTime', this.state.toast_duration); + } + render() { const { appearance } = this.props.language.sections; @@ -21,12 +52,12 @@ export default class AppearanceSettings extends React.PureComponent {
{appearance.accessibility.zoom} (100%) {this.props.language.buttons.reset}
- +{appearance.accessibility.zoom} ({this.state.zoom}%) this.resetItem('zoom')}>{this.props.language.buttons.reset}
+ this.setState({ zoom: event.target.value })} />{appearance.accessibility.toast_duration} (2500 {appearance.accessibility.milliseconds}) {this.props.language.buttons.reset}
- +{appearance.accessibility.toast_duration} ({this.state.toast_duration} {appearance.accessibility.milliseconds}) this.resetItem('toast_duration')}>{this.props.language.buttons.reset}
+ this.setState({ toast_duration: event.target.value })} />