1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-mobx-state-tree-typescript/components/Clock.tsx

20 lines
479 B
TypeScript
Raw Normal View History

const format = (t) => `${pad(t.getUTCHours())}:${pad(t.getUTCMinutes())}:${pad(t.getUTCSeconds())}`;
const pad = (n) => n < 10 ? `0${n}` : n;
const Clock = (props) => {
const divStyle = {
backgroundColor:(props.light ? "#999" : "#000"),
color:"#82FA58",
display:"inline-block",
font:"50px menlo, monaco, monospace",
padding:"15px",
};
return (
<div style={divStyle}>
{format(new Date(props.lastUpdate))}
</div>
);
};
export { Clock };