import clsx from 'clsx';
import { useSidebarToggle } from './SidebarContext';
import { Dot } from 'lucide-react';
import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from '@vertesia/ui/core';
import { Nav } from "@vertesia/ui/router";
interface SidebarProps {
children: React.ReactNode | React.ReactNode[]
logo?: React.ReactNode
className?: string
}
export function Sidebar({ children, logo, className }: SidebarProps) {
return (
)
}
interface SidebarSectionProps {
children: React.ReactNode | React.ReactNode[]
title?: React.ReactNode
action?: React.ReactNode
isFooter?: boolean
className?: string
}
export function SidebarSection({ children, title, action, isFooter = false, className }: SidebarSectionProps) {
const { isOpen } = useSidebarToggle();
let header = isOpen ? <>
{title || ""}
{action}
> :
return (
{title &&
{header}
}
)
}
export function SidebarTooltip({ children, text }: { children: React.ReactNode, text?: string }) {
const { isOpen } = useSidebarToggle();
return (
isOpen ? <>{children}> :
{children}
{text}
)
}
export interface SidebarItemProps {
href: string
to?: string
icon?: React.ComponentType>
current?: boolean
onClick?: (event: React.MouseEvent) => void
children: React.ReactNode | React.ReactNode[]
tools?: React.ReactNode
className?: string;
id?: string; //HTML ID of the element
external?: boolean; //If true, the link will open in a new tab
replace?: boolean; //If true, navigation replaces the current history entry instead of pushing
}
export function SidebarItem({ external, className, tools, children, icon: Icon, href, to, current, onClick, replace }: SidebarItemProps) {
const { toggleMobile } = useSidebarToggle();
const _closeSideBar = () => {
setTimeout(() => {
toggleMobile(false)
}, 100);
}
const onClickWrapper = (event: React.MouseEvent) => {
if (external) {
window.open(href, '_blank');
event.preventDefault(); // Prevent default link behavior
event.stopPropagation(); // Stop the event from propagating
} else if (onClick) {
onClick(event);
}
}
return (
)
}