diff --git a/src/components/modals/main/scss/settings/_main.scss b/src/components/modals/main/scss/settings/_main.scss index f4d8c1fe..f2ca1e3f 100644 --- a/src/components/modals/main/scss/settings/_main.scss +++ b/src/components/modals/main/scss/settings/_main.scss @@ -157,8 +157,12 @@ input[type=color]::-moz-color-swatch { color: map-get($button-colours, 'reset') !important; } +.MuiFormControlLabel-labelPlacementStart { + margin-left: 0px; +} + .MuiSwitch-colorPrimary.Mui-checked + .MuiSwitch-track { - background-color: var(--sidebar) !important; + background: darkgray !important; } .reminder-info { diff --git a/src/components/modals/main/settings/Dropdown.jsx b/src/components/modals/main/settings/Dropdown.jsx index 1619bbe8..9f54a932 100644 --- a/src/components/modals/main/settings/Dropdown.jsx +++ b/src/components/modals/main/settings/Dropdown.jsx @@ -1,18 +1,26 @@ import React from 'react'; export default class Dropdown extends React.PureComponent { + constructor(...args) { + super(...args); + this.state = { + value: localStorage.getItem(this.props.name) || '' + }; + } + getLabel() { return this.props.label ? {this.props.label} : null; } - componentDidMount() { - document.getElementById(this.props.name).value = localStorage.getItem(this.props.name); - } - - onChange = () => { - localStorage.setItem(this.props.name, document.getElementById(this.props.name).value); + onChange(value) { + this.setState({ + value: value + }); + + localStorage.setItem(this.props.name, value); + if (this.props.onChange) { - this.props.onChange(); + this.props.onChange(value); } } @@ -21,7 +29,7 @@ export default class Dropdown extends React.PureComponent { {this.getLabel()} - + this.onChange(e.target.value)}> {this.props.children} diff --git a/src/components/modals/main/settings/sections/Appearance.jsx b/src/components/modals/main/settings/sections/Appearance.jsx index 2cdde27d..85a93dc8 100644 --- a/src/components/modals/main/settings/sections/Appearance.jsx +++ b/src/components/modals/main/settings/sections/Appearance.jsx @@ -34,33 +34,25 @@ export default function AppearanceSettings(props) { {appearance.font.title} + + + {/* names are taken from https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight */} + Thin + Extra-Light + Light + Normal + Medium + Semi-Bold + Bold + Extra-Bold + + + + Normal + Italic + Oblique + - localStorage.setItem('fontWeight', document.getElementById('fontWeight').value)}> - {/* names are taken from https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight */} - Thin - Extra-Light - Light - Normal - Medium - Semi-Bold - Bold - Extra-Bold - - - localStorage.setItem('fontStyle', document.getElementById('fontStyle').value)}> - Normal - Italic - Oblique - - {appearance.accessibility.title} diff --git a/src/components/modals/main/settings/sections/Background.jsx b/src/components/modals/main/settings/sections/Background.jsx index dfafb215..af01789d 100644 --- a/src/components/modals/main/settings/sections/Background.jsx +++ b/src/components/modals/main/settings/sections/Background.jsx @@ -5,6 +5,7 @@ import Dropdown from '../Dropdown'; import FileUpload from '../FileUpload'; import Slider from '../Slider'; import Text from '../Text'; +import Switch from '../Switch'; import { ColorPicker } from 'react-color-gradient-picker'; import hexToRgb from '../../../../../modules/helpers/background/hexToRgb'; @@ -203,7 +204,7 @@ export default class BackgroundSettings extends React.PureComponent { return ( {background.title} - + {background.buttons.title} diff --git a/src/components/modals/main/settings/sections/Greeting.jsx b/src/components/modals/main/settings/sections/Greeting.jsx index d79825e4..3123cc13 100644 --- a/src/components/modals/main/settings/sections/Greeting.jsx +++ b/src/components/modals/main/settings/sections/Greeting.jsx @@ -16,11 +16,6 @@ export default class GreetingSettings extends React.PureComponent { } changeDate(data) { - //soon - if (data === 'reset') { - return; - } - localStorage.setItem('birthday', data); this.setState({ @@ -41,6 +36,7 @@ export default class GreetingSettings extends React.PureComponent { {greeting.birthday} + {greeting.birthday_date} this.changeDate(data)} value={this.state.birthday}/> diff --git a/src/components/modals/main/settings/sections/Language.jsx b/src/components/modals/main/settings/sections/Language.jsx index bffb14d7..31c9888f 100644 --- a/src/components/modals/main/settings/sections/Language.jsx +++ b/src/components/modals/main/settings/sections/Language.jsx @@ -13,7 +13,7 @@ export default function LanguageSettings () { {language.title} - localStorage.setItem('quotelanguage', document.getElementById('quotelanguage').value)}> + English Français diff --git a/src/components/modals/main/settings/sections/Quote.jsx b/src/components/modals/main/settings/sections/Quote.jsx index 0d00d23c..e939302b 100644 --- a/src/components/modals/main/settings/sections/Quote.jsx +++ b/src/components/modals/main/settings/sections/Quote.jsx @@ -2,6 +2,7 @@ import React from 'react'; import Checkbox from '../Checkbox'; import Text from '../Text'; +import Switch from '../Switch'; export default function QuoteSettings(props) { const { quote } = window.language.modals.main.settings.sections; @@ -9,7 +10,7 @@ export default function QuoteSettings(props) { return ( {quote.title} - + diff --git a/src/components/modals/main/settings/sections/Search.jsx b/src/components/modals/main/settings/sections/Search.jsx index e5bcc7da..c72df335 100644 --- a/src/components/modals/main/settings/sections/Search.jsx +++ b/src/components/modals/main/settings/sections/Search.jsx @@ -28,8 +28,6 @@ export default class SearchSettings extends React.PureComponent { } else { localStorage.removeItem('customSearchEngine'); } - - document.getElementById('searchEngine').value = searchEngine; } componentDidUpdate() { @@ -64,14 +62,11 @@ export default class SearchSettings extends React.PureComponent { - this.setSearchEngine(document.getElementById('searchEngine').value)} > - {searchEngines.map((engine) => - {engine.name} - )} - {search.custom.split(' ')[0]} + this.setSearchEngine(value)}> + {searchEngines.map((engine) => + {engine.name} + )} + {search.custom.split(' ')[0]} diff --git a/src/components/modals/main/settings/sections/Time.jsx b/src/components/modals/main/settings/sections/Time.jsx index b84231f2..71f35ead 100644 --- a/src/components/modals/main/settings/sections/Time.jsx +++ b/src/components/modals/main/settings/sections/Time.jsx @@ -2,6 +2,7 @@ import React from 'react'; import Checkbox from '../Checkbox'; import Dropdown from '../Dropdown'; +import Switch from '../Switch'; export default class TimeSettings extends React.PureComponent { constructor(...args) { @@ -12,9 +13,7 @@ export default class TimeSettings extends React.PureComponent { this.language = window.language.modals.main.settings; } - changeType() { - const value = document.getElementById('timeType').value; - localStorage.setItem('timeType', value); + changeType(value) { this.setState({ timeType: value }); @@ -55,8 +54,8 @@ export default class TimeSettings extends React.PureComponent { return ( {time.title} - - this.changeType()}> + + this.changeType(value)}> {time.digital.title} {time.analogue.title} {time.percentage_complete} diff --git a/src/components/widgets/greeting/Greeting.jsx b/src/components/widgets/greeting/Greeting.jsx index c829ea95..b6b84718 100644 --- a/src/components/widgets/greeting/Greeting.jsx +++ b/src/components/widgets/greeting/Greeting.jsx @@ -1,5 +1,7 @@ import React from 'react'; +import dtf from '@eartharoid/dtf'; + import './greeting.scss'; export default class Greeting extends React.PureComponent { @@ -34,6 +36,12 @@ export default class Greeting extends React.PureComponent { return message; } + calculateAge(date) { + const diff = Date.now() - date.getTime(); + const birthday = new Date(diff); + return Math.abs(birthday.getUTCFullYear() - 1970); + } + getGreeting() { const now = new Date(); const hour = now.getHours(); @@ -73,7 +81,12 @@ export default class Greeting extends React.PureComponent { // Birthday const birth = new Date(localStorage.getItem('birthday')); if (localStorage.getItem('birthdayenabled') === 'true' && birth.getDate() === now.getDate() && birth.getMonth() === now.getMonth()) { - message = this.language.birthday; + if (localStorage.getItem('birthdayage')) { + const text = this.language.birthday.split(' '); + message = `${text[0]} ${dtf.nth(this.calculateAge(birth))} ${text[1]}`; + } else { + message = this.language.birthday; + } } // Set the state to the greeting string
{greeting.birthday_date}