Skip to content

Commit

Permalink
allow theming visibleRange for pager
Browse files Browse the repository at this point in the history
  • Loading branch information
SerhiiTsybulskyi committed Jul 18, 2024
1 parent c8d72de commit 24949fd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/data/Pager/Pager.story.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { Pager } from './Pager';
import { pagerTheme } from './PagerTheme';

export default {
title: 'Components/Data/Pager',
Expand Down Expand Up @@ -47,3 +48,20 @@ export const ShowAll = () => {
/>
);
};

export const CustomTheme = () => {
const [page, setPage] = useState<number>(0);
const customTheme = pagerTheme;
customTheme.visibleRange = 'text-blue-400 font-bold';

return (
<Pager
theme={customTheme}
page={page}
size={10}
total={100}
onPageChange={setPage}
displayMode="all"
/>
);
};
6 changes: 4 additions & 2 deletions src/data/Pager/Pager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ export const Pager: FC<PagerProps> = ({
{pageCount > 1 && (
<Stack dense>
<Text>
{startItem.toLocaleString()}-{endItem.toLocaleString()} of{' '}
<Pluralize count={total} singular="item" />
<Text className={theme.visibleRange}>
{startItem.toLocaleString()}-{endItem.toLocaleString()}
</Text>{' '}
of <Pluralize count={total} singular="item" />
</Text>
</Stack>
)}
Expand Down
2 changes: 2 additions & 0 deletions src/data/Pager/PagerTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface PagerTheme {
};
ellipsis: string;
pagerDisplayItems: string;
visibleRange: string;
control: string;
firstPage: string;
prevPage: string;
Expand All @@ -28,6 +29,7 @@ const baseTheme: PagerTheme = {
},
ellipsis: 'cursor-pointer',
pagerDisplayItems: 'mr-1.5',
visibleRange: '',
control: '[&>svg]:w-5 [&>svg]:h-5',
firstPage: '',
prevPage: '',
Expand Down

0 comments on commit 24949fd

Please sign in to comment.