From 9d11e01a48328f5bd8d6367f57cea3c5e047c46b Mon Sep 17 00:00:00 2001 From: stroblme Date: Fri, 28 Aug 2026 18:49:29 +0200 Subject: [PATCH] Point the range picker at the shared segmented control RangePicker carried a byte-for-byte copy of ui/segmented.tsx's markup; it now renders that component instead. The dashboard's own segmented widget stays where it is: it is not a copy but a look-aware control, drawn per look in Dashboard/ui/{fluksio,glass,material}/Controls.tsx over the shared useSegmented behaviour. Note that in segmented.tsx in place of the stale size-prop plan. --- .../src/components/Common/RangePicker.tsx | 68 +++++-------------- frontend/src/components/ui/segmented.tsx | 11 +-- 2 files changed, 22 insertions(+), 57 deletions(-) diff --git a/frontend/src/components/Common/RangePicker.tsx b/frontend/src/components/Common/RangePicker.tsx index 8b90a7a..86fce44 100644 --- a/frontend/src/components/Common/RangePicker.tsx +++ b/frontend/src/components/Common/RangePicker.tsx @@ -1,8 +1,4 @@ -// The segmented shape's thumb transition lives beside the dashboard's own -// widgets, and CSS is chunked per entry — so the rule is pulled in wherever -// this picker is used, or the two copies of one shape would move differently. -import "@/components/Dashboard/dashboard.css" -import { cn } from "@/lib/utils" +import { Segmented } from "@/components/ui/segmented" /** * A window of history, and everything a query needs to ask for it. @@ -39,12 +35,7 @@ export const DEFAULT_RANGE = RANGES[2] export const rangeStart = (range: Range) => new Date(Date.now() - range.hours * 3600_000).toISOString() -/** - * The window a screen is showing, as presets. - * - * The one segmented shape: a single border pill, transparent segments, - * bg-accent on the selected one (root DESIGN-GUIDELINES.md). - */ +/** The window a screen is showing, as presets. */ export function RangePicker({ value, onChange, @@ -52,47 +43,20 @@ export function RangePicker({ value: Range onChange: (range: Range) => void }) { - const chosen = RANGES.findIndex((range) => range.hours === value.hours) 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 - // sliding 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. -
- Time range - {chosen >= 0 ? ( - - ) : null} - {RANGES.map((range, index) => ( - - ))} -
+ [String(range.hours), range.label] as const, + )} + onChange={(hours) => + onChange( + RANGES.find((range) => String(range.hours) === hours) ?? + DEFAULT_RANGE, + ) + } + /> ) } diff --git a/frontend/src/components/ui/segmented.tsx b/frontend/src/components/ui/segmented.tsx index cba6323..ddbac00 100644 --- a/frontend/src/components/ui/segmented.tsx +++ b/frontend/src/components/ui/segmented.tsx @@ -1,6 +1,5 @@ // 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. +// chunked per entry — so the rule is pulled in wherever this control is used. import "@/components/Dashboard/dashboard.css" import { cn } from "@/lib/utils" @@ -9,9 +8,11 @@ import { cn } from "@/lib/utils" * 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. + * App-side chrome only — `w-fit`, `text-xs`, a mouse-sized target. The + * dashboard's own segmented widget is not this component and never will be: + * it is drawn per look by `Dashboard/ui/{fluksio,glass,material}/Controls.tsx` + * over the shared `useSegmented` behaviour, as a full-width pill with a 44px + * touch target. Folding the two together would flatten the three looks. */ export function Segmented({ value,