diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Pagination.stories.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Pagination.stories.tsx new file mode 100644 index 0000000000..62615e8be0 --- /dev/null +++ b/apps/admin-x-settings/src/admin-x-ds/global/Pagination.stories.tsx @@ -0,0 +1,33 @@ +import type {Meta, StoryObj} from '@storybook/react'; + +import Pagination from './Pagination'; + +const meta = { + title: 'Global / Pagination story', + component: Pagination, + tags: ['autodocs'] +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + itemsPerPage: 5, + itemsTotal: 15 + } +}; + +export const LessThanMaximum: Story = { + args: { + itemsPerPage: 9, + itemsTotal: 5 + } +}; + +export const MoreThanMaximum: Story = { + args: { + itemsPerPage: 5, + itemsTotal: 15 + } +}; diff --git a/apps/admin-x-settings/src/admin-x-ds/global/Pagination.tsx b/apps/admin-x-settings/src/admin-x-ds/global/Pagination.tsx new file mode 100644 index 0000000000..dc0109b873 --- /dev/null +++ b/apps/admin-x-settings/src/admin-x-ds/global/Pagination.tsx @@ -0,0 +1,29 @@ +import Icon from './Icon'; +import React from 'react'; + +interface PaginationProps { + itemsPerPage: number; + itemsTotal: number; +} + +const Pagination: React.FC = ({itemsPerPage, itemsTotal}) => { + /* If there is less than X items total, where X is the number of items per page that we want to show */ + if (itemsPerPage < itemsTotal) { + return ( +
Showing 1-{itemsPerPage} of {itemsTotal} + + +
+ ); + + /* If there is more than X items total, where X is the number of items per page that we want to show */ + } else { + return ( +
Showing {itemsTotal} in total +
+ ); + } +}; + +export default Pagination; \ No newline at end of file