import { DropdownMenu } from "@cloudflare/kumo"; import { CaretUpDown, Check } from "@phosphor-icons/react"; import type { ComponentType, ReactNode } from "react"; export interface SwitcherItem { id: string; name: string; icon?: ComponentType<{ className?: string; weight?: "fill" | "regular" }>; } export interface SidebarSwitcherProps { /** The currently selected surface (account or site). */ current: SwitcherItem; items: SwitcherItem[]; onSelect: (item: SwitcherItem) => void; /** Extra rows after a separator (e.g. "All sites"). */ extra?: ReactNode; ariaLabel: string; } /** * Surface switcher for `Sidebar.Header`, following Kumo's AccountSwitcher demo: the trigger is a * plain row that collapses with the sidebar (caret hides via the sidebar's data-state), the menu * matches the trigger width and marks the current item. */ export function SidebarSwitcher({ current, items, onSelect, extra, ariaLabel, }: SidebarSwitcherProps) { const CurrentIcon = current.icon; return ( } > {CurrentIcon && } {current.name} {items.map((item) => { const Icon = item.icon; return ( onSelect(item)} > {Icon && } {item.name} {item.id === current.id && } ); })} {extra} ); }