import {
Box,
Column,
type ColumnProps,
Focusable,
Icon,
Row,
type RowProps,
Text,
Tooltip,
TooltipTrigger,
} from '@umami/react-zen';
import classNames from 'classnames';
import { createContext, type ReactNode, useContext } from 'react';
export interface SidebarProps extends ColumnProps {
isCollapsed?: boolean;
muteItems?: boolean;
children?: ReactNode;
}
const SidebarContext = createContext(null as any);
export function Sidebar({ isCollapsed, muteItems, className, children, ...props }: SidebarProps) {
return (
{children}
);
}
export function SidebarSection({
title,
className,
children,
...props
}: { title?: string; children: ReactNode } & ColumnProps) {
return (
{title && (
{title}
)}
{children}
);
}
export function SidebarHeader({
label,
icon,
className,
children,
...props
}: {
label: string;
icon?: ReactNode;
children?: ReactNode;
} & RowProps) {
return (
{icon && {icon}}
{label && {label}}
{children}
);
}
export interface SidebarItemProps extends RowProps {
isSelected?: boolean;
}
export function SidebarItem({
label,
icon,
isSelected,
className,
children,
...props
}: {
label?: string;
icon?: ReactNode;
} & SidebarItemProps) {
const { isCollapsed } = useContext(SidebarContext);
return (
{icon && {icon}}
{label && !isCollapsed && {label}}
{children}
{label}
);
}