-
Notifications
You must be signed in to change notification settings - Fork 0
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 #5 from Read-bird/feature/feat-calendar/youjeong
홈 캘린더 화면 UI 구현
- Loading branch information
Showing
42 changed files
with
748 additions
and
256 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { SVGProps } from 'react'; | ||
|
||
type TIconProps = { | ||
fillColor?: string; | ||
strokeColor?: string; | ||
} & SVGProps<SVGSVGElement>; | ||
|
||
export const IconBook = ({ fillColor = '#E3CCF2', strokeColor = 'white' }: TIconProps) => { | ||
return ( | ||
<svg width="46" height="39" viewBox="0 0 46 39" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path | ||
d="M34.5 0C28.1534 0 23 4.5918 23 10.2542C23 4.5918 17.8466 0.0128986 11.5 0.0128986C5.15336 0.0128986 0 4.6047 0 10.2671C0 10.2671 0 10.28 0 10.2929V38.2564C0 38.7852 0.563846 38.9916 0.852329 38.5789C2.57012 36.025 6.68757 34.2321 11.5 34.2321C16.3124 34.2321 20.443 36.025 22.1477 38.5789C22.423 38.9916 23 38.7852 23 38.2564C23 38.7852 23.5638 38.9916 23.8523 38.5789C25.5701 36.025 29.6876 34.2321 34.5 34.2321C39.3124 34.2321 43.443 36.025 45.1477 38.5789C45.423 38.9916 46 38.7852 46 38.2564V10.2929C46 10.2929 46 10.28 46 10.2671C46 4.6047 40.8466 0.0128986 34.5 0.0128986V0ZM23 10.28C23 10.28 23 10.28 23 10.2671C23 10.2671 23 10.2671 23 10.28Z" | ||
fill={fillColor} | ||
/> | ||
<path | ||
d="M34.833 12.9697L33.5741 11.7483C32.972 11.1645 32.005 11.1735 31.412 11.7663L21.1491 22.0225L16.1681 17.1908C15.6846 16.7238 14.891 16.7238 14.4166 17.1998L12.7654 18.8523C12.291 19.3282 12.291 20.1096 12.7745 20.5766L20.3189 27.8961C20.8024 28.3631 21.5961 28.3631 22.0705 27.8871L34.8513 15.1072C35.4442 14.5144 35.4351 13.5625 34.833 12.9787V12.9697Z" | ||
fill={strokeColor} | ||
/> | ||
</svg> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { SVGProps } from 'react'; | ||
|
||
type TIconProps = { | ||
fillColor?: string; | ||
strokeColor?: string; | ||
} & SVGProps<SVGSVGElement>; | ||
|
||
export const IconDayBirdMini = ({ | ||
fillColor = 'transparent', | ||
strokeColor = '#ABABAB', | ||
...props | ||
}: TIconProps) => { | ||
return ( | ||
<svg | ||
width="17" | ||
height="15" | ||
viewBox="0 0 17 15" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
> | ||
<path | ||
d="M15.8222 10.3837H14.2193C14.7487 9.30874 14.9944 8.0704 14.8482 6.7604C14.5177 3.75915 12.1017 1.3484 9.10947 1.03595C6.59695 0.775094 4.3389 1.9561 3.05486 3.85661L1.30282 3.73335C1.07175 3.73048 0.925505 3.97987 1.03958 4.18052L2.16568 5.80298C1.92876 6.68587 1.86733 7.64329 2.03991 8.6351C2.51374 11.3726 4.72792 13.5426 7.46859 13.9324C9.62426 14.2392 11.6161 13.4795 12.9909 12.1007C12.9909 12.1007 12.9938 12.1007 12.9967 12.1007C13.6548 11.4902 14.8511 11.0172 15.8748 10.7219C16.0679 10.6675 16.0269 10.378 15.8251 10.378L15.8222 10.3837Z" | ||
fill={fillColor} | ||
stroke={strokeColor} | ||
strokeWidth="0.5" | ||
strokeMiterlimit="10" | ||
/> | ||
</svg> | ||
); | ||
}; |
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
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 |
---|---|---|
@@ -1,25 +1,61 @@ | ||
import { useState } from 'react'; | ||
import ReactCalendar from 'react-calendar'; | ||
import 'react-calendar/dist/Calendar.css'; | ||
import { TPlanRecord } from '@api/types'; | ||
import { DayBird } from '@components/common/DayBird'; | ||
import { cls, getClassByStatus } from '@utils/classname'; | ||
import { convertMap } from '@utils/function'; | ||
import dayjs from 'dayjs'; | ||
import { useCallback, useMemo } from 'react'; | ||
import ReactCalendar, { TileContentFunc, TileDisabledFunc } from 'react-calendar'; | ||
import '../../../styles/calendar.css'; | ||
|
||
type ValuePiece = Date | null; | ||
type TProps = { | ||
currentDate: Date; | ||
record: TPlanRecord[]; | ||
changeCurrentDate: (date: string) => void; | ||
}; | ||
|
||
export const Calendar = ({ record, currentDate, changeCurrentDate }: TProps) => { | ||
const planDateRecord = useMemo(() => convertMap(record, 'createdAt'), [record]); | ||
const onChange = (value: Date) => { | ||
changeCurrentDate(dayjs(value).format()); | ||
}; | ||
|
||
type Value = ValuePiece | [ValuePiece, ValuePiece]; | ||
const tileContent: TileContentFunc = useCallback( | ||
({ date }) => { | ||
const formatDate = dayjs(date).format('YYYY-MM-DD'); | ||
|
||
export const Calendar = () => { | ||
const [value, setValue] = useState<Value>(new Date()); | ||
const data = planDateRecord.get(formatDate); | ||
const className = getClassByStatus(date, data?.status ?? null, currentDate); | ||
|
||
const onChange = (value: Value, event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => { | ||
console.log(value); | ||
}; | ||
return ( | ||
<DayBird | ||
key={`${date}`} | ||
className={cls(className)} | ||
cursor={className === 'after-today' ? 'default' : 'pointer'} | ||
> | ||
<p className={cls(className)}>{dayjs(date).format('DD')}</p> | ||
</DayBird> | ||
); | ||
}, | ||
[planDateRecord, currentDate] | ||
); | ||
|
||
const tileDisabled: TileDisabledFunc = useCallback( | ||
({ date }) => getClassByStatus(date, null, currentDate) === 'after-today', | ||
[currentDate] | ||
); | ||
|
||
return ( | ||
<div className="Calendar"> | ||
<div className="Calendar__container"> | ||
<main className="Calendar__container__content"> | ||
<ReactCalendar onChange={onChange} value={value} /> | ||
</main> | ||
</div> | ||
</div> | ||
<ReactCalendar | ||
value={currentDate} | ||
onClickDay={onChange} | ||
calendarType="gregory" | ||
formatDay={(_, date) => dayjs(date).format('D')} | ||
goToRangeStartOnSelect={false} | ||
maxDate={new Date(dayjs().add(1, 'year').format('YYYY-MM-DD'))} | ||
showNavigation={false} | ||
tileContent={tileContent} | ||
tileDisabled={tileDisabled} | ||
activeStartDate={currentDate} | ||
/> | ||
); | ||
}; |
47 changes: 15 additions & 32 deletions
47
...onents/common/Calendar/CustomCalendar.tsx → ...mponents/common/Calendar/WeekCalendar.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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { Calendar } from './Calendar'; | ||
export { CustomCalendar } from './CustomCalendar'; | ||
export { WeekCalendar } from './WeekCalendar'; |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { LoadingTemplate } from '@components/templates/LoadingTemplate'; | ||
import { LazyExoticComponent, Suspense } from 'react'; | ||
|
||
export const Loadable = | ||
( | ||
Component: LazyExoticComponent<() => JSX.Element>, | ||
fallback: JSX.Element = <div>로딩중...</div> | ||
) => | ||
() => ( | ||
<Suspense fallback={fallback}> | ||
<Component /> | ||
</Suspense> | ||
); | ||
( | ||
Component: LazyExoticComponent<() => JSX.Element>, | ||
fallback: JSX.Element = <LoadingTemplate /> | ||
) => | ||
() => ( | ||
<Suspense fallback={fallback}> | ||
<Component /> | ||
</Suspense> | ||
); |
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,3 @@ | ||
export const Loading = () => { | ||
return <div>로딩중이에요.</div>; | ||
}; |
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 @@ | ||
export { Loading } from './Loading'; |
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
Oops, something went wrong.