1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
import { IntlProvider } from 'react-intl';
import PaginationComponent from './pagination';
/**
* Pagination - Storybook Meta
*/
export default {
title: 'Molecules/Navigation/Pagination',
component: PaginationComponent,
argTypes: {
'aria-label': {
control: {
type: 'text',
},
description: 'An accessible name for the pagination.',
table: {
category: 'Accessibility',
},
type: {
name: 'string',
required: false,
},
},
baseUrl: {
control: {
type: 'text',
},
description: 'The url prefix.',
table: {
category: 'Options',
defaultValue: { summary: '/page/' },
},
type: {
name: 'string',
required: false,
},
},
className: {
control: {
type: 'text',
},
description: 'Set additional classnames to the pagination wrapper.',
table: {
category: 'Styles',
},
type: {
name: 'string',
required: false,
},
},
current: {
control: {
type: 'number',
},
description: 'The current page number.',
type: {
name: 'number',
required: true,
},
},
perPage: {
control: {
type: 'number',
},
description: 'The number of items per page.',
type: {
name: 'number',
required: true,
},
},
siblings: {
control: {
type: 'number',
},
description:
'The number of pages to show next to the current page for one side.',
table: {
category: 'Options',
defaultValue: { summary: 1 },
},
type: {
name: 'number',
required: false,
},
},
total: {
control: {
type: 'number',
},
description: 'The total number of items.',
type: {
name: 'number',
required: true,
},
},
},
decorators: [
(Story) => (
<IntlProvider locale="en">
<Story />
</IntlProvider>
),
],
} as ComponentMeta<typeof PaginationComponent>;
const Template: ComponentStory<typeof PaginationComponent> = (args) => (
<PaginationComponent {...args} />
);
/**
* Pagination Stories - Less than 5 pages
*/
export const WithoutDots = Template.bind({});
WithoutDots.args = {
current: 2,
perPage: 10,
siblings: 2,
total: 50,
};
/**
* Pagination Stories - Truncated to the right.
*/
export const RightDots = Template.bind({});
RightDots.args = {
current: 2,
perPage: 10,
siblings: 2,
total: 80,
};
/**
* Pagination Stories - Truncated to the left.
*/
export const LeftDots = Template.bind({});
LeftDots.args = {
current: 7,
perPage: 10,
siblings: 2,
total: 80,
};
/**
* Pagination Stories - Truncated both sides.
*/
export const LeftAndRightDots = Template.bind({});
LeftAndRightDots.args = {
current: 6,
perPage: 10,
siblings: 2,
total: 150,
};
/**
* Pagination Stories - Without previous link
*/
export const WithoutPreviousLink = Template.bind({});
WithoutPreviousLink.args = {
current: 1,
perPage: 10,
siblings: 2,
total: 50,
};
/**
* Pagination Stories - Without next link
*/
export const WithoutNextLink = Template.bind({});
WithoutNextLink.args = {
current: 5,
perPage: 10,
siblings: 2,
total: 50,
};
|