diff --git a/src/components/modals/main/scss/settings/_main.scss b/src/components/modals/main/scss/settings/_main.scss index 4e083c5b..853016d6 100644 --- a/src/components/modals/main/scss/settings/_main.scss +++ b/src/components/modals/main/scss/settings/_main.scss @@ -144,6 +144,13 @@ input[type=color]::-moz-color-swatch { .radio-title { text-transform: uppercase; font-weight: bold; + font-size: 1.17rem; +} + +.radio-title-small { + text-transform: uppercase; + font-weight: bold; + font-size: 1rem; } .sortableitem { diff --git a/src/components/modals/main/settings/Radio.jsx b/src/components/modals/main/settings/Radio.jsx index 36fda249..45841b0a 100644 --- a/src/components/modals/main/settings/Radio.jsx +++ b/src/components/modals/main/settings/Radio.jsx @@ -27,7 +27,7 @@ export default class Radio extends React.PureComponent { render() { return ( - {this.props.title} + {this.props.title} {this.props.options.map((option) => ( } label={option.name} key={option.name} /> diff --git a/src/components/modals/main/settings/sections/Search.jsx b/src/components/modals/main/settings/sections/Search.jsx index d1fc42bb..0ee70244 100644 --- a/src/components/modals/main/settings/sections/Search.jsx +++ b/src/components/modals/main/settings/sections/Search.jsx @@ -1,55 +1,62 @@ import React from 'react'; -import { isChrome } from 'react-device-detect'; -import { toast } from 'react-toastify'; - import Dropdown from '../Dropdown'; import Checkbox from '../Checkbox'; import Switch from '../Switch'; +import { isChrome } from 'react-device-detect'; +import { toast } from 'react-toastify'; + const searchEngines = require('../../../../widgets/search/search_engines.json'); export default class SearchSettings extends React.PureComponent { + constructor() { + super(); + this.state = { + customEnabled: false, + customDisplay: 'none', + customValue: localStorage.getItem('customSearchEngine') || '' + }; + this.language = window.language.modals.main.settings; + } + resetSearch() { localStorage.removeItem('customSearchEngine'); - document.getElementById('customSearchEngine').value = ''; + this.setState({ + customValue: '' + }); - toast(this.props.language.toasts.reset); + toast(window.language.modals.main.settings.toasts.reset); } componentDidMount() { - const searchEngine = localStorage.getItem('searchEngine'); - - if (searchEngine === 'custom') { - const input = document.getElementById('searchEngineInput'); - - input.style.display = 'block'; - input.enabled = 'true'; - - document.getElementById('customSearchEngine').value = localStorage.getItem('customSearchEngine'); + if (localStorage.getItem('searchEngine') === 'custom') { + this.setState({ + customDisplay: 'block', + customEnabled: true + }); } else { localStorage.removeItem('customSearchEngine'); } } componentDidUpdate() { - if (document.getElementById('searchEngineInput').enabled === 'true') { - const input = document.getElementById('customSearchEngine').value; - if (input) { - localStorage.setItem('searchEngine', 'custom'); - localStorage.setItem('customSearchEngine', input); - } + if (this.state.customEnabled === true && this.state.customValue !== '') { + localStorage.setItem('customSearchEngine', this.state.customValue); } } setSearchEngine(input) { - const searchEngineInput = document.getElementById('searchEngineInput'); if (input === 'custom') { - searchEngineInput.enabled = 'true'; - searchEngineInput.style.display = 'block'; + this.setState({ + customDisplay: 'block', + customEnabled: true + }); } else { - searchEngineInput.style.display = 'none'; - searchEngineInput.enabled = 'false'; + this.setState({ + customDisplay: 'none', + customEnabled: false + }); localStorage.setItem('searchEngine', input); } } @@ -63,15 +70,18 @@ export default class SearchSettings extends React.PureComponent {

{search.title}

{isChrome ? : null} + this.setSearchEngine(value)}> {searchEngines.map((engine) => ( ))} -
    -

    {search.custom} this.resetSearch()}>{language.reset}

    - + +

    +
      +

      {search.custom} this.resetSearch()}>{language.buttons.reset}

      + this.setState({ customValue: e.target.value })}>
    ); diff --git a/src/components/modals/main/settings/sections/Time.jsx b/src/components/modals/main/settings/sections/Time.jsx index 34770994..74a4a903 100644 --- a/src/components/modals/main/settings/sections/Time.jsx +++ b/src/components/modals/main/settings/sections/Time.jsx @@ -34,7 +34,7 @@ export default class TimeSettings extends React.PureComponent { const digitalSettings = ( <>

    {time.digital.title}

    - +
    diff --git a/src/components/modals/main/settings/sections/background/Background.jsx b/src/components/modals/main/settings/sections/background/Background.jsx index 2a07d89b..5c34b7d3 100644 --- a/src/components/modals/main/settings/sections/background/Background.jsx +++ b/src/components/modals/main/settings/sections/background/Background.jsx @@ -42,8 +42,8 @@ export default class BackgroundSettings extends React.PureComponent { if (customBackground.endsWith('.mp4') || customBackground.endsWith('.webm') || customBackground.endsWith('.ogg')) { return ( <> - - + + ) } else { @@ -53,7 +53,7 @@ export default class BackgroundSettings extends React.PureComponent { marketplaceType = () => { if (localStorage.getItem('photo_packs')) { - return + return } } @@ -120,6 +120,17 @@ export default class BackgroundSettings extends React.PureComponent { +

    {background.source.title}

    + this.setState({ backgroundType: value })}> + {this.marketplaceType()} + + + + +
    + + {backgroundSettings} +

    {background.buttons.title}

    @@ -129,16 +140,6 @@ export default class BackgroundSettings extends React.PureComponent {

    - - this.setState({ backgroundType: value })}> - {this.marketplaceType()} - - - - -
    - - {backgroundSettings} ); } diff --git a/src/components/modals/main/settings/sections/background/Colour.jsx b/src/components/modals/main/settings/sections/background/Colour.jsx index a5cd85a2..ebcbd7a0 100644 --- a/src/components/modals/main/settings/sections/background/Colour.jsx +++ b/src/components/modals/main/settings/sections/background/Colour.jsx @@ -21,19 +21,11 @@ export default class ColourSettings extends React.PureComponent { this.language = window.language.modals.main.settings; } - resetItem(key) { - switch (key) { - case 'customBackgroundColour': - localStorage.setItem('customBackgroundColour', ''); - this.setState({ - gradientSettings: this.DefaultGradientSettings - }); - break; - - default: - toast('resetItem requires a key!'); - } - + resetColour() { + localStorage.setItem('customBackgroundColour', ''); + this.setState({ + gradientSettings: this.DefaultGradientSettings + }); toast(this.language.toasts.reset); } @@ -177,7 +169,7 @@ export default class ColourSettings extends React.PureComponent { return ( <> -

    {background.source.custom_colour} this.resetItem('customBackgroundColour')}>{this.language.buttons.reset}

    +

    {background.source.custom_colour} this.resetColour()}>{this.language.buttons.reset}

    {colourSettings} diff --git a/src/components/widgets/Widgets.jsx b/src/components/widgets/Widgets.jsx index 0396205e..39cb6e9b 100644 --- a/src/components/widgets/Widgets.jsx +++ b/src/components/widgets/Widgets.jsx @@ -22,20 +22,7 @@ export default class Widgets extends React.PureComponent { } enabled(key) { - const stringValue = localStorage.getItem(key); - let enabled = true; - - if (stringValue !== null) { - if (stringValue === 'true') { - enabled = true; - } - - if (stringValue === 'false') { - enabled = false; - } - } - - return enabled; + return (localStorage.getItem(key) === 'true'); } componentDidMount() { diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index 00bedd64..624d8bb8 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -226,12 +226,12 @@ export default class Background extends React.PureComponent { render() { if (this.state.video === true) { - const checkValue = (setting) => { + const enabled = (setting) => { return (localStorage.getItem(setting) === 'true'); }; return ( -