'use client'; import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@djangocfg/ui-core/components'; type Props = { label: string; // Keyboard shortcut hint shown in the tooltip (e.g. "L" for loop). Optional. shortcut?: string; active?: boolean; children: ReactNode; // Render the button without the tooltip wrapper. Useful for inline contexts // (e.g. inside another tooltip / popover) where nesting Radix portals is // unnecessary. noTooltip?: boolean; } & Omit, 'children' | 'aria-label'>; // `forwardRef` is mandatory: this button is used as `` // in VolumeControl. Without ref forwarding, Radix can't anchor the popper to // the trigger, and `` renders with zero rect (invisible). export const IconButton = forwardRef(function IconButton( { label, shortcut, active, children, noTooltip, className = '', ...rest }, ref, ) { // Active state uses a tinted primary surface — readable, on-brand, not loud. const stateClasses = active ? 'bg-primary/10 text-primary hover:bg-primary/15' : 'text-muted-foreground hover:bg-accent hover:text-foreground'; const button = ( ); if (noTooltip) return button; return ( {button} {label} {shortcut && ( {shortcut} )} ); });