2024-04-08 23:40:42 -04:00
|
|
|
"use client"
|
|
|
|
|
|
|
|
import { X } from "lucide-react"
|
|
|
|
import { Button } from "./button"
|
2024-04-26 00:10:53 -04:00
|
|
|
import { useEffect } from "react"
|
2024-04-08 23:40:42 -04:00
|
|
|
|
|
|
|
export default function Tab({
|
|
|
|
children,
|
2024-04-18 15:38:38 -04:00
|
|
|
selected,
|
2024-04-08 23:40:42 -04:00
|
|
|
onClick,
|
|
|
|
onClose,
|
|
|
|
}: {
|
|
|
|
children: React.ReactNode
|
2024-04-18 15:38:38 -04:00
|
|
|
selected?: boolean
|
2024-04-08 23:40:42 -04:00
|
|
|
onClick?: () => void
|
|
|
|
onClose?: () => void
|
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
onClick={onClick ?? undefined}
|
|
|
|
size="sm"
|
2024-04-18 15:38:38 -04:00
|
|
|
variant={"secondary"}
|
2024-04-26 00:10:53 -04:00
|
|
|
className={`group font-normal select-none ${
|
|
|
|
selected
|
|
|
|
? "bg-neutral-700 hover:bg-neutral-600 text-foreground"
|
|
|
|
: "text-muted-foreground"
|
2024-04-18 15:38:38 -04:00
|
|
|
}`}
|
2024-04-08 23:40:42 -04:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
<div
|
2024-04-26 00:10:53 -04:00
|
|
|
onClick={
|
|
|
|
onClose
|
|
|
|
? (e) => {
|
|
|
|
e.stopPropagation()
|
|
|
|
e.preventDefault()
|
|
|
|
onClose()
|
|
|
|
}
|
|
|
|
: undefined
|
|
|
|
}
|
2024-04-09 00:50:48 -04:00
|
|
|
className="h-5 w-5 ml-0.5 flex items-center justify-center translate-x-1 transition-colors bg-transparent hover:bg-muted-foreground/25 cursor-pointer rounded-sm"
|
2024-04-08 23:40:42 -04:00
|
|
|
>
|
|
|
|
<X className="w-3 h-3" />
|
|
|
|
</div>
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|