Skip to content

Commit 7de218f

Browse files
refactor(LinkWithArrow): apply reviewer suggestions for cleaner code structure
1 parent 56f491a commit 7de218f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

apps/site/components/LinkWithArrow.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ArrowUpRightIcon } from '@heroicons/react/24/solid';
2+
import classNames from 'classnames';
23
import type {
34
AnchorHTMLAttributes,
45
ButtonHTMLAttributes,
@@ -12,10 +13,12 @@ type LinkWithArrowProps =
1213
| ({ href: string } & AnchorHTMLAttributes<HTMLAnchorElement>)
1314
| (Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> & { href?: never });
1415

15-
const LinkWithArrow: FC<PropsWithChildren<LinkWithArrowProps>> = props => {
16-
const { children, className, ...rest } = props;
17-
18-
if ('href' in props && props.href) {
16+
const LinkWithArrow: FC<PropsWithChildren<LinkWithArrowProps>> = ({
17+
children,
18+
className,
19+
...rest
20+
}) => {
21+
if (rest.href) {
1922
return (
2023
<Link
2124
{...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)}
@@ -33,7 +36,10 @@ const LinkWithArrow: FC<PropsWithChildren<LinkWithArrowProps>> = props => {
3336
<button
3437
type="button"
3538
{...(rest as ButtonHTMLAttributes<HTMLButtonElement>)}
36-
className={`${className || ''} text-green-600 hover:text-green-900 dark:text-green-400 dark:hover:text-green-200`}
39+
className={classNames(
40+
className,
41+
'text-green-600 hover:text-green-900 dark:text-green-400 dark:hover:text-green-200'
42+
)}
3743
>
3844
<span>
3945
{children}

0 commit comments

Comments
 (0)