Skip to content

Commit 57bb36f

Browse files
refactor: CrossLink Prev to Previous and cleanup of Pagination keys (#8378)
* use full word previous within crosslink * remove half used pagination keys in favor of common pagination * remove crossLink translation keys completely necessitates renaming the key in pagination due to dynamic reference in CrossLink
1 parent d9451ef commit 57bb36f

File tree

6 files changed

+23
-31
lines changed

6 files changed

+23
-31
lines changed

apps/site/components/Common/CrossLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const CrossLink: FC<Omit<CrossLinkProps, 'as' | 'label'>> = props => {
1010
const t = useTranslations();
1111
return (
1212
<BaseCrossLink
13-
label={t(`components.common.crossLink.${props.type}`)}
13+
label={t(`components.common.pagination.${props.type}`)}
1414
as={Link}
1515
{...props}
1616
/>

apps/site/components/Common/Pagination.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ const Pagination: FC<
1515
as={Link}
1616
labels={{
1717
aria: t('components.common.pagination.defaultLabel'),
18-
prevAria: t('components.common.pagination.prevAriaLabel'),
19-
prev: t('components.pagination.previous'),
20-
nextAria: t('components.common.pagination.nextAriaLabel'),
21-
next: t('components.pagination.next'),
18+
previousAriaLabel: t('components.common.pagination.previousAriaLabel'),
19+
previous: t('components.common.pagination.previous'),
20+
nextAriaLabel: t('components.common.pagination.nextAriaLabel'),
21+
next: t('components.common.pagination.next'),
2222
}}
2323
getPageLabel={pageNumber =>
2424
t('components.common.pagination.pageLabel', { pageNumber })

packages/i18n/src/locales/en.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@
237237
"npmVersion": "npm version",
238238
"v8Version": "V8 version"
239239
},
240-
"pagination": {
241-
"next": "Next",
242-
"previous": "Previous"
243-
},
244240
"common": {
245241
"alertBox": {
246242
"info": "Info",
@@ -250,17 +246,13 @@
250246
"breadcrumbs": {
251247
"navigateToHome": "Navigate to Home"
252248
},
253-
"crossLink": {
254-
"previous": "Prev",
255-
"next": "Next"
256-
},
257249
"codebox": {
258250
"copy": "Copy to clipboard",
259251
"copied": "Copied to clipboard!"
260252
},
261253
"pagination": {
262-
"prev": "Previous",
263-
"prevAriaLabel": "Previous page",
254+
"previous": "Previous",
255+
"previousAriaLabel": "Previous page",
264256
"next": "Next",
265257
"nextAriaLabel": "Next page",
266258
"defaultLabel": "Pagination",

packages/ui-components/src/Common/BasePagination/__tests__/index.test.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import BasePagination from '#ui/Common/BasePagination';
1111
const getPageLabel = number => number.toString();
1212
const labels = {
1313
aria: 'Aria',
14-
prevAria: 'Previous Aria',
15-
prev: 'Previous',
16-
nextAria: 'Next Aria',
14+
previousAriaLabel: 'Previous Aria',
15+
previous: 'Previous',
16+
nextAriaLabel: 'Next Aria',
1717
next: 'Next',
1818
};
1919

@@ -51,14 +51,14 @@ describe('Pagination', () => {
5151
assert.ok(
5252
isVisible(
5353
screen.getByRole('button', {
54-
name: labels.prevAria,
54+
name: labels.previousAriaLabel,
5555
})
5656
)
5757
);
5858
assert.ok(
5959
isVisible(
6060
screen.getByRole('button', {
61-
name: labels.nextAria,
61+
name: labels.nextAriaLabel,
6262
})
6363
)
6464
);
@@ -157,7 +157,7 @@ describe('Pagination', () => {
157157
assert.ok(
158158
screen
159159
.getByRole('button', {
160-
name: labels.prevAria,
160+
name: labels.previousAriaLabel,
161161
})
162162
.getAttribute('aria-disabled')
163163
);
@@ -172,7 +172,7 @@ describe('Pagination', () => {
172172
assert.ok(
173173
screen
174174
.getByRole('button', {
175-
name: labels.nextAria,
175+
name: labels.nextAriaLabel,
176176
})
177177
.getAttribute('aria-disabled')
178178
);

packages/ui-components/src/Common/BasePagination/index.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export const Default: Story = {
1313
getPageLabel: value => `Page: ${value}`,
1414
labels: {
1515
aria: 'Aria',
16-
prevAria: 'Previous Aria',
17-
prev: 'Previous',
18-
nextAria: 'Next Aria',
16+
previousAriaLabel: 'Previous Aria',
17+
previous: 'Previous',
18+
nextAriaLabel: 'Next Aria',
1919
next: 'Next',
2020
},
2121
},

packages/ui-components/src/Common/BasePagination/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export type PaginationProps = {
2121
getPageLabel: (pageNumber: number) => string;
2222
labels: {
2323
aria: string;
24-
prevAria: string;
25-
prev: string;
26-
nextAria: string;
24+
previousAriaLabel: string;
25+
previous: string;
26+
nextAriaLabel: string;
2727
next: string;
2828
};
2929
};
@@ -48,21 +48,21 @@ const BasePagination: FC<PaginationProps> = ({
4848
<nav aria-label={labels.aria} className={styles.pagination}>
4949
<Button
5050
as={as}
51-
aria-label={labels.prevAria}
51+
aria-label={labels.previousAriaLabel}
5252
disabled={currentPage === 1}
5353
kind="secondary"
5454
className={styles.previousButton}
5555
href={pages[currentPage - 2]?.url}
5656
>
5757
<ArrowLeftIcon className={styles.arrowIcon} />
58-
<span>{labels.prev}</span>
58+
<span>{labels.previous}</span>
5959
</Button>
6060

6161
<ol className={styles.list}>{parsedPages}</ol>
6262

6363
<Button
6464
as={as}
65-
aria-label={labels.nextAria}
65+
aria-label={labels.nextAriaLabel}
6666
disabled={currentPage === pages.length}
6767
kind="secondary"
6868
className={styles.nextButton}

0 commit comments

Comments
 (0)