-
Notifications
You must be signed in to change notification settings - Fork 6
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 #150 from Step3-kakao-tech-campus/weekly
weekly > master
- Loading branch information
Showing
40 changed files
with
911 additions
and
214 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
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,59 +1,63 @@ | ||
import FlexContainer from 'components/@commons/FlexContainer'; | ||
import Text from 'components/@commons/Text'; | ||
import { NextButton, PrevButton } from 'components/@commons/icons/buttons'; | ||
import { PrimitiveAtom, useAtom } from 'jotai'; | ||
import React from 'react'; | ||
import { WeekGrid } from './CalendarStyle'; | ||
import weekdayArray from 'utils/weekdayArray'; | ||
import { WeekGrid } from './CalendarStyle'; | ||
|
||
interface Props { | ||
monthDataAtom: PrimitiveAtom<{ | ||
year: number; | ||
month: number; | ||
}>; | ||
} | ||
const CalenderOutter = ({ selectedMonth, setMonth }: Props): JSX.Element => { | ||
return ( | ||
<FlexContainer $wFull $gap="24px"> | ||
<MonthSelectBar selectedMonth={selectedMonth} setMonth={setMonth} /> | ||
<DayTitle /> | ||
</FlexContainer> | ||
); | ||
}; | ||
|
||
const CalenderOutter = ({ monthDataAtom }: Props): JSX.Element => { | ||
const [nowMonth, setNowMonth] = useAtom(monthDataAtom); | ||
const { year, month } = nowMonth; | ||
export default CalenderOutter; | ||
|
||
const MonthSelectBar = ({ selectedMonth, setMonth }: Props) => { | ||
const { year, month } = selectedMonth; | ||
const monthMoveHandler = (dm: number) => { | ||
const newDateObj = new Date(nowMonth.year, nowMonth.month + dm, 1); | ||
const newObj = { year: newDateObj.getFullYear(), month: newDateObj.getMonth() }; | ||
setNowMonth(newObj); | ||
const newDateObj = new Date(year, month + dm, 1); | ||
setMonth({ year: newDateObj.getFullYear(), month: newDateObj.getMonth() }); | ||
}; | ||
|
||
return ( | ||
<FlexContainer $wFull $gap="24px"> | ||
<FlexContainer $direction="row" $justify="space-between" $wFull> | ||
<PrevButton onClick={() => monthMoveHandler(-1)} /> | ||
<FlexContainer $direction="row" $justify="space-between" $wFull> | ||
<PrevButton onClick={() => monthMoveHandler(-1)} /> | ||
|
||
<FlexContainer $direction="row" $gap="12px"> | ||
<Text size="lg" weight="bold">{`${year} 년`}</Text> | ||
<Text size="lg" weight="bold">{`${month + 1} 월`}</Text> | ||
</FlexContainer> | ||
|
||
<NextButton onClick={() => monthMoveHandler(+1)} /> | ||
</FlexContainer> | ||
<FlexContainer $direction="row" $wFull> | ||
<DayTitle /> | ||
<FlexContainer $direction="row" $gap="12px"> | ||
<Text size="lg" weight="bold">{`${year} 년`}</Text> | ||
<Text size="lg" weight="bold">{`${month + 1} 월`}</Text> | ||
</FlexContainer> | ||
|
||
<NextButton onClick={() => monthMoveHandler(+1)} /> | ||
</FlexContainer> | ||
); | ||
}; | ||
|
||
export default CalenderOutter; | ||
|
||
const DayTitle = () => { | ||
return ( | ||
<WeekGrid> | ||
{weekdayArray.map((e) => ( | ||
<FlexContainer $wFull key={e.eng}> | ||
<Text size="xxs" weight="semiBold"> | ||
{e.eng} | ||
</Text> | ||
</FlexContainer> | ||
))} | ||
</WeekGrid> | ||
<FlexContainer $direction="row" $wFull> | ||
<WeekGrid> | ||
{weekdayArray.map((e) => ( | ||
<FlexContainer $wFull key={e.eng}> | ||
<Text size="xxs" weight="semiBold"> | ||
{e.eng} | ||
</Text> | ||
</FlexContainer> | ||
))} | ||
</WeekGrid> | ||
</FlexContainer> | ||
); | ||
}; | ||
|
||
export interface MonthData { | ||
year: number; | ||
month: number; | ||
} | ||
|
||
interface Props { | ||
selectedMonth: MonthData; | ||
setMonth: (monthdata: MonthData) => void; | ||
} |
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
Oops, something went wrong.