generated from nextauthjs/next-auth-example
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-nav.tsx
91 lines (87 loc) · 2.74 KB
/
main-nav.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"use client"
import Image from "next/image"
import { cn } from "@/lib/utils"
import CustomLink from "./custom-link"
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle,
} from "./ui/navigation-menu"
import React from "react"
import { Button } from "./ui/button"
export function MainNav() {
return (
<div className="flex items-center gap-4">
<CustomLink href="/">
<Button variant="ghost" className="p-0">
<Image
src="/logo.png"
alt="Home"
width="32"
height="32"
className="min-w-8"
/>
</Button>
</CustomLink>
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger className="px-2">
Server Side
</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid gap-3 p-6 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]">
<ListItem href="/server-example" title="RSC Example">
Protecting React Server Component.
</ListItem>
<ListItem href="/middleware-example" title="Middleware Example">
Using Middleware to protect pages & APIs.
</ListItem>
<ListItem href="/api-example" title="Route Handler Example">
Getting the session inside an API Route.
</ListItem>
</ul>
</NavigationMenuContent>
</NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink
href="/client-example"
className={navigationMenuTriggerStyle()}
>
Client Side
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
</div>
)
}
const ListItem = React.forwardRef<
React.ElementRef<"a">,
React.ComponentPropsWithoutRef<"a">
>(({ className, title, children, ...props }, ref) => {
return (
<li>
<NavigationMenuLink asChild>
<a
ref={ref}
className={cn(
"hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors",
className
)}
{...props}
>
<div className="text-sm font-medium leading-none">{title}</div>
<p className="text-muted-foreground line-clamp-2 text-sm leading-snug">
{children}
</p>
</a>
</NavigationMenuLink>
</li>
)
})
ListItem.displayName = "ListItem"