Skip to content

Commit 06216df

Browse files
emyarodtw15egankodiakhq[bot]
authored
feat(Pagination): add support for sizes (#9215)
* feat(Pagination): add support for sizes * chore: update snapshots * style(Pagination): square button for all sizes Co-authored-by: TJ Egan <tw15egan@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 0edda76 commit 06216df

File tree

4 files changed

+65
-6
lines changed

4 files changed

+65
-6
lines changed

packages/components/src/components/pagination/_pagination.scss

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ $css--helpers: true;
1212
@import '../../globals/scss/typography';
1313
@import '../../globals/scss/layout';
1414
@import '../../globals/scss/css--helpers';
15+
@import '../../globals/scss/vendor/@carbon/layout/scss/generated/size';
1516
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
1617
@import '../select/select';
1718
@import '../text-input/text-input';
@@ -31,7 +32,7 @@ $css--helpers: true;
3132

3233
display: flex;
3334
width: calc(100% - 1px);
34-
min-height: rem(48px);
35+
min-height: $size-md;
3536
align-items: center;
3637
justify-content: space-between;
3738
border-top: 1px solid $ui-03;
@@ -63,6 +64,14 @@ $css--helpers: true;
6364
}
6465
}
6566

67+
.#{$prefix}--pagination--sm {
68+
min-height: $size-sm;
69+
}
70+
71+
.#{$prefix}--pagination--lg {
72+
min-height: $size-lg;
73+
}
74+
6675
.#{$prefix}--pagination .#{$prefix}--select {
6776
height: 100%;
6877
align-items: center;
@@ -78,8 +87,17 @@ $css--helpers: true;
7887

7988
width: auto;
8089
min-width: auto;
81-
height: rem(48px);
90+
height: 100%;
8291
padding: 0 2.25rem 0 $spacing-05;
92+
line-height: $size-md;
93+
}
94+
95+
.#{$prefix}--pagination--sm .#{$prefix}--select-input {
96+
line-height: $size-sm;
97+
}
98+
99+
.#{$prefix}--pagination--lg .#{$prefix}--select-input {
100+
line-height: $size-lg;
83101
}
84102

85103
.#{$prefix}--pagination .#{$prefix}--select-input:hover {
@@ -106,7 +124,7 @@ $css--helpers: true;
106124
.#{$prefix}--pagination__left,
107125
.#{$prefix}--pagination__right {
108126
display: flex;
109-
height: rem(48px);
127+
height: 100%;
110128
align-items: center;
111129
}
112130

@@ -153,8 +171,9 @@ $css--helpers: true;
153171
@include reset;
154172

155173
display: flex;
156-
width: $carbon--spacing-09;
157-
height: 100%;
174+
width: $size-md;
175+
height: $size-md;
176+
min-height: $size-sm;
158177
align-items: center;
159178
justify-content: center;
160179
border: none;
@@ -167,6 +186,20 @@ $css--helpers: true;
167186
background-color $duration--fast-02 motion(standard, productive);
168187
}
169188

189+
.#{$prefix}--pagination--sm .#{$prefix}--pagination__button,
190+
.#{$prefix}--pagination--sm
191+
.#{$prefix}--btn--ghost.#{$prefix}--pagination__button {
192+
width: $size-sm;
193+
height: $size-sm;
194+
}
195+
196+
.#{$prefix}--pagination--lg .#{$prefix}--pagination__button,
197+
.#{$prefix}--pagination--lg
198+
.#{$prefix}--btn--ghost.#{$prefix}--pagination__button {
199+
width: $size-lg;
200+
height: $size-lg;
201+
}
202+
170203
.#{$prefix}--pagination__button:focus,
171204
.#{$prefix}--btn--ghost:focus.#{$prefix}--pagination__button {
172205
@include focus-outline('outline');

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,6 +4299,16 @@ Map {
42994299
"pagesUnknown": Object {
43004300
"type": "bool",
43014301
},
4302+
"size": Object {
4303+
"args": Array [
4304+
Array [
4305+
"sm",
4306+
"md",
4307+
"lg",
4308+
],
4309+
],
4310+
"type": "oneOf",
4311+
},
43024312
"totalItems": Object {
43034313
"type": "number",
43044314
},

packages/react/src/components/Pagination/Pagination-story.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ import {
1313
array,
1414
boolean,
1515
number,
16+
select,
1617
text,
1718
} from '@storybook/addon-knobs';
1819
import Pagination from '../Pagination';
1920
import mdx from './Pagination.mdx';
2021

22+
const sizes = {
23+
'Small (sm)': 'sm',
24+
'Medium (md) - default': undefined,
25+
'Large (lg)': 'lg',
26+
};
27+
2128
const props = () => ({
2229
disabled: boolean('Disable page inputs (disabled)', false),
30+
size: select('Size (size)', sizes, undefined) || undefined,
2331
page: number('The current page (page)', 1),
2432
totalItems: number('Total number of items (totalItems)', 103),
2533
pagesUnknown: boolean('Total number of items unknown (pagesUnknown)', false),

packages/react/src/components/Pagination/Pagination.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ export default class Pagination extends Component {
148148
*/
149149
pagesUnknown: PropTypes.bool,
150150

151+
/**
152+
* Specify the size of the Pagination. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
153+
*/
154+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
155+
151156
/**
152157
* The total number of items.
153158
*/
@@ -277,10 +282,13 @@ export default class Pagination extends Component {
277282
totalItems,
278283
onChange, // eslint-disable-line no-unused-vars
279284
page: pageNumber, // eslint-disable-line no-unused-vars
285+
size,
280286
...other
281287
} = this.props;
282288

283-
const classNames = classnames(`${prefix}--pagination`, className);
289+
const classNames = classnames(`${prefix}--pagination`, className, {
290+
[`${prefix}--pagination--${size}`]: size,
291+
});
284292
const inputId = id || this.uniqueId;
285293
const { page: statePage, pageSize: statePageSize } = this.state;
286294
const totalPages = Math.max(Math.ceil(totalItems / statePageSize), 1);

0 commit comments

Comments
 (0)