diff --git a/frontend/src/components/SearchBar/Calendar/CalendarModal.tsx b/frontend/src/components/SearchBar/Calendar/CalendarModal.tsx index d79bf7d7a..3519ba2ae 100644 --- a/frontend/src/components/SearchBar/Calendar/CalendarModal.tsx +++ b/frontend/src/components/SearchBar/Calendar/CalendarModal.tsx @@ -1,16 +1,10 @@ import { useRecoilValue } from 'recoil'; -import { calendarModalState } from 'recoil/Atoms'; import * as S from "components/SearchBar/Calendar/CalendarStyles"; +import MonthlyCalendar from 'components/SearchBar/Calendar/MonthlyCalendar'; const CalendarModal = () => { - const { year, month, today } = useRecoilValue(calendarModalState); - const daysOfWeek: string[] = ["일", "월", "화", "수", "목", "금", "토"]; - const startDay: number = new Date(year, month, 1).getDay(); - const endDate: number = new Date(year, month, 0).getDate(); - const emptyDates: (number | string)[] = Array(startDay).fill(""); - const filledDates = Array.from({ length : endDate },(_, i) => i + 1); - const dates = [...emptyDates, ...filledDates]; - const calendarTemplate = dates.map((date, idx) =>
{date}
) + const monthTypes: string[] = ["PREVIOUS", "CURRENT", "NEXT", "MONTH_AFTER_NEXT"]; + return ( @@ -19,28 +13,17 @@ const CalendarModal = () => { - -
- -
- - - -
{year}년 {month}월
-
{daysOfWeek.map(day => {day})}
-
{calendarTemplate}
-
-
- -
-
{year}년 {month + 1}월
- - - -
-
-
-
+ + + + + + + + {monthTypes.map((_, idx) => + + )} +
); }; diff --git a/frontend/src/components/SearchBar/Calendar/CalendarStyles.tsx b/frontend/src/components/SearchBar/Calendar/CalendarStyles.tsx index 7ac3fdc1c..92753f101 100644 --- a/frontend/src/components/SearchBar/Calendar/CalendarStyles.tsx +++ b/frontend/src/components/SearchBar/Calendar/CalendarStyles.tsx @@ -14,10 +14,7 @@ const CalendarModalLayout = styled.div` background: #ffffff; box-shadow: rgb(0 0 0 / 20%) 0px 6px 20px; border-radius: 40px; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; + `; const CalendarSelector = styled.div` @@ -59,22 +56,20 @@ const CalendarSelector = styled.div` const CalendarLayout = styled.div` /* outline: red solid 1px; */ - width: 90%; - margin: 1.6rem; + /*margin: 1.6rem;*/ padding: 1.5rem; font-size: 1.6rem; font-weight: 600; .title-container { width: 100%; - display: flex; } `; const LeftArrowBtn = styled.button` position: absolute; - left: 0; - top: 0; + left: 3rem; + top: 2rem; width: 2rem; height: 2rem; border: none; @@ -84,17 +79,16 @@ const LeftArrowBtn = styled.button` &:hover { background-color: rgb(247, 247, 247); } - & > svg { - height: 1.2rem; - width: 1.2rem; + height: 2.5rem; + width: 2.5rem; } `; const RightArrowBtn = styled.button` position: absolute; - right: 0; - top: 0; + right: 3rem; + top: 2rem; width: 2rem; height: 2rem; border: none; @@ -106,18 +100,14 @@ const RightArrowBtn = styled.button` } & > svg { - height: 1.2rem; - width: 1.2rem; + height: 2.5rem; + width: 2.5rem; } `; const CurrentMonth = styled.div` - display: flex; - border: 1px solid green; - width: 50%; - text-align: center; - flex-direction: column; - + /*border: 1px solid green;*/ + .calendar-container { width: 100%; } @@ -132,6 +122,7 @@ const CurrentMonth = styled.div` padding-top: 0.5rem; margin: 0 auto; width: auto; + text-align: center; height: 2rem; } @@ -163,27 +154,12 @@ const CurrentMonth = styled.div` } `; -const NextMonth = styled.div` - display: flex; - border: 1px solid green; - width: 50%; - text-align: center; - flex-direction: column; - - &:last-child { - position: relative; - display: flex; - /* border: 1px solid pink; */ - align-items: center; - } - - .year_and_month { - padding-top: 0.5rem; - margin: 0 auto; - width: auto; - height: 2rem; - } -`; +const MonthlyCalendarContainer = styled.div` + //각 달의 달력들을 가로로 쭈욱 가지고 있는 애 + display: grid; + width: 200%; + grid-template-columns: repeat(4, 1fr); +` export { CalendarModalLayout, @@ -192,7 +168,7 @@ export { LeftArrowBtn, RightArrowBtn, CurrentMonth, - NextMonth, RiArrowLeftSLine, RiArrowRightSLine, + MonthlyCalendarContainer }; diff --git a/frontend/src/components/SearchBar/Calendar/MonthlyCalendar.tsx b/frontend/src/components/SearchBar/Calendar/MonthlyCalendar.tsx new file mode 100644 index 000000000..a1ec5d161 --- /dev/null +++ b/frontend/src/components/SearchBar/Calendar/MonthlyCalendar.tsx @@ -0,0 +1,37 @@ +import { useRecoilValue } from 'recoil'; +import { calendarModalState } from 'recoil/Atoms'; +import * as S from "components/SearchBar/Calendar/CalendarStyles"; + +interface MonthProps { + monthType: string +} + +const MonthlyCalendar:React.FunctionComponent = ({monthType}) => { + const { year, month, today} = useRecoilValue(calendarModalState); + const daysOfWeek: string[] = ["일", "월", "화", "수", "목", "금", "토"]; + const startDay: number = new Date(year, month, 1).getDay(); + const endDate: number = new Date(year, month, 0).getDate(); + const emptyDates: (number | string)[] = Array(startDay).fill(""); + const filledDates = Array.from({ length : endDate },(_, i) => i + 1); + const dates = [...emptyDates, ...filledDates]; + const calendarTemplate = dates.map((date, idx) =>
{date}
) + console.log(monthType); + + return ( + +
+ +
+ +
{year}년 {month}월
+
{daysOfWeek.map(day => {day})}
+
{calendarTemplate}
+
+
+
+
+ ); +}; + +export default MonthlyCalendar; + diff --git a/frontend/src/components/SearchBar/Calendar/Old.tsx b/frontend/src/components/SearchBar/Calendar/Old.md similarity index 99% rename from frontend/src/components/SearchBar/Calendar/Old.tsx rename to frontend/src/components/SearchBar/Calendar/Old.md index 542e1e573..2d2a09dc0 100644 --- a/frontend/src/components/SearchBar/Calendar/Old.tsx +++ b/frontend/src/components/SearchBar/Calendar/Old.md @@ -1,3 +1,5 @@ +export {}; +/* import * as S from "components/SearchBar/Calendar/CalendarStyles"; import moment, { Moment } from "moment"; import 'moment/locale/ko'; @@ -60,3 +62,4 @@ const CalendarModal = () => { export default CalendarModal; +*/ \ No newline at end of file diff --git a/frontend/src/components/SearchBar/SearchBar.tsx b/frontend/src/components/SearchBar/SearchBar.tsx index 44cfd59e3..78bf2bb1d 100644 --- a/frontend/src/components/SearchBar/SearchBar.tsx +++ b/frontend/src/components/SearchBar/SearchBar.tsx @@ -11,20 +11,15 @@ import { useSetRecoilState, } from "recoil"; import React, { useState, useEffect } from "react"; -import { searchBarClickState, checkInClickState } from "recoil/Atoms"; +import { searchBarClickState } from "recoil/Atoms"; const SearchBar = () => { // const Reset = useResetRecoilState(searchBarClickState); const setsSearchBarClick = useSetRecoilState(searchBarClickState); - const checkInTest = useRecoilValue(checkInClickState); useEffect(() => { - console.log(checkInTest); - if (checkInTest) document.body.addEventListener("click", ClosePopup); - return function cleanup() { - document.body.removeEventListener("click", ClosePopup); - }; - }, [checkInTest]); + document.body.addEventListener("click", ClosePopup); + }, []); const ClosePopup = (e: MouseEvent): void => { console.log(33);