-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from ghojeong/fe/47/new-calendar
[FE] 캘린더 UI 기초틀 완성
- Loading branch information
Showing
6 changed files
with
181 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
frontend/src/components/SearchBar/Calendar/MonthlyCalendar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MonthProps> = ({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) => <div key={'date-' + idx}>{date}</div>) | ||
console.log(monthType); | ||
|
||
return ( | ||
<S.CalendarLayout> | ||
<div className="title-container"> | ||
<S.CurrentMonth> | ||
<div className="calendar-container"> | ||
|
||
<div className="year_and_month">{year}년 {month}월</div> | ||
<div className="days">{daysOfWeek.map(day => <span>{day}</span>)}</div> | ||
<div className="dates">{calendarTemplate}</div> | ||
</div> | ||
</S.CurrentMonth> | ||
</div> | ||
</S.CalendarLayout> | ||
); | ||
}; | ||
|
||
export default MonthlyCalendar; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
export {}; | ||
/* | ||
import * as S from "components/SearchBar/Calendar/CalendarStyles"; | ||
import moment, { Moment } from "moment"; | ||
import 'moment/locale/ko'; | ||
moment.locale('ko'); | ||
|
||
const CalendarModal = () => { | ||
const value = moment(); //현재 날짜값 가져오기 | ||
const startDay = value.clone().startOf("month").startOf("week");//clone을 해주는 이유 = 원본 now Date를 보존하기 위해. | ||
const endDay = value.clone().endOf("month").endOf("week"); | ||
const day = startDay.clone().subtract(1, "day"); //시작일에서 하루 빼기 | ||
const calendar:Array<Moment[]> = []; | ||
|
||
//들어오는 day 값이 endDay 이전 값인지 체크. | ||
const createCalendar = () => { | ||
while(day.isBefore(endDay, "day")) { | ||
calendar.push(Array(7).fill(0).map(() => day.add(1, "day").clone())); | ||
} | ||
//format()을 하면 moment 객체에서 string으로 바꿔줌. | ||
//[[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [],,] | ||
return calendar.map(week => | ||
<div className="calendar"> | ||
{week.map((day) => { | ||
<div>{day.format("D").toString()}</div> | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
console.log(startDay.format("D").toString(), endDay.format("D").toString(), day.format("D").toString()); | ||
|
||
return ( | ||
<S.CalendarModalLayout> | ||
<S.CalendarSelector> | ||
<div> | ||
<button>달력</button> | ||
<button>자유로운 일정</button> | ||
</div> | ||
</S.CalendarSelector> | ||
<S.CalendarLayout> | ||
<S.CurrentMonth> | ||
<div> | ||
<S.LeftArrowBtn> | ||
<S.RiArrowLeftSLine/> | ||
</S.LeftArrowBtn> | ||
<div className="year_and_month">{startDay.format("YYYY")}년 {startDay.format("MM")}월</div> | ||
</div> | ||
</S.CurrentMonth> | ||
<S.NextMonth> | ||
<div> | ||
<div className="year_and_month">{endDay.format("YYYY")}년 {endDay.format("MM")}월</div> | ||
<S.RightArrowBtn> | ||
<S.RiArrowRightSLine/> | ||
</S.RightArrowBtn> | ||
</div> | ||
</S.NextMonth> | ||
</S.CalendarLayout> | ||
</S.CalendarModalLayout> | ||
); | ||
}; | ||
|
||
export default CalendarModal; | ||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.