sdy

update homeCalendar

...@@ -2,6 +2,7 @@ import React from "react"; ...@@ -2,6 +2,7 @@ import React from "react";
2 import styled from "styled-components"; 2 import styled from "styled-components";
3 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; 3 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
4 import { faArrowLeft, faArrowRight } from "@fortawesome/free-solid-svg-icons"; 4 import { faArrowLeft, faArrowRight } from "@fortawesome/free-solid-svg-icons";
5 +import moment from "moment";
5 6
6 const HomeCalendarWrapper = styled.div` 7 const HomeCalendarWrapper = styled.div`
7 display: flex; 8 display: flex;
...@@ -10,6 +11,9 @@ const HomeCalendarWrapper = styled.div` ...@@ -10,6 +11,9 @@ const HomeCalendarWrapper = styled.div`
10 align-items: center; 11 align-items: center;
11 height: 50%; 12 height: 50%;
12 width: 100%; 13 width: 100%;
14 + background-color: white;
15 + opacity: 0.8;
16 + border-radius: 10px;
13 `; 17 `;
14 18
15 const CalenderBox = styled.div` 19 const CalenderBox = styled.div`
...@@ -19,7 +23,6 @@ const CalenderBox = styled.div` ...@@ -19,7 +23,6 @@ const CalenderBox = styled.div`
19 align-items: center; 23 align-items: center;
20 height: 100%; 24 height: 100%;
21 width: 100%; 25 width: 100%;
22 - border: 1px solid;
23 `; 26 `;
24 27
25 const CalenderMenuBox = styled.div` 28 const CalenderMenuBox = styled.div`
...@@ -29,7 +32,6 @@ const CalenderMenuBox = styled.div` ...@@ -29,7 +32,6 @@ const CalenderMenuBox = styled.div`
29 align-items: center; 32 align-items: center;
30 height: 15%; 33 height: 15%;
31 width: 100%; 34 width: 100%;
32 - border: 1px solid;
33 `; 35 `;
34 36
35 const DateInfoSpan = styled.span` 37 const DateInfoSpan = styled.span`
...@@ -48,12 +50,15 @@ const DateBodyBox = styled.div` ...@@ -48,12 +50,15 @@ const DateBodyBox = styled.div`
48 50
49 const DateRow = styled.div` 51 const DateRow = styled.div`
50 width: 100%; 52 width: 100%;
53 + height: 100%;
51 display: flex; 54 display: flex;
52 flex-direction: row; 55 flex-direction: row;
53 justify-content: space-around; 56 justify-content: space-around;
57 + align-items: center;
54 `; 58 `;
55 59
56 const DateText = styled.span` 60 const DateText = styled.span`
61 + text-align: center;
57 font-family: "Overpass", sans-serif; 62 font-family: "Overpass", sans-serif;
58 color: ${(props) => { 63 color: ${(props) => {
59 if (props.className === "Sunday") return "#EA2027"; 64 if (props.className === "Sunday") return "#EA2027";
...@@ -62,6 +67,37 @@ const DateText = styled.span` ...@@ -62,6 +67,37 @@ const DateText = styled.span`
62 `; 67 `;
63 68
64 export default () => { 69 export default () => {
70 + const generate = () => {
71 + const today = moment();
72 + const startWeek = today.clone().startOf("month").week();
73 + const endWeek =
74 + today.clone().endOf("month").week() === 1
75 + ? 53
76 + : today.clone().endOf("month").week();
77 + let calendar = [];
78 + for (let week = startWeek; week <= endWeek; week++) {
79 + calendar.push(
80 + <DateRow key={week}>
81 + {Array(7)
82 + .fill(0)
83 + .map((n, i) => {
84 + let current = today
85 + .clone()
86 + .week(week)
87 + .startOf("week")
88 + .add(n + i, "day");
89 + return (
90 + <DateText className={`text`} key={i}>
91 + {current.format("D")}
92 + </DateText>
93 + );
94 + })}
95 + </DateRow>
96 + );
97 + }
98 + return calendar;
99 + };
100 +
65 return ( 101 return (
66 <HomeCalendarWrapper> 102 <HomeCalendarWrapper>
67 <CalenderBox> 103 <CalenderBox>
...@@ -80,15 +116,7 @@ export default () => { ...@@ -80,15 +116,7 @@ export default () => {
80 <DateText>FRI</DateText> 116 <DateText>FRI</DateText>
81 <DateText className="Saturday">SAT</DateText> 117 <DateText className="Saturday">SAT</DateText>
82 </DateRow> 118 </DateRow>
83 - <DateRow> 119 + {generate()}
84 - <DateText>26</DateText>
85 - <DateText>27</DateText>
86 - <DateText>28</DateText>
87 - <DateText>29</DateText>
88 - <DateText>30</DateText>
89 - <DateText>1</DateText>
90 - <DateText>2</DateText>
91 - </DateRow>
92 </DateBodyBox> 120 </DateBodyBox>
93 </CalenderBox> 121 </CalenderBox>
94 </HomeCalendarWrapper> 122 </HomeCalendarWrapper>
......