Skip to content

feat(Paging): extract paging into standalone reusable component#128

Merged
pglevy merged 2 commits into
pglevy:mainfrom
govind-gs:feat/paging-component
Jun 4, 2026
Merged

feat(Paging): extract paging into standalone reusable component#128
pglevy merged 2 commits into
pglevy:mainfrom
govind-gs:feat/paging-component

Conversation

@govind-gs

Copy link
Copy Markdown
Contributor

Closes #108

Summary

Extracts the inline paging UI from ReadOnlyGrid into a standalone Paging component for easier reuse across grids, lists, and card layouts.

Changes

  • New src/components/Paging/Paging.tsx — Standalone paging component with props for startIndex, endIndex, totalCount, currentPage, totalPages, pagingControls, onPageChange, and showWhen
  • New src/components/Paging/Paging.stories.tsx — Stories with autodocs, args-based controls, and interactive render (Standard, RowCount, TwoPages)
  • New src/components/Paging/index.ts — Barrel export
  • Modified src/components/ReadOnlyGrid/ReadOnlyGrid.tsx — Replaced ~40 lines of inline paging UI with <Paging /> usage; removed unused imports
  • Modified src/components/index.ts — Added export * from './Paging'

Props

Prop Type Default Description
startIndex number 1-based index of first visible item
endIndex number Index of last visible item on current page
totalCount number Total number of items
currentPage number Current page (1-based)
totalPages number Total number of pages
pagingControls 'STANDARD' | 'ROW_COUNT' 'STANDARD' Controls whether total count and first/last buttons show
onPageChange (page: number) => void Callback when page changes
showWhen boolean true Whether the component is displayed

Behavior

pagingControls Label format First/Last buttons
STANDARD "1 – 10 of many" Never
ROW_COUNT "1 – 10 of 50" When totalPages >= 3

Component returns null when totalPages <= 1.

Screenshots

Standard (pagingControls="STANDARD") paging-standard
Row Count (pagingControls="ROW_COUNT") paging-row-count
Two Pages (ROW_COUNT, no first/last buttons) paging-two-pages

Testing

  • TypeScript: ✅ Clean (tsc --noEmit)
  • Unit tests: ✅ 50 passed
  • Property tests: ✅ 15 passed
  • ESLint: ✅ 0 new warnings
  • Build: ✅ vite build success

- Create Paging component from ReadOnlyGrid inline paging UI
- Refactor ReadOnlyGrid to use the new Paging component
- Add stories with autodocs, args-based controls, and interactive render

Closes pglevy#108
Comment thread src/components/Paging/Paging.tsx
- Remove startIndex, endIndex, totalPages from public props
- Add pageSize prop; compute totalPages, startIndex, endIndex internally
- Update ReadOnlyGrid to pass simplified props
- Simplify stories to match new API

Addresses PR pglevy#128 review feedback
@pglevy pglevy merged commit 7fc302d into pglevy:main Jun 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make paging its own component

2 participants