diff options
author | Hsuan Lee <boczeratul@gmail.com> | 2019-04-08 22:18:34 +0800 |
---|---|---|
committer | Hsuan Lee <boczeratul@gmail.com> | 2019-04-08 22:18:34 +0800 |
commit | b9c0c169ce805124cb6b3fb84c7db8df9a76151e (patch) | |
tree | 88d4b5a09267a9cc9e4d56ccadeebe588dc36284 /app/containers/App/Timer.js | |
parent | 336162ac78ad3d5c787c5ecfe735b98d423c4053 (diff) | |
download | dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.tar dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.tar.gz dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.tar.bz2 dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.tar.lz dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.tar.xz dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.tar.zst dexon-lottery-b9c0c169ce805124cb6b3fb84c7db8df9a76151e.zip |
Complete webapp
Diffstat (limited to 'app/containers/App/Timer.js')
-rw-r--r-- | app/containers/App/Timer.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/containers/App/Timer.js b/app/containers/App/Timer.js new file mode 100644 index 0000000..a164cd1 --- /dev/null +++ b/app/containers/App/Timer.js @@ -0,0 +1,44 @@ + +import React, { PureComponent } from 'react'; +import styled from 'styled-components'; +import moment from 'moment'; + +import { Container, Header } from '@/components/Mux'; + +const LAUNCH_TIME = 1556164800000; +const Time = styled.div` + font-size: 72px; +`; +const pad = number => `0${number}`.slice(-2); + +class Timer extends PureComponent { + state = { + duration: LAUNCH_TIME - Date.now(), + }; + + componentDidMount() { + setInterval(this.updateTime, 1000); + } + + updateTime = () => { + this.setState({ duration: LAUNCH_TIME - Date.now() }); + } + + render() { + const duration = moment.duration(this.state.duration); + + return ( + <Container> + <Header> + Time Until DEXON Mainnet Launch + </Header> + + <Time> + {(duration.days() * 24) + duration.hours()}:{pad(duration.minutes())}:{pad(duration.seconds())} + </Time> + </Container> + ); + } +} + +export default Timer; |