Playing with the layout

This commit is contained in:
Owen Schwartz 2024-10-13 18:33:41 -04:00
parent 860e83e277
commit 11c687fc3a
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
11 changed files with 478 additions and 78 deletions

View file

@ -1,8 +1,7 @@
"use client"
import React from 'react'
import Link from "next/link"
import { usePathname } from "next/navigation"
import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
@ -11,15 +10,17 @@ interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> {
href: string
title: string
}[]
disabled?: boolean
}
export function SidebarNav({ className, items, ...props }: SidebarNavProps) {
export function SidebarNav({ className, items, disabled = false, ...props }: SidebarNavProps) {
const pathname = usePathname()
return (
<nav
className={cn(
"flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",
disabled && "opacity-50 pointer-events-none",
className
)}
{...props}
@ -33,12 +34,16 @@ export function SidebarNav({ className, items, ...props }: SidebarNavProps) {
pathname === item.href
? "bg-muted hover:bg-muted"
: "hover:bg-transparent hover:underline",
"justify-start"
"justify-start",
disabled && "cursor-not-allowed"
)}
onClick={disabled ? (e) => e.preventDefault() : undefined}
tabIndex={disabled ? -1 : undefined}
aria-disabled={disabled}
>
{item.title}
</Link>
))}
</nav>
)
}
}