Skip to content

Commit 0121c0f

Browse files
mperrotticolebemis
andauthored
Pagination design updates (#2702)
* updates pagination styles to match latest token usage patterns, and updates ARIA markup * adds changeset * Create .changeset/long-bags-double.md --------- Co-authored-by: Cole Bemis <colebemis@github.com>
1 parent d44d86f commit 0121c0f

File tree

5 files changed

+37
-18
lines changed

5 files changed

+37
-18
lines changed

.changeset/long-bags-double.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Pagination design updates:
6+
- Updates spacing inside of the buttons to match the "medium" control metrics: https://primer.style/primitives/spacing#medium
7+
- Updates hover style to align with ActionList items and other elements that may appear on any background color
8+
- Updates ARIA markup to improve assistive technology experience

.changeset/sour-melons-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Updates the visual design of the Pagination component to align with the latest design token usage patterns. Also improves ARIA markup to hide the "..." from assistive technologies.

src/Pagination/Pagination.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {buildComponentData, buildPaginationModel} from './model'
88

99
const Page = styled.a`
1010
display: inline-block;
11-
min-width: 32px;
12-
padding: 5px 10px;
11+
min-width: 32px; /* primer.control.medium.size */
12+
height: 32px; /* primer.control.medium.size */
13+
padding: 0.5rem calc((2rem - 1.25rem) / 2); /* primer.control.medium.paddingInline.condensed primer.control.medium.paddingBlock */
1314
font-style: normal;
14-
line-height: 20px;
15+
line-height: 1;
1516
color: ${get('colors.fg.default')};
1617
text-align: center;
1718
white-space: nowrap;
@@ -26,14 +27,14 @@ const Page = styled.a`
2627
margin-right: 0;
2728
}
2829
29-
border: ${get('borderWidths.1')} solid transparent;
30+
background-color: transparent;
3031
border-radius: ${get('radii.2')};
31-
transition: border-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);
32+
transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);
3233
3334
&:hover,
3435
&:focus {
3536
text-decoration: none;
36-
border-color: ${get('colors.border.default')};
37+
background-color: ${get('colors.actionListItem.default.hoverBg')};
3738
outline: 0;
3839
transition-duration: 0.1s;
3940
}
@@ -57,10 +58,12 @@ const Page = styled.a`
5758
}
5859
5960
&[aria-disabled],
60-
&[aria-disabled]:hover {
61+
&[aria-disabled]:hover,
62+
&[role='presentation'],
63+
&[role='presentation']:hover {
6164
color: ${get('colors.primer.fg.disabled')}; // check
6265
cursor: default;
63-
border-color: transparent;
66+
background-color: transparent;
6467
}
6568
6669
@supports (clip-path: polygon(50% 0, 100% 50%, 50% 100%)) {

src/Pagination/model.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export function buildComponentData(
179179
case 'BREAK': {
180180
key = `page-${page.num}-break`
181181
content = '…'
182-
Object.assign(props, {as: 'span', 'aria-disabled': true})
182+
Object.assign(props, {as: 'span', role: 'presentation'})
183183
}
184184
}
185185

src/__tests__/Pagination/__snapshots__/Pagination.test.tsx.snap

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ exports[`Pagination renders consistently 1`] = `
88
.c2 {
99
display: inline-block;
1010
min-width: 32px;
11-
padding: 5px 10px;
11+
height: 32px;
12+
padding: 0.5rem calc((2rem - 1.25rem) / 2);
1213
font-style: normal;
13-
line-height: 20px;
14+
line-height: 1;
1415
color: #24292f;
1516
text-align: center;
1617
white-space: nowrap;
@@ -23,10 +24,10 @@ exports[`Pagination renders consistently 1`] = `
2324
-webkit-text-decoration: none;
2425
text-decoration: none;
2526
margin-right: 4px;
26-
border: 1px solid transparent;
27+
background-color: transparent;
2728
border-radius: 6px;
28-
-webkit-transition: border-color 0.2s cubic-bezier(0.3,0,0.5,1);
29-
transition: border-color 0.2s cubic-bezier(0.3,0,0.5,1);
29+
-webkit-transition: background-color 0.2s cubic-bezier(0.3,0,0.5,1);
30+
transition: background-color 0.2s cubic-bezier(0.3,0,0.5,1);
3031
}
3132
3233
.c2:last-child {
@@ -37,7 +38,7 @@ exports[`Pagination renders consistently 1`] = `
3738
.c2:focus {
3839
-webkit-text-decoration: none;
3940
text-decoration: none;
40-
border-color: #d0d7de;
41+
background-color: rgba(208,215,222,0.32);
4142
outline: 0;
4243
-webkit-transition-duration: 0.1s;
4344
transition-duration: 0.1s;
@@ -76,10 +77,12 @@ exports[`Pagination renders consistently 1`] = `
7677
}
7778
7879
.c2[aria-disabled],
79-
.c2[aria-disabled]:hover {
80+
.c2[aria-disabled]:hover,
81+
.c2[role='presentation'],
82+
.c2[role='presentation']:hover {
8083
color: #8c959f;
8184
cursor: default;
82-
border-color: transparent;
85+
background-color: transparent;
8386
}
8487
8588
.c0 {
@@ -173,8 +176,8 @@ exports[`Pagination renders consistently 1`] = `
173176
6
174177
</a>
175178
<span
176-
aria-disabled={true}
177179
className="c2"
180+
role="presentation"
178181
>
179182
180183
</span>

0 commit comments

Comments
 (0)