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