Skip to content

Style: the base style is built from the tokens (#497 stage 2) - #499

Merged
samitbasu merged 2 commits into
shadcn-tokens-497from
shadcn-style-497
Nov 25, 2026
Merged

samitbasu merged 2 commits into
shadcn-tokens-497from
shadcn-style-497

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Stage 2 of #497: the base style is built from the tokens. Stacked on #498; merge that first. The diff against #498 deletes 1,931 lines and adds 1,154.

What changes

  • Style::new(&Tokens) fills every section the way Shadcn::style() did, in tokens.theme. Style::default() is Vega light.
  • Style::write_look(|sheet| …) writes the preset layer, then the recorded exceptions. Shadcn::style() is now Style::new + write_look + the disclosure exceptions.
  • Tokens carry their theme. with_palette and warn_low_contrast lose their theme argument, and Shadcn.theme becomes Shadcn::theme().
  • A layout with no style of its own gets Style::default() without its font, at regular weights. It installs no font and leaves egui's visuals alone.
  • The 10 private sections become pub fields (label, checkbox, radio, switch, segmented, select, menu, tooltip, input, table).
  • size::* moves to eggshell_ui::theme::size.
  • New: TablePart::last_row() and TablePart::striped_row(), beside first_column().
  • src/legacy_defaults.rs feeds the old Defaults writers from egui's default visuals until stage 3 deletes both. It's marked // #497 stage 3: delete.

Removed

  • Style::from_egui, plus ScrollStyle::from_egui, SplitterStyle::from_egui and TableStyle::from_egui.
  • Style::rewrite_rules. write_exceptions is now private.
  • The 10 setters (set_select … set_tooltip) and the 10 getters.
  • Private code: Style::derived, restyle, Sheet::set_layer, Sheet::has_rules_at.

Tests

  • 12 deleted. They pinned the egui-derived look or the restyle plumbing.
  • Rewritten onto App rules: table stripe, first-column inset and rule below the last row; the tabs icon cell; the select chevron; the number field's select height.
  • Two overlay fuzz tests: the window goes from 240×220 to 240×200. Vega's shorter page left the anchor on screen; the hidden-menu precondition still holds.

Checks

  • cargo xtask integrate: green.
  • No golden moved: 229 passed.
  • A temporary, uncommitted harness dumped every section, every extras extension, the egui style and every part's resolved classes. It covered Vega/Lyra × light/dark, for both style() and layout_style(). Before and after are byte-identical, once source locations are stripped.

For the user

  • Geist in a layout with no style? Leaving it out keeps the goldens still. Putting it in would re-render the 8 layout-only goldens (kaolin_*, chrome_stacked_by_z) in Geist; that would be a follow-up PR.
  • Stale prose:
    • "Style::default is derived from egui's visuals" (contract.rs:6);
    • "one derived from egui's" (draw.rs, pipeline.rs, shell.rs);
    • the size module doc;
    • TODO(prose) placeholders on the new items.
  • Names to check: write_look, last_row, striped_row.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76

samitbasu and others added 2 commits November 24, 2026 12:10
Tokens hold one theme's colours, but nothing said which:
with_palette took the theme as an argument that "must be the theme they
were made for", and Shadcn kept its own theme beside its tokens. Stage 2
builds a Style from tokens alone and needs the theme for shadcn's
`dark:` classes (input fill, ghost hover, the kbd on a tooltip).

- Tokens::theme, set by light() and dark().
- Tokens::with_palette(palette) reads it; its theme argument goes.
- theme::warn_low_contrast(ctx, tokens) reads it; its theme argument goes.
- Shadcn's `theme` field goes; Shadcn::theme() reads the tokens'.

No behaviour change: every section and every part's resolved classes
are identical before and after (checked with a throwaway dump).

Breaking: Tokens::with_palette, theme::warn_low_contrast and the
Shadcn::theme field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
Stage 2 of the shadcn-only epic. Core fills every section from shadcn's
tokens; the preset only writes its generated look over them.

- Style::new(&Tokens) fills every section the way Shadcn::style() did
  (it moves here from the preset), in the tokens' theme, and writes the
  widgets' own rules once, at the defaults layer. It carries the tokens'
  font as the Fonts extension. Style::default() is Vega neutral light.
- Style::write_look(|sheet| ..) sets the preset layer, runs the closure,
  then writes the recorded exceptions; write_exceptions is private.
  Shadcn::style() is Style::new, write_look over the generated sheets,
  the field sizes and its two own rules, and the disclosure exceptions.
- A layout with no style of its own draws with Style::default() in
  egui's fonts (no font, control and label weights Normal), built once;
  it gives egui nothing, as before.
- The 10 sections that had only getters and setters (label, checkbox,
  radio, switch, segmented, select, menu, tooltip, input, table) are pub
  fields; their getters go.
- size::{ICON, SM, XS, ..} move to eggshell_ui::theme::size; the shadcn
  crate re-exports them.
- TablePart::last_row() and TablePart::striped_row(), beside
  first_column(), so an app can rule the last row or a stripe.
- src/legacy_defaults.rs feeds the XDefaults writers from egui's default
  visuals, so the Defaults layer under the preset is unchanged; it is
  marked `#497 stage 3: delete`. 31 section fields that only feed rule
  writers or exceptions are marked `#497 stage 3: move`/`delete`.

Deleted: Style::from_egui, the from_egui of ScrollStyle, SplitterStyle,
TableStyle and Tones, Style::derived's egui path, restyle,
rewrite_rules, the 10 section setters (set_select, set_input, set_menu,
set_table, set_label, set_checkbox, set_radio, set_switch,
set_segmented, set_tooltip), and the unused Sheet::set_layer and
has_rules_at.

Behaviour: under the preset nothing changes. Every section, extras
extension, egui style and part's resolved classes are identical before
and after (Vega/Lyra x light/dark, style() and layout_style()), and no
golden moved. Without a preset, a style is now Vega light, not egui's
look: its sections, motion and tones are shadcn's.

Tests deleted (they pinned the egui-derived look or the restyle path):
contract::core_draws_a_button_with_no_preset,
contract::the_neutral_input_maps_to_egui_s_own_text_edit_style,
numbers::an_infinite_egui_tooltip_delay_is_the_longest_duration,
tone::the_egui_style_takes_egui_s_warning_colour,
tone::the_egui_style_s_tones_pass_aa_but_for_the_listed_misses,
tooltips::the_neutral_style_takes_its_timing_and_width_from_egui,
owned_choice::the_neutral_style_draws_the_chosen_cell_in_egui_s_active_fill,
owned_choice::a_modified_style_changes_every_owned_widget,
menu_sheet::without_a_preset_the_highlighted_item_takes_egui_s_selection_fill,
modal::style::the_neutral_scrim_is_egui_modals_and_the_presets_is_black_at_half,
style::a_new_text_role_reaches_the_widgets_own_looks,
style::a_section_metric_an_exception_reads_lands_after_the_preset.

Breaking: the deleted items above; the sections' getters (now fields);
eggshell_ui_shadcn::size is a re-export.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant