-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathindex.tsx
More file actions
38 lines (33 loc) · 905 Bytes
/
index.tsx
File metadata and controls
38 lines (33 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
}) =>
'href' in props ? (
<Link {...props} className={className}>
{children}
<ArrowUpRightIcon className={styles.icon} />
</Link>
) : (
<button
className={classNames(className, styles.button)}
{...(props as ButtonHTMLAttributes<HTMLButtonElement>)}
>
{children}
<ArrowUpRightIcon className={styles.icon} />
</button>
);
export default LinkWithArrow;