-
Notifications
You must be signed in to change notification settings - Fork 0
[FE] 대시보드 지표 카드 드래그앤드롭 편집 기능 구현 #276
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
33 commits
Select commit
Hold shift + click to select a range
5b56183
feat: EditCardContext에 대시보드 카드 드래그앤드랍 상태 관리 추가
lwjmcn f709a51
chore: import 경로 단축
lwjmcn 8f126d8
feat: EditCardContext에 픽셀 좌표 계산을 위한 gridRef 추가
lwjmcn bf00cc2
refactor: 카드 상태 2차원 그리드 대신 카드 배열 기준으로 리팩터링
lwjmcn fa99942
feat: 그리드 셀 크기 계산을 위한 useGridCellSize 추가
lwjmcn 3e281f5
feat: MiniViewActiveCard의 props 수정 (posX, posY -> colNo, rowNo)
lwjmcn ae9de0d
feat: 카드편집 뷰 카드 클릭 시 추가 이벤트 동작 및 클릭 이벤트 전파 방지
lwjmcn 6b3a8d2
fix: parameter row,col 순서 변경 버그
lwjmcn d2103e0
feat: 드래그 앤 드롭 카드 기능 추가 및 카드 밀어내기 재귀 알고리즘 구현
lwjmcn fc3937f
feat: 카드 편집 및 미니 뷰에 드래그 앤 드롭 핸들러 연결 및 ghost 컴포넌트 추가
lwjmcn 966d071
fix: 이미지 드래그 막기
lwjmcn e862450
fix: 이미 추가된 카드 드래그 시도 시 텍스트가 선택되는 문제
lwjmcn c17a05f
feat: dragOver 이벤트 핸들러에 스로틀링 추가
lwjmcn 8077dfb
chore: 메트릭 이름 오타 수정
lwjmcn ca7e601
style: 메트릭 이름 줄바꿈 스타일링
lwjmcn bb21461
style: 드래그앤드랍 고스트 스타일링
lwjmcn 30423b5
style: 삭제하기 오버레이 디자인 개선
lwjmcn bab413c
chore: import 경로 단축
lwjmcn 8428a82
refactor: 드래그앤드랍 카드 위치 스타일링 left/top에서 translate로 개선
lwjmcn bbeba5d
refactor: 그리드 위치 계산 시 변수명을 rowPx/colPx에서 topInPixel/leftInPixel으로 개선
lwjmcn e2b4702
refactor: AABB 알고리즘 가독성 있게 변경
lwjmcn afd7181
refactor: 그리드 셀 거리 계산 방식을 유클리드에서 맨하탄으로 개선
lwjmcn 5fa4f29
refactor: isSameGrid 함수 변수명 가독성 개선
lwjmcn 68629c0
refactor: useRef로 throttle 인스턴스 재생성 방지 및 throttle cancel로 메모리 누수 방지
lwjmcn d02f297
refactor: throttle 함수에서 this 사용 제거
lwjmcn 82d197b
refactor: useThrottle 훅을 추가하여 스로틀링 로직을 재사용 가능하게 함
lwjmcn ae14348
fix: 사파리 relatedTarget 이슈 해결
lwjmcn 3a95eda
style: 카드 편집 뷰에 overflow 속성을 추가하여 레이아웃 개선
lwjmcn 9ff5bd5
Merge branch 'develop' into feature/#54-fe-dashboard-edit-draggable
lwjmcn 4393bd4
chore: 콘솔 로그 삭제
lwjmcn 069402f
Merge branch 'develop' into feature/#54-fe-dashboard-edit-draggable
lwjmcn ff5d63e
fix: develop merge conflict
lwjmcn 986292c
fix: useEffect dependency array 린트 에러 (develop)
lwjmcn 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
Some comments aren't visible on the classic Files Changed page.
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
46 changes: 32 additions & 14 deletions
46
frontend/src/components/dashboard/dashboard-edit/EditCardProvider.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
52 changes: 37 additions & 15 deletions
52
frontend/src/components/dashboard/dashboard-edit/MiniView.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
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
35 changes: 35 additions & 0 deletions
35
frontend/src/components/dashboard/dashboard-edit/MiniViewGhost.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,35 @@ | ||
| import { DASHBOARD_METRIC_CARDS } from '@/constants/dashboard'; | ||
| import { useEditCardContext, useGridCellSize } from '@/hooks/dashboard'; | ||
| import { cn } from '@/utils/shared'; | ||
|
|
||
| export const MiniViewGhost = () => { | ||
| const { dragState, ghost, isOverList } = useEditCardContext(); | ||
| const { getGridPosition, getGridCardSize } = useGridCellSize(); | ||
|
|
||
| if (!dragState || !ghost || isOverList) { | ||
| return null; | ||
| } | ||
|
|
||
| const draggingCardDef = | ||
| DASHBOARD_METRIC_CARDS[dragState.draggingCard.cardCode]; | ||
|
|
||
| const { topInPixel, leftInPixel } = getGridPosition(ghost.rowNo, ghost.colNo); | ||
| const { widthInPixel, heightInPixel } = getGridCardSize( | ||
| draggingCardDef.sizeX, | ||
| draggingCardDef.sizeY, | ||
| ); | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| 'rounded-400 pointer-events-none absolute top-0 left-0 shadow-[2px_2px_8px_0_rgba(0,0,0,0.15)_inset] transition-all duration-200', | ||
| ghost.isValid ? 'bg-grey-200' : 'bg-others-negative opacity-40', | ||
| )} | ||
| style={{ | ||
| translate: `${leftInPixel}px ${topInPixel}px`, | ||
| width: widthInPixel, | ||
| height: heightInPixel, | ||
| }} | ||
| /> | ||
| ); | ||
| }; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3: 이젠 진짜 state Provider, action Provider로 나누어야 할 것 같네요..
useReducer를 사용해서 state provider랑 dispatch provider를 분리하면 좋을 것 같습니다
아니면 context를 쪼갠다거나...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금 dispatch 함수만을 구독하고 있는 컴포넌트가 없습니다 (다 state만 구독하거나 state & dispatch를 동시에 구독하고 있어요)
그래서 state provider와 dispatch provider를 분리해서 얻을 이점이 딱히 없을 것 같습니다.
지금 보기에도 context에 상태가 너무 많아서 분리해야 할 필요성은 있을 것 같습니다. 일단 카드 그리드 상태와 드래그앤드랍 상태를 나눌 수 있을 것 같아요. 다만 카드목록 전체 리렌더링 상황에서도 selector를 고려했어서, 대시보드 카드 관련 내용을 다 외부 스토어로 전환하는 게 어떤가 싶습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리팩터링 이슈 파두었습니다. #316