Spaces:
Sleeping
Sleeping
Download src/components/navbar.tsx from veltrixcode/Iot: direct link, hf CLI and curl.
- Browser
- Download file 10 kB
-
https://huggingface.co/spaces/veltrixcode/Iot/resolve/main/src/components/navbar.tsx
- Command line
-
hf download hf://spaces/veltrixcode/Iot/src/components/navbar.tsx
-
curl -L -o navbar.tsx https://huggingface.co/spaces/veltrixcode/Iot/resolve/main/src/components/navbar.tsx
10 kB
| import Link from "next/link" | |
| import { auth } from "@/auth" | |
| import { Button } from "@/components/ui/button" | |
| import { | |
| DropdownMenu, | |
| DropdownMenuContent, | |
| DropdownMenuItem, | |
| DropdownMenuLabel, | |
| DropdownMenuSeparator, | |
| DropdownMenuTrigger, | |
| } from "@/components/ui/dropdown-menu" | |
| import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" | |
| import { checkAndResetDailyCredits } from "@/lib/credits" | |
| import { ThemeToggle } from "@/components/theme-toggle" | |
| import { Menu } from "lucide-react" | |
| import { | |
| Sheet, | |
| SheetContent, | |
| SheetHeader, | |
| SheetTitle, | |
| SheetTrigger, | |
| } from "@/components/ui/sheet" | |
| export async function Navbar() { | |
| const session = await auth() | |
| let credits = 0 | |
| if (session?.user?.id) { | |
| const userCredits = await checkAndResetDailyCredits(session.user.id) | |
| credits = userCredits ?? 0 | |
| } | |
| return ( | |
| <header className="sticky top-4 z-50 w-full px-4 md:px-6"> | |
| <div className="mx-auto max-w-7xl glass-panel rounded-full px-6 h-16 flex items-center justify-between transition-all duration-300 hover:shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)]"> | |
| <Link href="/" className="flex items-center space-x-2 group"> | |
| <div className="relative h-10 w-40"> | |
| <img src="/dark.png" alt="Imyra" className="h-full w-full object-contain object-left hidden dark:block" /> | |
| <img src="/light.png" alt="Imyra" className="h-full w-full object-contain object-left block dark:hidden" /> | |
| </div> | |
| </Link> | |
| <nav className="hidden md:flex flex-1 items-center justify-center space-x-8 text-sm font-bold tracking-tight"> | |
| <Link href="/" className="transition-colors hover:text-primary relative group"> | |
| Home | |
| <span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-primary transition-all group-hover:w-full"></span> | |
| </Link> | |
| <Link href="/gallery" className="transition-colors hover:text-primary relative group"> | |
| Gallery | |
| <span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-primary transition-all group-hover:w-full"></span> | |
| </Link> | |
| {session && ( | |
| <Link href="/create" className="transition-colors hover:text-primary relative group"> | |
| Create | |
| <span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-primary transition-all group-hover:w-full"></span> | |
| </Link> | |
| )} | |
| <Link href="/about" className="transition-colors hover:text-primary relative group"> | |
| About | |
| <span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-primary transition-all group-hover:w-full"></span> | |
| </Link> | |
| </nav> | |
| <div className="flex items-center space-x-4"> | |
| <div className="hidden md:block"> | |
| <ThemeToggle /> | |
| </div> | |
| {session && session.user ? ( | |
| <div className="flex items-center gap-4"> | |
| <div className="hidden sm:flex items-center gap-2 text-sm font-bold bg-secondary/10 px-4 py-1.5 rounded-full border-2 border-secondary/20 text-secondary"> | |
| <span>{credits} ⚡</span> | |
| </div> | |
| <DropdownMenu> | |
| <DropdownMenuTrigger asChild> | |
| <Button variant="ghost" className="relative h-10 w-10 rounded-full border-2 border-transparent hover:border-primary transition-all p-0"> | |
| <Avatar className="h-9 w-9 border-2 border-background"> | |
| <AvatarImage src={session.user.image || ""} alt={session.user.name || ""} /> | |
| <AvatarFallback className="bg-primary text-primary-foreground font-bold">{session.user.name?.[0]?.toUpperCase() || "U"}</AvatarFallback> | |
| </Avatar> | |
| </Button> | |
| </DropdownMenuTrigger> | |
| <DropdownMenuContent align="end" className="w-56 glass-panel border-2 mt-2"> | |
| <DropdownMenuLabel> | |
| <div className="flex flex-col space-y-1"> | |
| <p className="text-sm font-bold leading-none">{session.user.name}</p> | |
| <p className="text-xs leading-none text-muted-foreground">{session.user.email}</p> | |
| </div> | |
| </DropdownMenuLabel> | |
| <DropdownMenuSeparator className="bg-border/50" /> | |
| <DropdownMenuItem asChild className="focus:bg-primary/10 cursor-pointer font-medium"><Link href="/create">Generate</Link></DropdownMenuItem> | |
| <DropdownMenuItem asChild className="focus:bg-primary/10 cursor-pointer font-medium"><Link href="/history">History</Link></DropdownMenuItem> | |
| <DropdownMenuItem asChild className="focus:bg-primary/10 cursor-pointer font-medium"><Link href="/profile">Settings</Link></DropdownMenuItem> | |
| <DropdownMenuSeparator className="bg-border/50" /> | |
| <DropdownMenuItem asChild className="focus:bg-destructive/10 cursor-pointer text-destructive font-bold"> | |
| <form action={async () => { | |
| "use server" | |
| const { signOut } = await import("@/auth") | |
| await signOut() | |
| }}> | |
| <button className="w-full text-left">Sign out</button> | |
| </form> | |
| </DropdownMenuItem> | |
| </DropdownMenuContent> | |
| </DropdownMenu> | |
| </div> | |
| ) : ( | |
| <div className="hidden md:flex items-center gap-2"> | |
| <Button variant="ghost" asChild className="font-bold hover:bg-primary/10"><Link href="/login">Log in</Link></Button> | |
| <Button asChild className="neo-brutalist bg-primary text-primary-foreground hover:bg-primary/90 font-bold rounded-none"><Link href="/signup">Sign up</Link></Button> | |
| </div> | |
| )} | |
| {/* Mobile Menu */} | |
| <div className="md:hidden"> | |
| <Sheet> | |
| <SheetTrigger asChild> | |
| <Button variant="ghost" size="icon" className="neo-brutalist border-2 rounded-md"> | |
| <Menu className="h-6 w-6" /> | |
| </Button> | |
| </SheetTrigger> | |
| <SheetContent side="right" className="w-[300px] glass-panel border-l-2 p-6"> | |
| <SheetHeader> | |
| <div className="flex items-center justify-between"> | |
| <SheetTitle className="text-left text-2xl font-black uppercase tracking-tighter">Menu</SheetTitle> | |
| <ThemeToggle /> | |
| </div> | |
| </SheetHeader> | |
| <div className="flex flex-col gap-6 mt-8"> | |
| <nav className="flex flex-col gap-4"> | |
| <Link href="/" className="text-lg font-bold hover:text-primary transition-colors">Home</Link> | |
| <Link href="/gallery" className="text-lg font-bold hover:text-primary transition-colors">Gallery</Link> | |
| {session && ( | |
| <> | |
| <Link href="/create" className="text-lg font-bold hover:text-primary transition-colors">Create</Link> | |
| <Link href="/history" className="text-lg font-bold hover:text-primary transition-colors">History</Link> | |
| <Link href="/profile" className="text-lg font-bold hover:text-primary transition-colors">Settings</Link> | |
| </> | |
| )} | |
| <Link href="/about" className="text-lg font-bold hover:text-primary transition-colors">About</Link> | |
| </nav> | |
| {!session && ( | |
| <div className="flex flex-col gap-3 mt-4 pt-4 border-t-2 border-border/50"> | |
| <Button variant="outline" className="w-full neo-brutalist font-bold" asChild><Link href="/login">Log in</Link></Button> | |
| <Button className="w-full neo-brutalist bg-primary font-bold" asChild><Link href="/signup">Sign up</Link></Button> | |
| </div> | |
| )} | |
| </div> | |
| </SheetContent> | |
| </Sheet> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| ) | |
| } | |