Skip to content

Theme: one Tokens type, shadcn's, in core (#497 stage 1) - #498

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

samitbasu merged 2 commits into
mainfrom
shadcn-tokens-497

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Stage 1 of #497, the shadcn-only epic: one Tokens type.

What changes

  • shadcn's token types move into core as eggshell_ui::theme. The moves are git mvs, so history is kept, and eggshell-ui-shadcn re-exports every type. The types are Tokens, Palette, BaseColor, ThemeColor, ShadcnStyle, Elevation, HoverSurface, FontSet, ContrastPair, ContrastRatio and RegistryMiss.
  • Core's 32-field contract::Tokens and its from_egui are deleted, along with the preset's private core_tokens bridge. Every rule body now reads the one type.
  • Fields that existed only for egui's look now read from the shadcn tokens:
    • control_height → control_height()
    • button_padding → points_vec(button_padding)
    • text_size → control_text_size().size
    • switch_thumb → points(switch_thumb)
  • focus is now the method Tokens::focus(), computed from ring_width and ring at half opacity. disabled stays a field, defaulting to Disabled::Colors.
  • Fonts: Geist moves to src/fonts/. Core gains a fonts feature, off by default; the shadcn crate's fonts feature enables it.
  • The importer reads the colour token names from src/theme/tokens.rs. The regenerated sheets are byte-identical.
  • Style::from_egui's tokens are now Vega neutral light. Its sections still come from egui until stage 2.

Checks

  • cargo xtask integrate: green.
  • No golden moved: 229 passed, and nothing is new or changed under tests/snapshots.
  • No tests were deleted. Tests that overrode the removed fields now set the shadcn tokens instead.

Public API

  • Removed: contract::Tokens and its from_egui.
  • Added:
    • the theme module;
    • Tokens::focus();
    • Tokens::disabled;
    • FontSet::declared, install and inserts, Elevation::shadow and theme::warn_low_contrast, which were crate-private in the shadcn crate.

Prose

Left for the user:

  • TODO(prose) docs on the theme module, Elevation::shadow, Tokens::focus and Tokens::disabled;
  • the shadcn crate doc, which still says core has no shadcn names or values.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76

samitbasu and others added 2 commits November 24, 2026 11:41
Stage 1 of the shadcn-only epic starts by moving the token types, so the
one Tokens type can live where Style and every rule body are. Tokens,
Palette, BaseColor, ThemeColor, ShadcnStyle, Elevation, HoverSurface,
FontSet and the contrast check move from eggshell-ui-shadcn into
eggshell_ui::theme unchanged; the shadcn crate re-exports them, so
downstream paths keep working until the crate split.

The bundled Geist moves to src/fonts with its licence. Core grows a
`fonts` feature (off by default) for it; the shadcn crate's `fonts`
feature, still on by default, now forwards to it.

The items the preset reached as crate-private become public:
FontSet::{declared, install, inserts}, Elevation::shadow and
theme::warn_low_contrast.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKfuwuKXZxdwsSBxd76
Style::tokens is now theme::Tokens, shadcn's set, and every rule body
(`Fn(Tw, &Tokens) -> Tw`) and reader takes it. Core's 32-field
contract::Tokens, Tokens::from_egui and the preset's core_tokens bridge
are deleted; the preset hands Style its own tokens.

The fields core had that shadcn's did not:
- The four egui-only ones go; readers take what core_tokens mapped them
  from, so preset values are unchanged:
  control_height -> control_height(),
  button_padding -> points_vec(button_padding) (now spacing units),
  text_size -> control_text_size().size,
  switch_thumb -> points(switch_thumb).
- focus becomes Tokens::focus(), computed from ring_width and ring/50,
  which is what the preset set it to; a field could drift from them.
  Tests that override the ring set ring and ring_width.
- disabled stays, as a field of the one Tokens (default Colors):
  eggshell's own, like success and warning.

Style::from_egui keeps filling its sections from egui; its tokens are
shadcn Vega neutral light (Tokens::light()). Without a preset that moves
the token-read values: a mount's bare padding (focus clearance 4 -> 6),
the Defaults-layer rule colours, and egui_look's input. Under the preset
nothing changes, and no golden moved.

The importer reads the colour token names from src/theme/tokens.rs;
the regenerated sheets are byte-identical.

Tests changed, none deleted: egui_look::the_core_tokens_are_the_preset_s
becomes the_style_s_tokens_are_the_preset_s (whole equality); ring
overrides in field_box, owned_choice and owned set ring/ring_width;
egui_look and sheet tests set control_units / text.sm instead of the
egui-only fields; density compares button padding in points.

Breaking: eggshell_ui::contract::Tokens and Tokens::from_egui are gone
(use eggshell_ui::theme::Tokens); Tokens::focus is a method.

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