'use client'; import type { ReactNode } from 'react'; import { X } from 'lucide-react'; import { cn } from '@djangocfg/ui-core/lib'; import { useResolvedComposerSize } from './size-context'; import type { ComposerSize } from './types'; export interface ComposerToolPillProps { /** Leading icon — a lucide-react element. */ icon?: ReactNode; /** Pill text. */ label: ReactNode; /** Accent fill when the tool/mode is active. */ active?: boolean; /** Clicking the pill body (toggles the tool). */ onClick?: () => void; /** When set, renders a trailing `×` that calls this instead. */ onRemove?: () => void; disabled?: boolean; /** Omit to inherit the composer's size. */ size?: ComposerSize; className?: string; } /** Per-size geometry — round capsule heights matching the action bar. */ const PILL_SIZE: Record = { sm: { pill: 'h-7 gap-1 px-2', text: 'text-xs', icon: '[&_svg]:size-3.5' }, md: { pill: 'h-9 gap-1.5 px-3', text: 'text-sm', icon: '[&_svg]:size-4' }, lg: { pill: 'h-11 gap-2 px-3.5', text: 'text-sm', icon: '[&_svg]:size-[1.125rem]' }, }; /** * A rounded action-bar capsule for a selected tool or mode — Gemini's * "🎨 Images" pill. Drop it into `composerSlots.inlineStart` (leading * cluster). When `onRemove` is set the pill shows a trailing `×`. */ export function ComposerToolPill({ icon, label, active = false, onClick, onRemove, disabled, size, className, }: ComposerToolPillProps) { const sz = PILL_SIZE[useResolvedComposerSize(size)]; return (
{onRemove ? ( ) : null}
); }