migrate ui crate to new theme tokens

This commit is contained in:
2026-10-09 10:43:46 +07:00
parent 90377c8c76
commit 5c15b0e840
27 changed files with 292 additions and 235 deletions
+75 -36
View File
@@ -281,51 +281,90 @@ Keep public APIs (D2). Per file, replace old token reads with new tokens,
radii with ratio functions, ad-hoc spacing with `SPACE` steps where it is a
real deviation, and state washes with the paint helpers.
- [ ] `button.rs` — variant table: Primary → `solid`/`on_solid` +
- [x] `button.rs` — variant table: Primary → `solid`/`on_solid` +
`surface_raised_hover`-style plate hover; Secondary →
`surface_raised` + `border` + `text`; Danger → `danger_strong` +
`on_accent`; Warning → `warning_muted` chip treatment; Ghost →
transparent + `element_hover`/`element_active`; Custom stays (sources
defaults from new tokens). Size → bezel `ControlSize` ladder values via
the existing `Size` enum. Radius: `button_radius()`, `bubble_radius()`
when `rounded`.
- [ ] `input/` — `input_bg`, `border_faint` resting / `border_strong` focus,
`ring`, `caret`, `selection`, `text_faint` placeholder.
- [ ] `dialog.rs` — `surface_dialog` over `scrim()`, `surface_radius()`,
frame shadows.
- [ ] `popover.rs`, `menu/` — `surface_overlay`, hairline border,
`popover_surface` stub (D6: plain wash for now).
- [ ] `tab.rs` — mapping table row: `bg` active plane, `element_hover`
hover, `text_muted`/`text` labels, `border_faint` separators.
- [ ] `nav.rs`, `nav_item.rs` — `element_hover`/`element_active` states,
`accent` selection markers.
- [ ] `title_bar.rs` — `surface`; drag handlers unchanged; height stays 36.
- [ ] `tooltip.rs` — `surface_overlay` plate, `text` label.
- [ ] `switch.rs` — on: `accent_strong` track + `on_solid` knob; off:
when `rounded`. *(Size ladder heights kept — bezel's 24px control
heights are a consumer-visible layout change, deferred.)*
- [x] `input/` — `input_bg`, `border_faint` resting / `border_strong` focus,
`ring`, `caret`, `selection`, `text_faint` placeholder. *(coop's Input
paints no frame border/ring of its own — focus mechanics untouched;
`InputEditorStyle::border` now `border_faint`, placeholder reaches
gpui-base's `muted_foreground`, now `text_faint`.)*
- [x] `dialog.rs` — `surface_dialog` over `scrim(SCRIM_ALPHA_DARK)`,
`surface_radius()`, `surface_shadows()` (entrance animation scales the
helper's shadow alphas).
- [x] `popover.rs`, `menu/` — `surface_overlay`, hairline border,
`popover_surface` stub (D6: plain wash for now). *(The floating plate
is `StyledExt::popover_style` in styled.rs; popover.rs itself paints no
theme values. Menu item corners are concentric:
`inset_radius(surface_radius(), 4)`.)*
- [x] `tab.rs` — mapping table row: `bg` active plane, `element_hover`
hover, `text_muted`/`text` labels, `border_faint` separators. *(No
separator was painted before; none added — structure frozen. Segmented
track is `surface`.)*
- [x] `nav.rs`, `nav_item.rs` — `element_hover`/`element_active` states,
`accent` selection markers. *(Resting labels are now `text_muted` —
intentional visible change; radius 12→8.)*
- [x] `title_bar.rs` — the crate never read `title_bar`/`title_bar_inactive`
(consumers paint the strip); close-button danger hover reskinned to
`danger_strong`/`on_accent`/`plate_active`. Drag handlers and heights
untouched.
- [x] `tooltip.rs` — `surface_overlay` plate, `text` label,
`control_radius()`.
- [x] `switch.rs` — on: `accent_strong` track + `on_solid` knob; off:
`input_bg` track + `border`.
- [ ] `indicator.rs`, `kbd.rs` — indicator gets `success`/`busy`/`danger`
dots; kbd: `surface_raised` + `border_faint` + `text_muted`.
- [ ] `avatar.rs` — `border_faint` ring; keep blob behavior.
- [ ] `message.rs` — `bubble_radius()` on bubbles, `text_dim` for file-path /
secondary labels, `success`/`busy`/`danger` delivery states, `band` for
composer strips.
- [ ] `markdown.rs` — `code_text`/`code_wash`, `SyntaxPalette`,
`text_muted` headings hierarchy.
- [ ] `notification.rs` — `surface_overlay` plate + semantic accents.
- [ ] `group_box.rs` — `panel_radius()`, `border_faint`, `band` header.
- [ ] `dock/`, `resizable/` — `drop_target`, `drop_line`, `border_faint`.
- [ ] `scroll/` — scrollbar paints from gpui-base tokens; verify
`ScrollbarMode` setting still lands via `sync_base`.
- [ ] `root.rs` — `bg` + `border` window frame, frame shadows.
- [ ] `icon.rs` — tones from text tokens; keep the `IconName` set as-is.
- [ ] `styled.rs` — `divider()` → `border_faint` / `hairline()`;
`popover_style()` → `surface_overlay` + `surface_radius()`. Keep
- [x] `indicator.rs`, `kbd.rs` — indicator turned out to be the loading
spinner and paints no theme values (no status dots exist in `crates/ui`
— the `success`/`busy`/`danger` mapping lands at consumer call sites in
Phase 3). kbd: `surface_raised` + `border_faint` + `text_muted`.
- [x] `avatar.rs` — no ring/border is painted today; dropped the
`ghost_element_background` underlay. Blob behavior kept.
- [x] `message.rs` — `text_dim` on the author/timestamp row, `text_faint`
welcome body, `element_hover` row wash. *(No bubbles, delivery states,
composer strips or report banners live in this file — those are
consumer-side, Phase 3.)*
- [x] `markdown.rs` — `code_text`/`code_wash` (added `with_inline_code`),
heading hierarchy (`with_heading`: h1–h3 `text`, h4–h6 `text_muted`),
links `accent`. *(Fenced-code highlighting comes from gpui-base's theme
via `sync_base`; `SyntaxPalette` stays unconsumed until a coop-side
highlighter exists.)*
- [x] `notification.rs` — `surface_overlay` plate + `surface_radius()` +
`surface_shadows()`; error is a full `danger_strong` plate with
`on_accent`, success/warning icons `success`/`warning`.
- [x] `group_box.rs` — `surface` plate, `panel_radius()`. *(No border or
header strip is painted today; adding them is a design change, deferred
to Phase 3/4 review.)*
- [x] `dock/`, `resizable/` — `drop_target`, `drop_line`, `border_faint`.
*(Tab-insertion line and drop-region outline both use `drop_line` now —
slightly more prominent than the old muted outline, intentional. Drag
preview/empty-space drag-over also reskinned.)*
- [x] `scroll/` — verified: zero theme reads; scrollbar paint comes from
gpui-base via `sync_base`, `ScrollbarMode` still lands.
- [x] `root.rs` — `bg` plane, `surface_shadows()` on the window frame (now
gated on `cx.theme().shadow`); decoration consts untouched.
- [x] `icon.rs` — default tone `text_muted` (was `icon`); `IconName` set and
APIs unchanged.
- [x] `styled.rs` — `divider()` → `border_faint`; `popover_style()` →
`surface_overlay` + `px(surface_radius())` + `surface_shadows()` gated
on `cx.theme().shadow` (was always-on `shadow_md`). Keep
`h_flex`/`v_flex` names (bezel's `stack::row`/`column` equivalents).
- [ ] `animation.rs` — leave as-is this pass; note bezel's named-motion
catalog as follow-up.
- [x] `animation.rs` — left as-is this pass; bezel's named-motion catalog is
a follow-up.
Validation: `cargo check -p ui`, run desktop, walk every component in
light/dark against Phase 0 screenshots.
Outcome: `theme::plate_hover`/`plate_active` were made public (wrappers over
the crate-internal `*_for` helpers) so `crates/ui` can reskin opaque plates.
Zero legacy-token reads remain in `crates/ui` (the Phase 3 grep already
passes inside this crate); `cargo check -p ui`, `cargo check --workspace`,
`cargo test -p theme` (11 tests) and `cargo clippy -p ui -p theme` are green.
Public APIs, element structure, sizes and heights unchanged (D2, D7).
Validation remaining: run desktop, walk every component in light/dark
against the Phase 0 screenshots.
### Phase 3 — Migrate consumers