Skip to content

Commit f35e5df

Browse files
Mohit5Upadhyayavivkeller
authored andcommitted
fix(ui): make LinkWithArrow behave like accessible button for modal open
1 parent b33a5a4 commit f35e5df

File tree

11 files changed

+72
-43
lines changed

11 files changed

+72
-43
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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
const content = (
24+
<span>
25+
{children}
26+
<ArrowUpRightIcon className={styles.icon} />
27+
</span>
28+
);
29+
30+
if ('href' in props) {
31+
return (
32+
<Link {...props} className={className}>
33+
{content}
34+
</Link>
35+
);
36+
}
37+
38+
return (
39+
<button
40+
className={classNames(className, styles.button)}
41+
{...(props as ButtonHTMLAttributes<HTMLButtonElement>)}
42+
>
43+
{content}
44+
</button>
45+
);
46+
};
47+
48+
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/DownloadReleasesTable/DetailsButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useTranslations } from 'next-intl';
44
import type { FC } from 'react';
55
import { use } from 'react';
66

7-
import LinkWithArrow from '#site/components/LinkWithArrow';
7+
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
88
import { ReleaseModalContext } from '#site/providers/releaseModalProvider';
99
import type { NodeRelease } from '#site/types';
1010

@@ -19,8 +19,8 @@ const DetailsButton: FC<DetailsButtonProps> = ({ versionData }) => {
1919

2020
return (
2121
<LinkWithArrow
22-
className="cursor-pointer"
2322
onClick={() => openModal(versionData)}
23+
aria-label={t('details')}
2424
>
2525
{t('details')}
2626
</LinkWithArrow>

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/LinkWithArrow.tsx

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

apps/site/next.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ const nextConfig = {
8484
'@radix-ui/react-dropdown-menu',
8585
'@radix-ui/react-label',
8686
'@radix-ui/react-select',
87-
'@radix-ui/react-slot',
8887
'@radix-ui/react-tabs',
8988
'@radix-ui/react-toast',
9089
'@radix-ui/react-tooltip',

apps/site/next.mdx.use.client.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Blockquote from '@node-core/ui-components/Common/Blockquote';
44
import MDXCodeTabs from '@node-core/ui-components/MDX/CodeTabs';
55

66
import Button from './components/Common/Button';
7+
import LinkWithArrow from './components/Common/LinkWithArrow';
78
import DownloadButton from './components/Downloads/DownloadButton';
89
import DownloadLink from './components/Downloads/DownloadLink';
910
import BlogPostLink from './components/Downloads/Release/BlogPostLink';
@@ -17,7 +18,6 @@ import ReleasePrebuiltDownloadButtons from './components/Downloads/Release/Prebu
1718
import ReleaseCodeBox from './components/Downloads/Release/ReleaseCodeBox';
1819
import ReleaseVersionDropdown from './components/Downloads/Release/VersionDropdown';
1920
import Link from './components/Link';
20-
import LinkWithArrow from './components/LinkWithArrow';
2121
import MDXCodeBox from './components/MDX/CodeBox';
2222
import MDXImage from './components/MDX/Image';
2323
import { ReleaseProvider } from './providers/releaseProvider';

apps/site/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"@opentelemetry/sdk-logs": "~0.202.0",
4343
"@orama/react-components": "^0.8.1",
4444
"@oramacloud/client": "^2.1.4",
45-
"@radix-ui/react-slot": "^1.2.3",
4645
"@radix-ui/react-tabs": "^1.1.12",
4746
"@radix-ui/react-tooltip": "^1.2.7",
4847
"@tailwindcss/postcss": "~4.1.11",

0 commit comments

Comments
 (0)