Align pagination to architecture goals#181
Open
lifeiscontent wants to merge 3 commits into
Open
Conversation
|
📚 Storybook preview: https://pr-181-propel-storybook.vamsi-906.workers.dev |
- Move all className composition into cva variants; drop cx from component files and from the exported slotBase helper (now an internal constant). - Add ellipsisVariants cva so PaginationEllipsis no longer calls cx directly. - Make PaginationEllipsis accept children (NodeSlot pattern) instead of baking MoreHorizontal inline, keeping it a single rendered element. - Add required magnitude prop to every ui part (PaginationArrowButton, PaginationPageButton, PaginationEllipsis, PaginationPerPageTrigger) with an md value covering the current 24px Figma size; no defaultVariants. - Switch [&_svg] descendant selectors to [&>svg] direct-child selectors to match the single-element/children-passed-in pattern. - Export PaginationMagnitude and ellipsisVariants from the ui entry; drop the now-internal slotBase from the public export. - Thread magnitude="md" through the Pagination composition and both story files.
…ts tier Each ui/pagination part now renders exactly one element: add the Pagination (nav), PaginationList, PaginationItem, PaginationPerPage, PaginationPerPageIndicator, PaginationPerPageLabel, PaginationRange, PaginationRangeCurrent and PaginationSpinner parts, and turn the ellipsis into an icon slot. The components tier composes these parts and no longer carries any className/cva/cx. Drop the single-value magnitude axis (the 24px Figma slot is the only size, so it's baked in).
…ames Rename every cva export in ui/pagination/variants.ts (and all consumer files) so each name is exactly <camelCasePartName>Variants per rule 3a: pageButtonVariants → paginationPageButtonVariants arrowButtonVariants → paginationArrowButtonVariants ellipsisVariants → paginationEllipsisVariants spinnerVariants → paginationSpinnerVariants perPageVariants → paginationPerPageVariants perPageTriggerVariants → paginationPerPageTriggerVariants perPageIndicatorVariants → paginationPerPageIndicatorVariants perPageLabelVariants → paginationPerPageLabelVariants rangeVariants → paginationRangeVariants rangeCurrentVariants → paginationRangeCurrentVariants
8ab65ef to
88ed523
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #141
What the spec says
From the designer's comment on #141:
Always the same (baked in): horizontal layout, prev/next button positions, active page highlight, gap between items, ellipsis for collapsed ranges, focus ring, keyboard navigation, disabled prev/next at bounds.
Depends (adjustable): total pages, current page, visible page range, size variant, whether first/last page buttons are shown, whether a page count summary is shown.
Changes
variants.tscximport entirely; theslotBaseshared base is now an internal string constant (not exported).pageButtonVariants,arrowButtonVariants,ellipsisVariants,perPageTriggerVariants) now carries amagnitudevariant with an initialmdvalue for the current 24 px Figma size — nodefaultVariants, so the prop is required at each call site.ellipsisVariantsas a proper cva so the ellipsis component never callscxdirectly.[&_svg]descendant selectors to[&>svg]direct-child selectors, matching the single-element / children-passed-in pattern.pagination-ellipsis.tsx<MoreHorizontal>icon. The part now acceptschildrenand sizes whatever svg is passed via[&>svg]:size-3.5— the same NodeSlot pattern used by the arrow button. This keeps the part to one rendered element.cximport.pagination-arrow-button.tsx,pagination-page-button.tsx,pagination-per-page-trigger.tsxmagnitude: PaginationMagnitude. Callers must be explicit about size; no silent default.index.tsx(ui/pagination)slotBaseexport withellipsisVariantsandPaginationMagnitude.components/pagination/pagination.tsxmagnitude="md".PaginationEllipsisnow receives<MoreHorizontal aria-hidden />as children.Stories
magnitude="md"and supply the ellipsis icon as children.Notes
magnitudevariant has one value today (md). Additional sizes (e.g.sm) can be added tovariants.tsand surfaced through the composition layer without breaking the existing API.