generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathlink-tree.tsx
45 lines (41 loc) · 1.02 KB
/
link-tree.tsx
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
39
40
41
42
43
44
45
import { Button } from '@/src/components/ui/button'
import Link from 'next/link'
import { ReactNode } from 'react'
export type LinkTreeItemProps = {
href: string
icon: ReactNode
label: ReactNode
}
export function LinkTreeItem({ href, icon, label }: LinkTreeItemProps) {
const isLocalRoute = href.startsWith('/')
return (
<li>
<Button
asChild
variant="outline"
className="flex w-full items-center justify-center gap-3 py-6 text-lg transition-all hover:scale-[1.01]"
>
<Link
href={href}
target={isLocalRoute ? undefined : '_blank'}
rel={isLocalRoute ? undefined : 'noopener noreferrer'}
>
{icon}
<span>{label}</span>
</Link>
</Button>
</li>
)
}
type LinkTreeProps = {
items: LinkTreeItemProps[]
}
export function LinkTree({ items }: LinkTreeProps) {
return (
<ul className="space-y-4">
{items.map((item, index) => (
<LinkTreeItem key={index} {...item} />
))}
</ul>
)
}