Skip to content

Commit 34d7449

Browse files
authored
[Pagination] Update UI (#11637)
### WHY are these changes introduced? Addresses Shopify/web#119227 Reliant on #11622 merging before this can merge. Updates the table variant of the Pagination component to match the new required UI. [Figma for reference](https://www.figma.com/file/shC6hyM1MC60abgslhpUib/Index-bulk-actions?type=design&node-id=11-207471&mode=design&t=alwlAtMB43g2Kk1h-0). ### WHAT is this pull request doing? - Centre-align buttons - Add prominence to buttons with background color that's different to surrounding box. ### How to 🎩 Spin URL: https://admin.web.pagination-refresh.marc-thomas.eu.spin.dev/store/shop1/products?selectedView=all ### 🎩 checklist - [x] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [x] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [x] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [x] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [x] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent df1eaf0 commit 34d7449

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Updated Pagination table variant to have more prominent and centrally-aligned actions

polaris-react/src/components/Pagination/Pagination.module.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828

2929
button {
3030
--button-min-height: var(--p-height-700);
31-
background-color: var(--p-color-bg-surface-secondary);
31+
background-color: var(--p-color-bg-surface-secondary-selected);
3232
min-height: var(--button-min-height);
3333
min-width: var(--button-min-height);
3434
height: var(--button-min-height);
3535
width: var(--button-min-height);
36+
display: flex;
3637
padding: unset;
3738

3839
/* stylelint-disable -- override pagination buttons in tables */
@@ -62,3 +63,10 @@
6263
}
6364
}
6465
}
66+
67+
.TablePaginationActions {
68+
display: flex;
69+
gap: var(--p-space-025);
70+
align-items: center;
71+
justify-content: center;
72+
}

polaris-react/src/components/Pagination/Pagination.stories.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,26 @@ export function WithTableType() {
8080
</div>
8181
);
8282
}
83+
84+
export function WithTableTypeAndNoLabel() {
85+
return (
86+
<div
87+
style={{
88+
maxWidth: 'calc(700px + (2 * var(--p-space-400)))',
89+
margin: '0 auto',
90+
}}
91+
>
92+
<Pagination
93+
onPrevious={() => {
94+
console.log('Previous');
95+
}}
96+
onNext={() => {
97+
console.log('Next');
98+
}}
99+
type="table"
100+
hasNext
101+
hasPrevious
102+
/>
103+
</div>
104+
);
105+
}

polaris-react/src/components/Pagination/Pagination.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ export function Pagination({
163163

164164
if (type === 'table') {
165165
const labelMarkup = label ? (
166-
<Text as="span" variant="bodySm" fontWeight="medium">
167-
{label}
168-
</Text>
166+
<Box padding="300" paddingBlockStart="0" paddingBlockEnd="0">
167+
<Text as="span" variant="bodySm" fontWeight="medium">
168+
{label}
169+
</Text>
170+
</Box>
169171
) : null;
170172

171173
return (
@@ -183,15 +185,15 @@ export function Pagination({
183185
paddingInlineStart="300"
184186
paddingInlineEnd="200"
185187
>
186-
<InlineStack
187-
align={labelMarkup ? 'space-between' : 'end'}
188-
blockAlign="center"
189-
>
190-
{labelMarkup}
191-
<ButtonGroup variant="segmented">
192-
{constructedPrevious}
193-
{constructedNext}
194-
</ButtonGroup>
188+
<InlineStack align="center" blockAlign="center">
189+
<div
190+
className={styles.TablePaginationActions}
191+
data-buttongroup-variant="segmented"
192+
>
193+
<div>{constructedPrevious}</div>
194+
{labelMarkup}
195+
<div>{constructedNext}</div>
196+
</div>
195197
</InlineStack>
196198
</Box>
197199
</nav>

polaris-react/src/components/Pagination/tests/Pagination.test.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,11 @@ describe('<Pagination />', () => {
272272
});
273273
});
274274

275-
it('uses Button and ButtonGroup as subcomponents', () => {
275+
it('uses Button as subcomponent', () => {
276276
const pagination = mountWithApp(
277277
<Pagination nextURL="/next" previousURL="/prev" type={type} />,
278278
);
279279

280-
expect(pagination).toContainReactComponent(ButtonGroup, {
281-
variant: 'segmented',
282-
});
283280
expect(pagination).toContainReactComponent(Button, {url: '/prev'});
284281
expect(pagination).toContainReactComponent(Button, {url: '/next'});
285282
});
@@ -316,19 +313,19 @@ describe('<Pagination />', () => {
316313
});
317314

318315
describe('type: table', () => {
319-
it('places the content at the end of the container', () => {
316+
it('places the content centreally within the container', () => {
320317
const pagination = mountWithApp(
321318
<Pagination hasNext nextURL="/next" previousURL="/prev" type="table" />,
322319
);
323320

324321
expect(pagination).toContainReactComponent(InlineStack, {
325-
align: 'end',
322+
align: 'center',
326323
blockAlign: 'center',
327324
});
328325
});
329326

330327
describe('label', () => {
331-
it('spaces the content apart within the container', () => {
328+
it('spaces the content centrally within the container', () => {
332329
const pagination = mountWithApp(
333330
<Pagination
334331
hasNext
@@ -340,7 +337,7 @@ describe('<Pagination />', () => {
340337
);
341338

342339
expect(pagination).toContainReactComponent(InlineStack, {
343-
align: 'space-between',
340+
align: 'center',
344341
blockAlign: 'center',
345342
});
346343
});

0 commit comments

Comments
 (0)