Skip to content

Commit

Permalink
chore(pagination): rename to initialSelectedPage prop
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinaSpasevska committed Aug 23, 2023
1 parent 34c4d93 commit a6fa5e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const meta: Meta<
step: 1,
},
},
initialPage: {
initialSelectedPage: {
control: {
type: 'number',
min: 1,
Expand All @@ -61,10 +61,10 @@ export const Controlled: Story = {
label: 'Label',
totalPages: 10,
visiblePageLimit: 3,
initialPage: 2,
initialSelectedPage: 2,
},
render: ({ totalPages, label, visiblePageLimit, initialPage }) => {
const [page, setPage] = React.useState(initialPage ?? 1);
render: ({ totalPages, label, visiblePageLimit, initialSelectedPage }) => {
const [page, setPage] = React.useState(initialSelectedPage ?? 1);

return (
<Stack direction="column" gap="$4">
Expand All @@ -74,7 +74,7 @@ export const Controlled: Story = {
currentPage={page}
label={label}
visiblePageLimit={visiblePageLimit}
initialPage={initialPage}
initialSelectedPage={initialSelectedPage}
onPageChange={setPage}
/>
</Stack>
Expand All @@ -87,15 +87,15 @@ export const Uncontrolled: Story = {
label: 'Label',
totalPages: 10,
visiblePageLimit: 3,
initialPage: 2,
initialSelectedPage: 2,
},
render: ({ totalPages, label, visiblePageLimit, initialPage }) => {
render: ({ totalPages, label, visiblePageLimit, initialSelectedPage }) => {
return (
<Pagination
totalPages={totalPages}
label={label}
visiblePageLimit={visiblePageLimit}
initialPage={initialPage}
initialSelectedPage={initialSelectedPage}
onPageChange={() => console.log('Updating Page')}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IPaginationProps {
currentPage?: number;
label: string;
visiblePageLimit?: number;
initialPage?: number;
initialSelectedPage?: number;
onPageChange: (page: number) => void;
}

Expand All @@ -21,10 +21,10 @@ export const Pagination: FC<IPaginationProps> = ({
currentPage,
label,
visiblePageLimit = 3,
initialPage,
initialSelectedPage,
onPageChange,
}) => {
const [_page, setPage] = useState(initialPage ?? 1);
const [_page, setPage] = useState(initialSelectedPage ?? 1);
const page = currentPage || _page;
const pages = paginate({
page,
Expand Down

0 comments on commit a6fa5e3

Please sign in to comment.