Skip to content

Commit 5b4b267

Browse files
Aymericrclaude
andcommitted
feat(editor): smart unit suffix — dim on focus, yield to explicit units
While editing a numeric field, the unit suffix now visually responds to the draft content: - Plain number / empty: suffix dims to 40% opacity (signals "default unit if you commit a bare number") - Explicit unit typed (hint showing): suffix fades to opacity-0 over 150ms (the conversion hint provides unit feedback instead) - Unparseable text: suffix stays dimmed (field will revert on commit) - At rest: unchanged full-opacity suffix Uses opacity-0 rather than unmounting so the flex layout doesn't jump. The predicate is simply `hint !== null` — it aligns exactly with measurementHint's internal PLAIN_NUMBER guard. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 58339c6 commit 5b4b267

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/editor/src/components/ui/controls/metric-control.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,16 @@ export function MetricControl({
330330
type="text"
331331
value={inputValue}
332332
/>
333-
{displayUnit && <span className="ml-[1px] text-muted-foreground">{displayUnit}</span>}
333+
{displayUnit && (
334+
<span
335+
className={cn(
336+
'ml-[1px] transition-opacity duration-150',
337+
hint ? 'opacity-0' : 'text-muted-foreground/40',
338+
)}
339+
>
340+
{displayUnit}
341+
</span>
342+
)}
334343
</div>
335344
) : (
336345
<div

packages/editor/src/components/ui/controls/slider-control.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,16 @@ export function SliderControl({
329329
type="text"
330330
value={inputValue}
331331
/>
332-
{displayUnit && <span className="ml-[1px] text-muted-foreground">{displayUnit}</span>}
332+
{displayUnit && (
333+
<span
334+
className={cn(
335+
'ml-[1px] transition-opacity duration-150',
336+
hint ? 'opacity-0' : 'text-muted-foreground/40',
337+
)}
338+
>
339+
{displayUnit}
340+
</span>
341+
)}
333342
</>
334343
) : (
335344
<div

0 commit comments

Comments
 (0)