WIP countdown widget

This commit is contained in:
David Ralph
2020-12-05 14:34:52 +00:00
parent 408f8c4502
commit 88e54ad26a
5 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import React from 'react';
import Countdown from 'react-countdown';
import './countdown.scss';
export default class CountdownWidget extends React.PureComponent {
constructor(...args) {
super(...args);
this.state = {
countdown: new Date(localStorage.getItem('birthday')),
message: localStorage.getItem('countdownmessage') || 'until tomorrow'
};
}
render() {
if (localStorage.getItem('countdown') === 'false') return;
return <h4 className='countdown'>
<Countdown date={this.state.countdown + 10000} onComplete={() => this.setState({ message: 'Today\'s the day!'})} /><br/>
{this.state.message}
</h4>;
}
}

View File

@@ -0,0 +1,5 @@
.countdown {
position: absolute;
bottom: 0;
font-size: 0.95em;
}