Skip to content

Commit ab2c8a4

Browse files
author
Adam Plesnik
committed
Fix link error
1 parent 44a240a commit ab2c8a4

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

docs/src/components/CodeBlock.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { LucideIcon } from 'lucide-react'
22
import Prism from 'prismjs'
33
import { PropsWithChildren, useEffect } from 'react'
4+
import Link from './Link'
45

56
const CodeBlock = ({
67
children,
@@ -31,9 +32,9 @@ const CodeBlock = ({
3132
}
3233
>
3334
{Icon && <Icon size={14} strokeWidth={2} />}
34-
{/* <Link href={linkHref} target={'_blank'} borderWidth={'narrow'}>
35+
<Link href={linkHref} target={'_blank'} borderWidth={'narrow'}>
3536
{linkText ? linkText : linkHref}
36-
</Link> */}
37+
</Link>
3738
</div>
3839
)}
3940
</div>

docs/src/components/Link.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { PropsWithChildren } from 'react'
2+
import { LucideIcon } from 'lucide-react'
3+
4+
const Link = ({
5+
borderWidth = undefined,
6+
children,
7+
className,
8+
href,
9+
Icon = undefined,
10+
iconSize = 16,
11+
iconStrokeWidth = 1.65,
12+
inline = false,
13+
target,
14+
}: PropsWithChildren<LinkProps>) => {
15+
return (
16+
<a
17+
href={href}
18+
target={target}
19+
className={
20+
(inline ? 'inline ' : 'inline-flex items-center gap-1 ') +
21+
'relative bg-gradient-to-r from-fuchsia-400 to-violet-800 bg-[length:200%_100%] bg-clip-text text-transparent ' +
22+
'group whitespace-normal transition-[background-size] duration-700 hover:bg-[length:500%_1000%] dark:to-violet-700 ' +
23+
(className ? ` ${className}` : '')
24+
}
25+
>
26+
<span>{children}</span>
27+
{Icon ? (
28+
<Icon
29+
size={iconSize}
30+
absoluteStrokeWidth={true}
31+
strokeWidth={iconStrokeWidth}
32+
className={
33+
'stroke-violet-600 ease-bounce group-hover:max-w-full group-hover:animate-bounce-bottom'
34+
}
35+
/>
36+
) : (
37+
''
38+
)}
39+
<span
40+
className={
41+
(borderWidth === 'narrow'
42+
? 'h-px'
43+
: borderWidth === 'none'
44+
? 'hidden'
45+
: borderWidth === 'huge'
46+
? 'h-1'
47+
: 'h-[2px]') +
48+
' absolute -bottom-px left-0 w-full max-w-0 bg-gradient-to-r from-fuchsia-400 to-violet-800 transition-[max-width] duration-500 ease-line group-hover:max-w-full'
49+
}
50+
></span>
51+
</a>
52+
)
53+
}
54+
55+
export interface LinkProps {
56+
children: PropsWithChildren
57+
href: string
58+
target: string
59+
borderWidth?: undefined | 'narrow' | 'none' | 'huge'
60+
className?: string
61+
Icon?: LucideIcon | undefined
62+
iconSize?: number | 16
63+
iconStrokeWidth?: number | 2
64+
inline?: boolean
65+
}
66+
67+
export default Link

0 commit comments

Comments
 (0)