feat(components): cad_tool_button + data_table + toast_overlay#6
Merged
Conversation
Unblocks the editor port slices in tokito (VtronTokito/tokito#26 — slice foundation issue #36). The Tokito desktop's legacy `crate::ui::{widgets, table, toast}` modules cover these three roles today; this brings them into `tokito_ui` so the editor migration can land on the shared design substrate. ## cad_tool_button `pub fn cad_tool_button(ui, t, glyph: &str, side, selected, tooltip) -> Response` Square, toggleable button for a CAD tool rail (select, wire, label, bus, …). `glyph` is a Phosphor constant so the icon set lives in the consumer crate, not the library. Configurable `side` (legacy was a fixed 38×36). Animated hover, accent border + soft fill when selected, `text_2 → text` ink fade otherwise. ## data_table (+ SortState + sortable_header) Built on `egui_extras::TableBuilder` so consumers get sticky headers, striped rows, and column-width control without re-implementing them. `SortDir`/`SortState` are small types the consumer owns; `sortable_header` is the clickable column-header primitive; `data_table` is a thin composer that wires them together for the common case. Adds `egui_extras = "0.29"` to deps — pinned to match the existing egui 0.29 / egui-phosphor 0.7.x version coupling rule in AGENTS.md. ## toast_overlay (+ ToastStack) `ToastStack` owns a queue of `Toast { message, kind, until }`. Consumers hold one in app state and call `push_info`/`push_success`/`push_warning`/ `push_error` from anywhere; once per frame they pass it to `toast_overlay(ctx, t, &mut stack)` to paint. Expired entries are pruned automatically and the overlay re-requests repaints while toasts are still live so dismissal is on-time. Anchored bottom-right, newest first. ## Docs - README component table — three new rows. - AGENTS.md — full component list updated; toast/checkbox removed from "Known follow-ups" (toast is now shipped; checkbox shipped earlier). ## CI gates locally clean - `cargo fmt --all -- --check` - `cargo clippy --all-targets -- -D warnings` - `cargo build` - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps` Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
kakarot-dev
added a commit
to VtronTokito/tokito
that referenced
this pull request
Jun 12, 2026
…gation) (#52) * deps(tokito_ui): bump rev to 5fc4542 — cad_tool_button + data_table + toast_overlay Bumps the tokito_ui rev to pick up the three new primitives shipped in [VtronTokito/ui#6][1]: - cad_tool_button — square toggleable CAD tool-rail button (replaces legacy `crate::ui::widgets::cad_tool_button`) - data_table + SortState + sortable_header — egui_extras-backed sortable table (replaces legacy `crate::ui::table`) - toast_overlay + ToastStack — transient bottom-right notifications (replaces legacy `crate::ui::toast`) This is the foundation slice for the editor migration — every studio file we port next (slices #37–#43 under epic #26) consumes at least one of these. [1]: VtronTokito/ui#6 cargo fmt --all -- --check: clean cargo clippy --workspace --all-targets -- -D warnings: clean cargo test -p tokito-native: 56 passed, 0 failed Closes #36 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(ui): legacy primitives delegate to tokito_ui The legacy crate::ui::{widgets, layout, toast} modules now render through tokito_ui::components under the hood. The editor's call sites (`secondary_button(ui, chrome.tokens, label)`, `filter_chip(...)`, `content_card(...)`, etc.) stay unchanged — they keep taking &UiTokens and returning the same shapes — but the actual painting goes through the shared design layer. Effect: the whole editor (chrome panels, side bars, lists, buttons, toasts) immediately picks up the new tokito_ui look without touching the 20+ files that consume these primitives. ## What changed - tokens.rs: `UiTokens::tk()` produces a `tokito_ui::Tokens` from the chrome palette. The schematic-specific colours (canvas grid, wire default/highlight/selected, ERC markers, symbol body fill) stay editor-local because they don't have a tokito_ui counterpart. - widgets.rs: `list_row`, `primary_button`, `primary_button_full`, `secondary_button` delegate to tokito_ui::components::{list_row, text_button(ButtonKind::{Primary, Secondary})}. The CAD tool rail (`cad_tool_button` + `paint_tool_icon`) stays manual because the schematic tool glyphs (wire bend, GND triangle, net label) aren't Phosphor — tokito_ui::cad_tool_button takes a glyph string. - layout.rs: `section_header`, `subsection`, `empty_state`, `content_card`, `inspector_row`, `filter_chip`, `list_section_label` delegate. The panel chrome (`panel_frame`, `dock_tab_shell`, `toolbar_actions`, `search_field`) stays editor-local — dock-specific behaviour. - toast.rs: `ToastStack` wraps `tokito_ui::components::ToastStack`; `ToastKind` mirrors the shared enum 1:1 via `From`. table.rs is unchanged — its `SortState` has a `sort_strings` convenience the tokito_ui version doesn't, and `sortable_header` doesn't take tokens. mcad_viewer/* and viewer3d.rs stay legacy as well — explicitly out of scope for this migration ("don't touch the mesh"). ## Verified locally - `cargo fmt --all -- --check`: clean - `cargo clippy --workspace --all-targets -- -D warnings`: clean - `cargo test -p tokito-native`: 56 passed, 0 failed ## Follow-up (separate PR) The slice #44 "delete legacy crate::ui::{widgets, layout, toast}" remains open. The legacy modules are now thin wrappers — when we rewrite the editor call sites to call tokito_ui directly, the modules drop. Closes #36 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(ui): real migration to tokito_ui — UiTokens deleted, schematic palette unified Round 4 of the editor migration. Real type-level migration this time: the custom UiTokens struct is gone; UiTokens is now a thin type alias for tokito_ui::Tokens, which carries both chrome and schematic palettes. ## What changed - ui/tokens.rs — replaced with `pub use tokito_ui::Tokens as UiTokens;` The 40+ schematic colour fields the editor used (canvas, wire, sym, label_ink, refdes_ink, pin_ink, selection, preview_bg, …) now live in tokito_ui::Tokens (via VtronTokito/ui#8). - theme.rs — tokens_for() returns the tokito_ui preset (dark/light) for the theme; no more hand-rolled UiTokens literal. Visuals wiring uses Stroke::new(1.0, t.border) where it previously read t.stroke_subtle, and t.rounding_*() for the Rounding-typed visual fields. - Every editor consumer file (app/studio/*, editor/*, mcad_viewer/*, viewer3d.rs, app/mod.rs, app/impl_eframe.rs, theme.rs, base_symbols.rs) was field-renamed from the legacy UiTokens names to the tokito_ui ones: text_primary → text text_secondary → text_2 text_muted → text_3 bg_app → bg bg_panel → bg_chrome bg_elevated → card bg_canvas → canvas_bg bg_hover → card_hover bg_chip_selected → accent_soft accent_dim → accent_soft spacing_xs..lg → space_1, space_2, space_4, space_5 .stroke_subtle → Stroke::new(1.0, .border) .stroke_focus → Stroke::new(1.4, .border_strong) .margin_panel → Margin::symmetric(.space_4, .space_3) - editor/tool_icons.rs — new module holding the hand-drawn schematic glyphs (Select, Place, Wire, NetLabel, Power, Junction, NoConnect, Bus, Text, Pan, Focus, ZoomFit, Grid, Snap). Designed as the closure body the new tokito_ui::components::cad_tool_button takes: c::cad_tool_button(ui, &t, 38.0, sel, "Wire", |p, r, ink| { paint(p, r, ToolIcon::Wire, ink) }); - ui/widgets.rs, ui/layout.rs, ui/toast.rs — still in place as thin wrappers; bodies now pass `tokens` directly (no more .tk() conversion). The wrappers will fold away in a final cleanup slice once consumer call sites switch to tokito_ui::components::* directly. Today they're a 1:1 trivial mapping. ## Visual + behavioural effect - Every chrome surface, button, list row, card, search field, toast in the editor now renders through tokito_ui::components. - The schematic canvas reads its palette from the same Tokens value the chrome reads — one token source. - Mesh (mcad_viewer + viewer3d.rs) was migrated too (no carve-out). ## Local CI clean - cargo fmt --all -- --check - cargo clippy --workspace --all-targets -- -D warnings - cargo test -p tokito-native: 56 passed, 0 failed ## Still ahead in this PR - Migrate consumer call sites to import tokito_ui::components directly (today they go through `crate::ui::widgets::secondary_button` etc., which is a 1-line wrapper around `tokito_ui::components::text_button`). - Delete legacy crate::ui::{widgets, layout, table, toast, typography}. Both are mechanical organisational cleanup; the visual look is final. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(ui): finish migration — call tokito_ui::components directly, delete legacy modules Editor consumers now reach into `tokito_ui::components` and `tokito_ui::Tokens` without going through `crate::ui::{widgets,layout,table,toast,tokens,typography}`. Those modules are gone; only `crate::ui::icons` (Phosphor font binding) remains. - toast: `crate::ui::toast::{ToastStack,ToastKind}` → `tokito_ui::components::*`, `.show(ctx, tokens)` → `toast_overlay(ctx, tokens, stack)`. - table: `crate::ui::table::{SortState,SortDir,sortable_header}` → tokito_ui's variants; the editor-local `data_table`/`sort_strings` helpers are dropped. - typography: `TypeRamp::small_weak/body/section/title` calls inlined as `RichText::new(...).small().weak()` / `.heading().strong()` etc. — egui's named text styles already carry the same pixel sizes (theme.rs registers Small at 11.0, matching the ramp). - tokens: `crate::ui::UiTokens` → `tokito_ui::Tokens` throughout (editor, render, base_symbols, mcad_viewer, theme). - chrome: `dock_tab_shell`, `section_header`, `subsection`, `empty_state`, `toolbar_actions` inlined into `app/studio/chrome.rs::TabChrome`. - search field on the place panel built inline against `egui::TextEdit` to preserve Enter-to-submit semantics. Gates green locally: `cargo fmt --check`, `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace --locked`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * ci(coverage): drop TOKITO_RUN_DB_INTEGRATION — gate off the flaky pg-embed test pg-embed's PostgreSQL bootstrap flakes intermittently on the Actions runner (seen here as `put_and_get_schematic_document: embedded PostgreSQL failed after retries` — same fragility that already gates pg-embed off the Windows `test` job). The DB integration tests are still run by `test (ubuntu-latest)`; coverage just leaves the env var unset so the suite self-skips them via `tokito::test_support::database_integration_tests_enabled()`. Coverage delta on the affected DB paths is small (request handlers behind a thin axum layer) and we already accept Codecov upload failures with `fail_ci_if_error: false`, so trading coverage of that slice for a stable job is the right call. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unblocks the editor port slices in VtronTokito/tokito#26 — specifically the foundation slice #36 which carries this exact scope.
The Tokito desktop's legacy `crate::ui::{widgets, table, toast}` modules cover these three roles today. Bringing them into `tokito_ui` is what lets the editor migration land on the shared design substrate instead of building new UI on the deprecated path.
What's added
`cad_tool_button`
Square toggleable button for a CAD tool rail (select, wire, label, bus, …). `glyph` is a Phosphor constant so the icon set lives in the consumer crate, not the library — `ToolIcon`-style enums stay on the editor side. Configurable `side` (legacy was a fixed 38×36). Animated hover, accent border + soft fill when selected.
`data_table` + `SortState` + `sortable_header`
Built on `egui_extras::TableBuilder` for sticky headers + striped rows + column-width control. `SortState` is the small typed state the consumer owns; `sortable_header` is the clickable header primitive; `data_table` is a thin composer for the common case (headers + sortable + scrolling body).
Adds `egui_extras = "0.29"` to deps, pinned to match the existing egui 0.29 / egui-phosphor 0.7.x coupling.
`toast_overlay` + `ToastStack`
`ToastStack` is the owned queue with `push_info`/`push_success`/`push_warning`/`push_error` helpers. `toast_overlay(ctx, t, &mut stack)` paints the live entries bottom-right with auto-prune + repaint scheduling. Replaces the legacy `crate::ui::toast` module exactly.
Docs
CI gates locally clean
Next
After this lands, VtronTokito/tokito bumps the `tokito_ui` rev SHA in `native/Cargo.toml` (will close #36) and the editor port slices (#37–#43) unblock.