|
1 |
| -import type { Meta, StoryObj } from "@storybook/react"; |
2 |
| -import { |
3 |
| - Pagination, |
4 |
| - PaginationContent, |
5 |
| - PaginationItem, |
6 |
| - PaginationPrevious, |
7 |
| - PaginationLink, |
8 |
| - PaginationEllipsis, |
9 |
| - PaginationNext, |
10 |
| -} from "@signozhq/pagination"; |
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | +import { Pagination } from '@signozhq/pagination'; |
11 | 3 |
|
12 |
| -const PaginationComponent = () => ( |
13 |
| - <Pagination> |
14 |
| - <PaginationContent> |
15 |
| - <PaginationItem> |
16 |
| - <PaginationPrevious href="#" onClick={(e) => e.preventDefault()} /> |
17 |
| - </PaginationItem> |
18 |
| - <PaginationItem> |
19 |
| - <PaginationLink href="#" onClick={(e) => e.preventDefault()}> |
20 |
| - 1 |
21 |
| - </PaginationLink> |
22 |
| - </PaginationItem> |
23 |
| - <PaginationItem> |
24 |
| - <PaginationLink href="#" onClick={(e) => e.preventDefault()} isActive> |
25 |
| - 2 |
26 |
| - </PaginationLink> |
27 |
| - </PaginationItem> |
28 |
| - <PaginationItem> |
29 |
| - <PaginationLink href="#" onClick={(e) => e.preventDefault()}> |
30 |
| - 3 |
31 |
| - </PaginationLink> |
32 |
| - </PaginationItem> |
33 |
| - <PaginationItem> |
34 |
| - <PaginationEllipsis /> |
35 |
| - </PaginationItem> |
36 |
| - <PaginationItem> |
37 |
| - <PaginationNext href="#" onClick={(e) => e.preventDefault()} /> |
38 |
| - </PaginationItem> |
39 |
| - </PaginationContent> |
40 |
| - </Pagination> |
41 |
| -); |
42 |
| - |
43 |
| -const meta: Meta<typeof PaginationComponent> = { |
44 |
| - title: "Components/Pagination", |
45 |
| - component: PaginationComponent, |
46 |
| - argTypes: {}, |
47 |
| - parameters: { |
48 |
| - backgrounds: { |
49 |
| - default: "dark", |
50 |
| - }, |
51 |
| - design: [ |
52 |
| - { |
53 |
| - name: "Figma", |
54 |
| - type: "figma", |
55 |
| - url: "https://www.figma.com/design/egMidgk6VJDXTumxcCYUl1/Periscope---Primitives?node-id=40-1657&node-type=frame&t=RGQXgBfSXKWsYAz9-0", |
56 |
| - }, |
57 |
| - ], |
58 |
| - }, |
| 4 | +const meta: Meta<typeof Pagination> = { |
| 5 | + title: 'Components/Pagination', |
| 6 | + component: Pagination, |
| 7 | + argTypes: { |
| 8 | + current: { |
| 9 | + control: 'number', |
| 10 | + description: 'Current selected page (optional)', |
| 11 | + }, |
| 12 | + total: { |
| 13 | + control: 'number', |
| 14 | + description: 'Total number of items', |
| 15 | + required: true, |
| 16 | + }, |
| 17 | + pageSize: { |
| 18 | + control: 'number', |
| 19 | + description: 'Number of items per page', |
| 20 | + defaultValue: 10, |
| 21 | + }, |
| 22 | + defaultCurrent: { |
| 23 | + control: 'number', |
| 24 | + description: 'Initial page number when uncontrolled', |
| 25 | + defaultValue: 1, |
| 26 | + }, |
| 27 | + align: { |
| 28 | + control: 'select', |
| 29 | + options: ['start', 'center', 'end'], |
| 30 | + description: 'Alignment of pagination component', |
| 31 | + defaultValue: 'start', |
| 32 | + }, |
| 33 | + onPageChange: { |
| 34 | + action: 'page changed', |
| 35 | + description: 'Callback when page changes', |
| 36 | + }, |
| 37 | + }, |
| 38 | + parameters: { |
| 39 | + backgrounds: { |
| 40 | + default: 'dark', |
| 41 | + }, |
| 42 | + design: [ |
| 43 | + { |
| 44 | + name: 'Figma', |
| 45 | + type: 'figma', |
| 46 | + url: 'https://www.figma.com/design/egMidgk6VJDXTumxcCYUl1/Periscope---Primitives?node-id=40-1657&node-type=frame&t=RGQXgBfSXKWsYAz9-0', |
| 47 | + }, |
| 48 | + ], |
| 49 | + }, |
59 | 50 | };
|
60 | 51 |
|
61 | 52 | export default meta;
|
62 | 53 |
|
63 |
| -type Story = StoryObj<typeof PaginationComponent>; |
| 54 | +type Story = StoryObj<typeof Pagination>; |
64 | 55 |
|
65 | 56 | export const Default: Story = {
|
66 |
| - render: () => <PaginationComponent />, |
67 |
| - args: {}, |
| 57 | + args: { |
| 58 | + total: 50, |
| 59 | + current: 1, |
| 60 | + }, |
| 61 | +}; |
| 62 | + |
| 63 | +export const CustomPageSize: Story = { |
| 64 | + args: { |
| 65 | + total: 100, |
| 66 | + pageSize: 5, |
| 67 | + current: 1, |
| 68 | + }, |
| 69 | +}; |
| 70 | + |
| 71 | +export const CenterAligned: Story = { |
| 72 | + args: { |
| 73 | + total: 50, |
| 74 | + align: 'center', |
| 75 | + current: 1, |
| 76 | + }, |
| 77 | +}; |
| 78 | + |
| 79 | +export const EndAligned: Story = { |
| 80 | + args: { |
| 81 | + total: 50, |
| 82 | + align: 'end', |
| 83 | + current: 1, |
| 84 | + }, |
| 85 | +}; |
| 86 | + |
| 87 | +export const UncontrolledWithDefaultCurrent: Story = { |
| 88 | + args: { |
| 89 | + total: 50, |
| 90 | + defaultCurrent: 3, |
| 91 | + }, |
| 92 | +}; |
| 93 | + |
| 94 | +export const WithPageChangeHandler: Story = { |
| 95 | + args: { |
| 96 | + total: 50, |
| 97 | + current: 1, |
| 98 | + onPageChange: (page: number) => console.log(`Page changed to ${page}`), |
| 99 | + }, |
| 100 | +}; |
| 101 | + |
| 102 | +export const ThreePages_FirstSelected: Story = { |
| 103 | + args: { |
| 104 | + total: 30, |
| 105 | + current: 1, |
| 106 | + }, |
| 107 | +}; |
| 108 | + |
| 109 | +export const ThreePages_SecondSelected: Story = { |
| 110 | + args: { |
| 111 | + total: 30, |
| 112 | + current: 2, |
| 113 | + }, |
| 114 | +}; |
| 115 | + |
| 116 | +export const TenPages_FirstSelected: Story = { |
| 117 | + args: { |
| 118 | + total: 100, |
| 119 | + current: 1, |
| 120 | + }, |
| 121 | +}; |
| 122 | + |
| 123 | +export const TenPages_LastSelected: Story = { |
| 124 | + args: { |
| 125 | + total: 100, |
| 126 | + current: 10, |
| 127 | + }, |
68 | 128 | };
|
0 commit comments