Skip to content

Commit 2d2a01b

Browse files
fix(ui): make LinkWithArrow behave like accessible button for modal open (#8051)
* fix(ui): make `LinkWithArrow` accessible Co-Authored-By: Mohit5Upadhyay <[email protected]> * fixup! --------- Co-authored-by: avivkeller <[email protected]>
1 parent 61b55a2 commit 2d2a01b

File tree

13 files changed

+63
-45
lines changed

13 files changed

+63
-45
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@reference "../../../styles/index.css";
2+
3+
.icon {
4+
@apply ml-1
5+
inline
6+
w-3
7+
fill-neutral-600
8+
dark:fill-white;
9+
}
10+
11+
.button {
12+
@apply text-green-600
13+
hover:text-green-900
14+
dark:text-green-400
15+
dark:hover:text-green-200;
16+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ArrowUpRightIcon } from '@heroicons/react/24/solid';
2+
import classNames from 'classnames';
3+
import type {
4+
ButtonHTMLAttributes,
5+
ComponentProps,
6+
FC,
7+
PropsWithChildren,
8+
} from 'react';
9+
10+
import Link from '#site/components/Link';
11+
12+
import styles from './index.module.css';
13+
14+
type LinkWithArrowProps =
15+
| ComponentProps<typeof Link>
16+
| ButtonHTMLAttributes<HTMLButtonElement>;
17+
18+
const LinkWithArrow: FC<PropsWithChildren<LinkWithArrowProps>> = ({
19+
children,
20+
className,
21+
...props
22+
}) =>
23+
'href' in props ? (
24+
<Link {...props} className={className}>
25+
{children}
26+
<ArrowUpRightIcon className={styles.icon} />
27+
</Link>
28+
) : (
29+
<button
30+
className={classNames(className, styles.button)}
31+
{...(props as ButtonHTMLAttributes<HTMLButtonElement>)}
32+
>
33+
{children}
34+
<ArrowUpRightIcon className={styles.icon} />
35+
</button>
36+
);
37+
38+
export default LinkWithArrow;

apps/site/components/Downloads/DownloadLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type { FC, PropsWithChildren } from 'react';
44

5-
import LinkWithArrow from '#site/components/LinkWithArrow';
5+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
66
import { useClientContext } from '#site/hooks';
77
import type { DownloadKind, NodeRelease } from '#site/types';
88
import { getNodeDownloadUrl } from '#site/util/url';

apps/site/components/Downloads/Release/ChangelogLink.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
import type { FC, PropsWithChildren } from 'react';
44
import { useContext } from 'react';
55

6-
import Link from '#site/components/Link';
7-
import LinkWithArrow from '#site/components/LinkWithArrow';
6+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
87
import { BASE_CHANGELOG_URL } from '#site/next.constants.mjs';
98
import { ReleaseContext } from '#site/providers/releaseProvider';
109

1110
const ChangelogLink: FC<PropsWithChildren> = ({ children }) => {
1211
const { release } = useContext(ReleaseContext);
1312

1413
return (
15-
<LinkWithArrow asChild>
16-
<Link href={`${BASE_CHANGELOG_URL}${release.version}`}>{children}</Link>
14+
<LinkWithArrow href={`${BASE_CHANGELOG_URL}${release.version}`}>
15+
{children}
1716
</LinkWithArrow>
1817
);
1918
};

apps/site/components/Downloads/Release/ReleaseCodeBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import type { FC } from 'react';
88
import { useContext, useMemo } from 'react';
99

1010
import CodeBox from '#site/components/Common/CodeBox';
11+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
1112
import Link from '#site/components/Link';
12-
import LinkWithArrow from '#site/components/LinkWithArrow';
1313
import { createSval } from '#site/next.jsx.compiler.mjs';
1414
import {
1515
ReleaseContext,

apps/site/components/EOL/EOLReleaseTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { Fragment, useState } from 'react';
55
import type { FC } from 'react';
66

77
import FormattedTime from '#site/components/Common/FormattedTime';
8+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
89
import EOLModal from '#site/components/EOL/EOLModal';
910
import VulnerabilityChips from '#site/components/EOL/VulnerabilityChips';
10-
import LinkWithArrow from '#site/components/LinkWithArrow';
1111
import provideReleaseData from '#site/next-data/providers/releaseData';
1212
import provideVulnerabilities from '#site/next-data/providers/vulnerabilities';
1313
import { EOL_VERSION_IDENTIFIER } from '#site/next.constants.mjs';

apps/site/components/EOL/VulnerabilitiesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import classNames from 'classnames';
22
import { useTranslations } from 'next-intl';
33
import type { FC } from 'react';
44

5+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
56
import VulnerabilityChip from '#site/components/EOL/VulnerabilityChips/VulnerabilityChip';
6-
import LinkWithArrow from '#site/components/LinkWithArrow';
77
import type { Vulnerability } from '#site/types/vulnerabilities';
88

99
const VulnerabilitiesTable: FC<{

apps/site/components/LinkWithArrow.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

apps/site/components/Releases/PreviousReleasesTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { FC } from 'react';
66
import { useState } from 'react';
77

88
import FormattedTime from '#site/components/Common/FormattedTime';
9-
import LinkWithArrow from '#site/components/LinkWithArrow';
9+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
1010
import provideReleaseData from '#site/next-data/providers/releaseData';
1111

1212
import ReleaseModal from './ReleaseModal';

apps/site/next.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const nextConfig = {
8686
'@radix-ui/react-dropdown-menu',
8787
'@radix-ui/react-label',
8888
'@radix-ui/react-select',
89-
'@radix-ui/react-slot',
9089
'@radix-ui/react-tabs',
9190
'@radix-ui/react-toast',
9291
'@radix-ui/react-tooltip',

0 commit comments

Comments
 (0)