// The thumb's transition lives beside the dashboard's own widgets, and CSS is // chunked per entry — so the rule is pulled in wherever this control is used, // or two copies of one shape would move differently. import "@/components/Dashboard/dashboard.css" import { cn } from "@/lib/utils" /** * One of N, as the one segmented shape: a single border pill, no dividers, * transparent segments, and `bg-accent` held by a thumb that slides rather than * a fill that jumps from cell to cell (root DESIGN-GUIDELINES.md). * * ponytail: sized for editor chrome — `w-fit`, `text-xs`, a mouse-sized target. * The widget-side copy in `Dashboard/widgets.tsx` is a full-width pill with a * 44px touch target, so pointing that one here needs a size prop first. */ export function Segmented({ value, options, label, testId, onChange, }: { value: string /** `[value, label]` pairs, in the order they are drawn. */ options: readonly (readonly [string, string])[] /** Names the group for screen readers. */ label: string testId?: string onChange: (value: string) => void }) { const chosen = options.findIndex(([option]) => option === value) return ( // A `fieldset` carries `min-inline-size: min-content` from the UA sheet, // which no width utility overrides. Equal tracks and no gap put the thumb // at its share of the padded box without measuring — a grid rather than a // flex row because `flex-1` under `w-fit` sizes the segments to a share of // the widest label instead of to the label itself.
{label} {chosen >= 0 ? ( ) : null} {options.map(([option, optionLabel], index) => ( ))}
) }