bb23d37b28
* Moved the state to the clock component * Refactored the store according to the new requirements * Refactored _app so it uses the new store * This file is no longer needed Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
26 lines
662 B
JavaScript
26 lines
662 B
JavaScript
import { useSelector } from 'react-redux'
|
|
|
|
const format = (t) => t.toJSON().slice(11, 19) // cut off except hh:mm:ss
|
|
|
|
export default function Clock() {
|
|
const lastUpdate = useSelector((state) => state.lastUpdate)
|
|
const light = useSelector((state) => state.light)
|
|
return (
|
|
<div className={light ? 'light' : ''}>
|
|
{format(new Date(lastUpdate))}
|
|
<style jsx>{`
|
|
div {
|
|
padding: 15px;
|
|
display: inline-block;
|
|
color: #82fa58;
|
|
font: 50px menlo, monaco, monospace;
|
|
background-color: #000;
|
|
}
|
|
|
|
.light {
|
|
background-color: #999;
|
|
}
|
|
`}</style>
|
|
</div>
|
|
)
|
|
}
|