HomeTodo.js
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React, { useState, useEffect } from "react";
import styled from "styled-components";
import moment from "moment";
import Input from "../Input";
const HomeTodo = styled.div`
display: flex;
flex-direction: column;
`;
const DateBox = styled.div`
display: flex;
flex-direction: column;
input {
margin-top: 20px;
background: none;
border-bottom: 1px solid;
border-radius: 0px;
border-color: white;
}
`;
const DateSpan = styled.span`
font-size: ${(props) => {
if (props.className === "Clock") return "85px";
if (props.className === "Title") return "30px";
}};
color: white;
text-align: center;
&:not(:last-child) {
margin-bottom: 20px;
}
`;
export default () => {
const [date, setDate] = useState(moment().format("h:mm:ss"));
useEffect(() => {
let timer = setInterval(() => tick(), 1000);
return function cleanUp() {
clearInterval(timer);
};
});
function tick() {
setDate(moment().format("h:mm:ss"));
}
return (
<HomeTodo>
<DateBox>
<DateSpan className="Clock">{date}</DateSpan>
<DateSpan className="Title">Enter Todo list</DateSpan>
<Input placeholder={""} />
</DateBox>
</HomeTodo>
);
};