Skip to content

Commit 47cdaef

Browse files
Merge pull request #385 from eccenca/bugfix/paginationBreakpoints-CMEM-7458
Re-configure breakpoints for pagination container queries (CMEM-7458)
2 parents 0417f33 + 6037854 commit 47cdaef

3 files changed

Lines changed: 92 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- `<Pagination />`
12+
- improve breakpoints to display widgets for page size and page number inside smaller containers
13+
- male the breakpoints configurable via SCSS
14+
915
## [25.1.0] - 2026-04-13
1016

1117
### Added

src/components/Pagination/Stories/Pagination.stories.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export default {
1010

1111
const PaginationExample = (args) => <Pagination {...args} />;
1212

13+
const ContainerQueriesExample = (args) => (
14+
<>
15+
<Pagination {...args} style={{ maxWidth: "100%" }} />
16+
<Pagination {...args} style={{ maxWidth: "32rem" }} />
17+
<Pagination {...args} style={{ maxWidth: "26rem" }} />
18+
</>
19+
);
20+
1321
export const Default: StoryFn<typeof Pagination> = PaginationExample.bind({});
1422
Default.args = {
1523
pageSizes: [10, 20, 50, 100],
@@ -28,3 +36,27 @@ ExtendedPagesizeSelection.args = {
2836
{ text: "Large page with 100 items", value: "100" },
2937
],
3038
};
39+
40+
/**
41+
* This story demonstrates a minimal pagination and is a check that elements are always hidden.
42+
*/
43+
export const MinimalPagination: StoryFn<typeof Pagination> = PaginationExample.bind({});
44+
MinimalPagination.args = {
45+
...Default.args,
46+
hidePageSizeConfiguration: true,
47+
hidePageSelect: true,
48+
hideInfoText: true,
49+
hideNavigationArrows: false,
50+
hideBorders: false,
51+
};
52+
53+
/**
54+
* Demonstrates the breakpoints of the container queries.
55+
* If the container gets too small, some elements are removed automatically.
56+
* First, page selector disappears, then the page size selector.
57+
* Info text and navigation arrow are never hidden automatically.
58+
*/
59+
export const ContainerQueries: StoryFn<typeof Pagination> = ContainerQueriesExample.bind({});
60+
ContainerQueries.args = {
61+
...Default.args,
62+
};

src/components/Pagination/pagination.scss

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ $eccgui-size-typo-pagination: $eccgui-size-typo-caption !default;
77
$eccgui-size-pagination-height-medium: $pt-button-height !default;
88
$eccgui-size-pagination-height-small: $pt-button-height-small !default;
99
$eccgui-size-pagination-height-large: $pt-button-height-large !default;
10+
$eccgui-size-pagination-breakpoint-wide: 32rem !default;
11+
$eccgui-size-pagination-breakpoint-small: 26rem !default;
1012

1113
.#{$prefix}--pagination {
1214
min-block-size: $eccgui-size-pagination-height-medium;
@@ -38,7 +40,7 @@ span.#{$prefix}--pagination__text {
3840
padding-left: 0;
3941

4042
& > *:not(:last-child) {
41-
display: none;
43+
display: none !important;
4244
}
4345
}
4446
}
@@ -56,7 +58,7 @@ span.#{$prefix}--pagination__text {
5658

5759
.#{$eccgui}-pagination--hideinfotext {
5860
.#{$prefix}--pagination__left > .#{$prefix}--pagination__text:last-child {
59-
display: none;
61+
display: none !important;
6062
}
6163

6264
& .#{$prefix}--select__item-count .#{$prefix}--select-input {
@@ -66,13 +68,13 @@ span.#{$prefix}--pagination__text {
6668

6769
.#{$eccgui}-pagination--hidepageselect {
6870
.#{$prefix}--pagination__right > *:not(.#{$prefix}--pagination__control-buttons) {
69-
display: none;
71+
display: none !important;
7072
}
7173
}
7274

7375
.#{$eccgui}-pagination--hidenavigation {
7476
.#{$prefix}--pagination__right > .#{$prefix}--pagination__control-buttons {
75-
display: none;
77+
display: none !important;
7678
}
7779
}
7880

@@ -137,3 +139,51 @@ span.#{$prefix}--pagination__text {
137139
line-height: $eccgui-size-pagination-height-large;
138140
}
139141
}
142+
143+
// fix breakpoints for container queries
144+
// Carbon does not provide the option to configure that breakpoint
145+
@container pagination (min-width: #{$eccgui-size-pagination-breakpoint-small}) {
146+
.#{$prefix}--pagination.#{$eccgui}-pagination {
147+
.#{$prefix}--pagination__control-buttons {
148+
display: flex;
149+
}
150+
.#{$prefix}--pagination__left > * {
151+
display: inherit;
152+
}
153+
}
154+
}
155+
156+
@container pagination (min-width: #{$eccgui-size-pagination-breakpoint-wide}) {
157+
.#{$prefix}--pagination.#{$eccgui}-pagination {
158+
.#{$prefix}--pagination__right > * {
159+
display: inherit;
160+
}
161+
}
162+
}
163+
164+
@container pagination (max-width: #{$eccgui-size-pagination-breakpoint-small}) {
165+
.#{$prefix}--pagination.#{$eccgui}-pagination {
166+
.#{$prefix}--pagination__left > * {
167+
display: none;
168+
}
169+
.#{$prefix}--pagination__items-count {
170+
margin-left: 0;
171+
}
172+
}
173+
}
174+
175+
@container pagination (max-width: #{$eccgui-size-pagination-breakpoint-wide}) {
176+
.#{$prefix}--pagination.#{$eccgui}-pagination {
177+
.#{$prefix}--pagination__right > * {
178+
display: none;
179+
}
180+
181+
.#{$prefix}--pagination__items-count {
182+
display: initial;
183+
}
184+
185+
.#{$prefix}--pagination__control-buttons {
186+
display: flex;
187+
}
188+
}
189+
}

0 commit comments

Comments
 (0)