Days per grid page option - #383
Conversation
WalkthroughAdds a persisted “Days per page” setting with mobile and desktop options, selector UI, and localStorage handling. ScheduleGrid now uses the selected day count, clamps invalid pages, reports display state, and supports compact headers. ScheduleHeader renders condensed date layouts in compact mode. Event results, painting, and editor views expose the setting in their responsive panels, while painting tracks last-page visitation through grid updates and the editor conditionally displays preview controls. 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src/features/event/grid/lib/use-grid.ts (1)
47-55: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winBoundary check fix is correct; consider stabilizing
paginate's identity.The generalized
< 0/> 0check correctly supports the multi-step jump used by the pagination clamp fix ingrid.tsx. Sincepaginateisn't memoized, it's a new reference every render, which causes the paginationuseEffectingrid.tsx(which listspaginateas a dependency) to re-run on every render rather than only whencurrentPage/totalPageschange.♻️ Optional: stabilize with `useCallback`
- const paginate = (newDirection: number) => { + const paginate = useCallback((newDirection: number) => { if ( (newDirection < 0 && currentPage > 0) || (newDirection > 0 && currentPage < view.totalPages - 1) ) { setCurrentPage([currentPage + newDirection, newDirection]); onPaginate(currentPage + newDirection, view.totalPages); } - }; + }, [currentPage, view.totalPages, onPaginate]);
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 8c2cc00e-7559-4d4f-bbfe-28d4a8aa701f
📒 Files selected for processing (9)
frontend/src/app/(event)/[event-code]/page-client.tsxfrontend/src/app/(event)/[event-code]/painting/page-client.tsxfrontend/src/features/event/components/selectors/grid-page-days.tsxfrontend/src/features/event/editor/editor.tsxfrontend/src/features/event/grid/grid.tsxfrontend/src/features/event/grid/lib/constants.tsfrontend/src/features/event/grid/lib/use-grid.tsfrontend/src/features/event/grid/lib/use-page-days.tsfrontend/src/features/event/grid/schedule-header.tsx
This PR adds a dropdown that lets users select how many days to show on the results grid.
Overview
This option is displayed next to the time zone option on the results and painting pages. On the event editor, it's shown below the grid.
The value selected is saved to local storage, and the value for the mobile layout is separate from the desktop layout. They also have different options, between 4 and 7 on mobile and 7 and 14 on desktop.
This option depends on a new hook,
useGridPageDays, which handles the logic of checking local storage and validating the value before setting the option.New
ScheduleGridPropspageDaysdetermines how many days are shown on each grid page.useCompactHeaderdetermines if the compact header layout should be used.setGridDisplayedallows the parent component to know if a grid is displayed, for use in the editor.Grid Header Changes
To fit additional days on the grid, a "compact" grid header was created that shrinks the weekdays into single characters and the dates into just numbers. These features dynamically activate based on the screen size, so a large enough screen will show the original "uncompacted" header with the additional days.
Fixed Out of Bounds Page Bug
There was an issue where, if you were at the last grid page and increased the number of days per page, the current grid page would be out of bounds. This has been fixed.
Somewhat related to this, the logic for checking if the user has viewed all grid pages when painting has been simplified.
Fixed Mobile Event Editor Grid Header
The mobile event editor didn't have a sticky header on the grid preview, which has now been added.