File tree Expand file tree Collapse file tree 3 files changed +36
-22
lines changed Expand file tree Collapse file tree 3 files changed +36
-22
lines changed Original file line number Diff line number Diff line change 1
1
'use client' ;
2
2
3
- import { ArrowUpRightIcon } from '@heroicons/react/24/solid' ;
4
3
import { useTranslations } from 'next-intl' ;
5
4
import type { FC } from 'react' ;
6
5
import { use } from 'react' ;
7
6
7
+ import LinkWithArrow from '#site/components/LinkWithArrow' ;
8
8
import { ReleaseModalContext } from '#site/providers/releaseModalProvider' ;
9
9
import type { NodeRelease } from '#site/types' ;
10
10
@@ -18,15 +18,13 @@ const DetailsButton: FC<DetailsButtonProps> = ({ versionData }) => {
18
18
const { openModal } = use ( ReleaseModalContext ) ;
19
19
20
20
return (
21
- < button
22
- type = "button"
23
- className = "cursor-pointer text-green-600 hover:text-green-900 dark:text-green-400 dark:hover:text-green-200"
21
+ < LinkWithArrow
24
22
onClick = { ( ) => openModal ( versionData ) }
25
23
aria-label = { t ( 'details' ) }
24
+ className = "cursor-pointer"
26
25
>
27
26
{ t ( 'details' ) }
28
- < ArrowUpRightIcon className = "ml-1 inline w-3 fill-neutral-600 dark:fill-white" />
29
- </ button >
27
+ </ LinkWithArrow >
30
28
) ;
31
29
} ;
32
30
Original file line number Diff line number Diff line change 3
3
import type { FC , PropsWithChildren } from 'react' ;
4
4
import { useContext } from 'react' ;
5
5
6
- import Link from '#site/components/Link' ;
7
6
import LinkWithArrow from '#site/components/LinkWithArrow' ;
8
7
import { BASE_CHANGELOG_URL } from '#site/next.constants.mjs' ;
9
8
import { ReleaseContext } from '#site/providers/releaseProvider' ;
@@ -12,8 +11,8 @@ const ChangelogLink: FC<PropsWithChildren> = ({ children }) => {
12
11
const { release } = useContext ( ReleaseContext ) ;
13
12
14
13
return (
15
- < LinkWithArrow asChild >
16
- < Link href = { ` ${ BASE_CHANGELOG_URL } ${ release . version } ` } > { children } </ Link >
14
+ < LinkWithArrow href = { ` ${ BASE_CHANGELOG_URL } ${ release . version } ` } >
15
+ { children }
17
16
</ LinkWithArrow >
18
17
) ;
19
18
} ;
Original file line number Diff line number Diff line change 1
1
import { ArrowUpRightIcon } from '@heroicons/react/24/solid' ;
2
- import type { SlotProps } from '@radix-ui/react-slot' ;
3
- import { Slot } from '@radix-ui/react-slot' ;
4
- import type { ComponentProps , FC , PropsWithChildren } from 'react' ;
2
+ import type {
3
+ AnchorHTMLAttributes ,
4
+ ButtonHTMLAttributes ,
5
+ FC ,
6
+ PropsWithChildren ,
7
+ } from 'react' ;
5
8
6
9
import Link from '#site/components/Link' ;
7
10
8
11
type LinkWithArrowProps =
9
- | ( { asChild ?: false } & ComponentProps < typeof Link > )
10
- | ( { asChild : true } & SlotProps ) ;
12
+ | ( { href : string } & AnchorHTMLAttributes < HTMLAnchorElement > )
13
+ | ( Omit < ButtonHTMLAttributes < HTMLButtonElement > , 'type' > & { href ?: never } ) ;
11
14
12
- const LinkWithArrow : FC < PropsWithChildren < LinkWithArrowProps > > = ( {
13
- children,
14
- asChild = false ,
15
- ...props
16
- } ) => {
17
- const Comp = asChild ? Slot : Link ;
15
+ const LinkWithArrow : FC < PropsWithChildren < LinkWithArrowProps > > = props => {
16
+ const { children, className, ...rest } = props ;
17
+
18
+ if ( 'href' in props && props . href ) {
19
+ return (
20
+ < Link
21
+ { ...( rest as AnchorHTMLAttributes < HTMLAnchorElement > ) }
22
+ className = { className }
23
+ >
24
+ < span >
25
+ { children }
26
+ < ArrowUpRightIcon className = "ml-1 inline w-3 fill-neutral-600 dark:fill-white" />
27
+ </ span >
28
+ </ Link >
29
+ ) ;
30
+ }
18
31
19
32
return (
20
- < Comp { ...props } >
33
+ < button
34
+ type = "button"
35
+ { ...( rest as ButtonHTMLAttributes < HTMLButtonElement > ) }
36
+ className = { `${ className || '' } text-green-600 hover:text-green-900 dark:text-green-400 dark:hover:text-green-200` }
37
+ >
21
38
< span >
22
39
{ children }
23
40
< ArrowUpRightIcon className = "ml-1 inline w-3 fill-neutral-600 dark:fill-white" />
24
41
</ span >
25
- </ Comp >
42
+ </ button >
26
43
) ;
27
44
} ;
28
45
You can’t perform that action at this time.
0 commit comments