feat: analog time settings

This commit is contained in:
David Ralph
2021-03-17 18:26:09 +00:00
parent 8f1ebb309c
commit 2454f1bbab
3 changed files with 37 additions and 5 deletions

View File

@@ -19,6 +19,11 @@ export default class TimeSettings extends React.PureComponent {
});
}
componentDidMount() {
document.getElementById('dateformat').value = localStorage.getItem('dateFormat');
document.getElementById('timeType').value = localStorage.getItem('timeType');
}
render() {
let digitalSettings = (
<React.Fragment>
@@ -28,10 +33,23 @@ export default class TimeSettings extends React.PureComponent {
<Checkbox name='ampm' text={this.props.language.ampm} />
<Checkbox name='zero' text={this.props.language.zero} />
</React.Fragment>
)
);
if (this.state.timeType !== 'digital') {
digitalSettings = null;
let analogSettings = (
<React.Fragment>
<h3>Analog</h3>
<Checkbox name='secondHand' text='Seconds Hand' />
<Checkbox name='minuteHand' text='Minutes Hand' />
<Checkbox name='hourHand' text='Hours Hand' />
<Checkbox name='hourMarks' text='Hour Marks' />
<Checkbox name='minuteMarks' text='Minute Marks' />
</React.Fragment>
);
switch (this.state.timeType) {
case 'digital': break;
case 'analogue': digitalSettings = analogSettings; break;
default: digitalSettings = null; break;
}
return (

View File

@@ -97,8 +97,22 @@ export default class Clock extends React.PureComponent {
render() {
let clockHTML = <h1 className='clock'>{this.state.time}<span className='ampm'>{this.state.ampm}</span></h1>;
const checkValue = (setting) => {
return (localStorage.getItem(setting) === 'true');
}
if (localStorage.getItem('timeType') === 'analogue') {
clockHTML = <Analog className='analogclock' value={this.state.time} renderHourMarks={false} renderMinuteMarks={false} />;
clockHTML = (
<Analog
className='analogclock'
value={this.state.time}
renderHourMarks={checkValue('hourMarks')}
renderMinuteMarks={checkValue('minuteMarks')}
renderSecondHand={checkValue('secondHand')}
renderMinuteHand={checkValue('minuteHand')}
renderHourHand={checkValue('hourHand')}
/>
);
}
return clockHTML;

View File

@@ -18,7 +18,7 @@
border: 1px solid map-get($theme-colours, 'main') !important;
}
.react-clock__hand__body {
.react-clock__hand__body, .react-clock__mark__body {
background: map-get($theme-colours, 'main') !important;
box-shadow: 0 0 25px rgba(0, 0, 0, 0.3);
}