[Feature/#295] 타임라인 그리드 열 너비 뷰포트 균등 분배#298
Conversation
📝 WalkthroughWalkthrough타임라인 컨테이너의 너비를 관찰하는 훅을 추가하고, 컨테이너 너비와 열 개수에 따라 Changes타임라인 반응형 열 너비
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Timeline
participant useContainerWidth
participant ResizeObserver
participant TimelineAxis
participant TimelineGrid
participant TimelineBar
Timeline->>useContainerWidth: scrollRef 전달
useContainerWidth->>ResizeObserver: 컨테이너 관찰
ResizeObserver-->>useContainerWidth: 너비 변경 전달
useContainerWidth-->>Timeline: containerWidth 반환
Timeline->>Timeline: colWidth와 totalWidth 계산
Timeline->>TimelineAxis: colWidth 전달
Timeline->>TimelineGrid: colWidth 전달
TimelineGrid->>TimelineBar: colWidth 전달
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📚 Storybook 배포 완료
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/hooks/timeline/useContainerWidth.ts (1)
15-18: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win불필요한 리렌더 방지를 위해 width 변경 시에만 setState 호출
update()가el.clientWidth가 변경되지 않아도setWidth를 호출합니다. ResizeObserver는 크기 변화 시에만 트리거되지만, 초기 호출(update())과 연속 리사이즈에서 동일한 값이 설정될 수 있어 불필요한 리렌더가 발생합니다.♻️ 제안하는 수정
const update = () => { - setWidth(el.clientWidth); + setWidth((prev) => (prev === el.clientWidth ? prev : el.clientWidth)); };🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/hooks/timeline/useContainerWidth.ts` around lines 15 - 18, Update the update function in useContainerWidth so it calls setWidth only when el.clientWidth differs from the current width state. Preserve the initial measurement and ResizeObserver behavior while avoiding state updates for unchanged width values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/hooks/timeline/useContainerWidth.ts`:
- Around line 15-18: Update the update function in useContainerWidth so it calls
setWidth only when el.clientWidth differs from the current width state. Preserve
the initial measurement and ResizeObserver behavior while avoiding state updates
for unchanged width values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 409f628e-008d-493a-8b7b-39abf993e28e
📒 Files selected for processing (3)
src/constants/timeline/layout.tssrc/hooks/timeline/useContainerWidth.tssrc/pages/dashboard/timeline/Timeline.tsx
🚨 관련 이슈
Closed #295
✨ 변경사항
✏️ 작업 내용
컨테이너 너비 / 열 수로 동적 계산해서 일/주/월 모두 가로 공간을 채우도록 수정useContainerWidth로 리사이즈시 재계산💻 작업 화면
MONTH 단위
WEEK 단위
DAY 단위
😅 미완성 작업
N/A
📢 논의 사항 및 참고 사항
Summary by CodeRabbit