-
Notifications
You must be signed in to change notification settings - Fork 1
[FE-Feat] 캘린더 드래그 또는 클릭으로 시간 선택 구현 #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9928eb2
feat: 셀 15분 단위로 쪼개기
hamo-o 43deec0
fix: 캘린더 헤더에서 컨트롤하는 부분 삭제
hamo-o 065f446
feat: 캘린더에서 날짜 선택 시 선택된 날짜 하이라이팅 애니메이션 후 사라짐
hamo-o 7b58dc5
feat: 타겟이 특정 날짜 범위 내에 있는지 확인하는 유틸함수
hamo-o 3ce15af
feat: 각 셀이 Date 정보를 들고 있도록 수정, DetailCell에서 15분 단위로 클릭 시 선택할 수 있도록
hamo-o b35a80f
feat: useReducer로 선택 중인 상태를 추가하여, 드래그 이벤트들로 시간대 선택하도록
hamo-o aaca99e
feat: 날짜 정렬 로직을 추가하여, 드래그가 종료되면 정렬해서 상태값 결정
hamo-o 4cf7435
feat: 선택 종료 시 확정된 시간 범위 컨텍스트로 관리하여 스타일 변경
hamo-o 2cb1366
chore: 사용하지 않는 변수 삭제
hamo-o 25120eb
feat: 클릭 이벤트로 날짜 선택
hamo-o 93c6ccb
feat: useClickOutside 훅 구현, 캘린더 바깥 클릭하면 리셋시키기
hamo-o 9312749
refactor: useClickOutside 훅에서 불필요한 의존성 배열 요소 제거
hamo-o 3350833
refactor: 사용하지 않는 prop 제거
hamo-o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
frontend/src/components/Calendar/Table/CalendarDetailCell.tsx
This file contains hidden or 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,36 @@ | ||
| import { isDateInRange } from '@/utils/date'; | ||
|
|
||
| import { useTimeTableContext } from '../context/TimeTableContext'; | ||
| import { cellDetailStyle } from './index.css'; | ||
|
|
||
| export const CalendarDetailCell = ({ date }: { date: Date }) => { | ||
| const { | ||
| selectedStartTime, | ||
| selectedEndTime, | ||
| doneStartTime, | ||
| doneEndTime, | ||
| handleMouseDown, | ||
| handleMouseEnter, | ||
| handleMouseUp, | ||
| handleClick, | ||
| } = useTimeTableContext(); | ||
| const selected = isDateInRange(date, selectedStartTime, selectedEndTime); | ||
| const done = isDateInRange(date, doneStartTime, doneEndTime); | ||
|
|
||
| const stateStyle = (() => { | ||
| if (done) return 'done'; | ||
| if (selected) return 'selected'; | ||
| return 'default'; | ||
| })(); | ||
|
|
||
| return ( | ||
| <div | ||
| className={cellDetailStyle({ state: stateStyle })} | ||
| key={date.getTime()} | ||
| onClick={()=>handleClick(date)} | ||
| onMouseDown={()=>handleMouseDown(date)} | ||
| onMouseEnter={()=>handleMouseEnter(date)} | ||
| onMouseUp={handleMouseUp} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
| import { createContext } from 'react'; | ||
|
|
||
| import { useSafeContext } from '@/hooks/useSafeContext'; | ||
| import type { TimeInfo } from '@/hooks/useSelectTime'; | ||
|
|
||
| export const TimeTableContext = createContext<TimeInfo | null>(null); | ||
|
|
||
| export const useTimeTableContext = (): TimeInfo => useSafeContext(TimeTableContext); |
14 changes: 14 additions & 0 deletions
14
frontend/src/components/Calendar/context/TimeTableProvider.tsx
This file contains hidden or 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,14 @@ | ||
| import type { PropsWithChildren } from 'react'; | ||
|
|
||
| import { useSelectTime } from '@/hooks/useSelectTime'; | ||
|
|
||
| import { TimeTableContext } from './TimeTableContext'; | ||
|
|
||
| export const TimeTableProvider = ({ children }: PropsWithChildren) => { | ||
| const times = useSelectTime(); | ||
| return ( | ||
| <TimeTableContext.Provider value={times}> | ||
| {children} | ||
| </TimeTableContext.Provider> | ||
| ); | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.