import type { ReactNode } from "react"; import { Dropdown } from "./Dropdown.js"; import { HeaderAvatar } from "./AppHeader.js"; import { Icon, type IconName } from "./Icon.js"; export interface UserProfileMenuAction { id: string; label: ReactNode; icon?: IconName; href?: string; disabled?: boolean; tone?: "default" | "danger"; onSelect?: () => void; } export interface UserProfileMenuProps { displayName: string; subtitle?: string; avatarUrl?: string; coverImageUrl?: string; triggerLabel?: ReactNode; actions: readonly UserProfileMenuAction[]; } export function UserProfileMenu({ displayName, subtitle, avatarUrl, coverImageUrl, triggerLabel, actions, }: UserProfileMenuProps) { const label = displayName || "NODE.DC"; return ( ( )} > {({ close }) => (
{label} {subtitle ? {subtitle} : null}
{actions.map((action) => { const content = ( <> {action.icon ? : } {action.label} ); if (action.href && !action.disabled) { return ( close()} > {content} ); } return ( ); })}
)}
); }