Skip to content

fix(ui): make LinkWithArrow behave like accessible button for modal open #8051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/site/components/Common/LinkWithArrow/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@reference "../../../styles/index.css";

.icon {
@apply ml-1
inline
w-3
fill-neutral-600
dark:fill-white;
}

.button {
@apply text-green-600
hover:text-green-900
dark:text-green-400
dark:hover:text-green-200;
}
48 changes: 48 additions & 0 deletions apps/site/components/Common/LinkWithArrow/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ArrowUpRightIcon } from '@heroicons/react/24/solid';
import classNames from 'classnames';
import type {
ButtonHTMLAttributes,
ComponentProps,
FC,
PropsWithChildren,
} from 'react';

import Link from '#site/components/Link';

import styles from './index.module.css';

type LinkWithArrowProps =
| ComponentProps<typeof Link>
| ButtonHTMLAttributes<HTMLButtonElement>;

const LinkWithArrow: FC<PropsWithChildren<LinkWithArrowProps>> = ({
children,
className,
...props
}) => {
const content = (
<span>
{children}
<ArrowUpRightIcon className={styles.icon} />
</span>
);

if ('href' in props) {
return (
<Link {...props} className={className}>
{content}
</Link>
);
}

return (
<button
className={classNames(className, styles.button)}
{...(props as ButtonHTMLAttributes<HTMLButtonElement>)}
>
{content}
</button>
);
};

export default LinkWithArrow;
2 changes: 1 addition & 1 deletion apps/site/components/Downloads/DownloadLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

import LinkWithArrow from '#site/components/LinkWithArrow';
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
import { useClientContext } from '#site/hooks';
import type { DownloadKind, NodeRelease } from '#site/types';
import { getNodeDownloadUrl } from '#site/util/url';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslations } from 'next-intl';
import type { FC } from 'react';
import { use } from 'react';

import LinkWithArrow from '#site/components/LinkWithArrow';
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
import { ReleaseModalContext } from '#site/providers/releaseModalProvider';
import type { NodeRelease } from '#site/types';

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

return (
<LinkWithArrow
className="cursor-pointer"
onClick={() => openModal(versionData)}
aria-label={t('details')}
>
{t('details')}
</LinkWithArrow>
Expand Down
7 changes: 3 additions & 4 deletions apps/site/components/Downloads/Release/ChangelogLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
import type { FC, PropsWithChildren } from 'react';
import { useContext } from 'react';

import Link from '#site/components/Link';
import LinkWithArrow from '#site/components/LinkWithArrow';
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
import { BASE_CHANGELOG_URL } from '#site/next.constants.mjs';
import { ReleaseContext } from '#site/providers/releaseProvider';

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

return (
<LinkWithArrow asChild>
<Link href={`${BASE_CHANGELOG_URL}${release.version}`}>{children}</Link>
<LinkWithArrow href={`${BASE_CHANGELOG_URL}${release.version}`}>
{children}
</LinkWithArrow>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { FC } from 'react';
import { useContext, useMemo } from 'react';

import CodeBox from '#site/components/Common/CodeBox';
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
import Link from '#site/components/Link';
import LinkWithArrow from '#site/components/LinkWithArrow';
import { createSval } from '#site/next.jsx.compiler.mjs';
import {
ReleaseContext,
Expand Down
29 changes: 0 additions & 29 deletions apps/site/components/LinkWithArrow.tsx

This file was deleted.

1 change: 0 additions & 1 deletion apps/site/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const nextConfig = {
'@radix-ui/react-dropdown-menu',
'@radix-ui/react-label',
'@radix-ui/react-select',
'@radix-ui/react-slot',
'@radix-ui/react-tabs',
'@radix-ui/react-toast',
'@radix-ui/react-tooltip',
Expand Down
2 changes: 1 addition & 1 deletion apps/site/next.mdx.use.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup';

import Button from './components/Common/Button';
import LinkWithArrow from './components/Common/LinkWithArrow';
import DownloadReleasesTable from './components/Downloads/DownloadReleasesTable';
import Link from './components/Link';
import LinkWithArrow from './components/LinkWithArrow';
import UpcomingMeetings from './components/MDX/Calendar/UpcomingMeetings';
import WithBadgeGroup from './components/withBadgeGroup';
import WithBanner from './components/withBanner';
Expand Down
1 change: 0 additions & 1 deletion apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@opentelemetry/sdk-logs": "~0.203.0",
"@orama/react-components": "^0.8.1",
"@oramacloud/client": "^2.1.4",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-tabs": "^1.1.12",
"@radix-ui/react-tooltip": "^1.2.7",
"@tailwindcss/postcss": "~4.1.11",
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading