class
UI::DesignTokens::Tokens
- UI::DesignTokens::Tokens
- Reference
- Object
Overview
Top-level token aggregate. Held immutable: #with_brand returns a new
Tokens rather than mutating self.
Defined in:
ui/design_tokens.crConstructors
-
.default : Tokens
The canonical built-in brand.
- .new(colors_light : ColorPalette, colors_dark : ColorPalette, spacing : SpacingScale, type : TypeScale, radius : RadiusScale, shadow : ShadowScale, motion : MotionScale, breakpoints : Breakpoints, material : Material = Defaults.material, touch_target_minimum_px : Float64 = 44.0)
Instance Method Summary
- #breakpoints : Breakpoints
- #colors_dark : ColorPalette
- #colors_light : ColorPalette
-
#copy_with(colors_light : ColorPalette = @colors_light, colors_dark : ColorPalette = @colors_dark, spacing : SpacingScale = @spacing, type : TypeScale = @type, radius : RadiusScale = @radius, shadow : ShadowScale = @shadow, motion : MotionScale = @motion, breakpoints : Breakpoints = @breakpoints, material : Material = @material, touch_target_minimum_px : Float64 = @touch_target_minimum_px) : Tokens
Returns a new
Tokenswith the given fields replaced; everything else is shared by reference (all referenced types are records, so sharing is safe). -
#lookup(path : String) : Color | Float64 | Int32 | String | TypeStep | Nil
Look up a single token by dotted path.
-
#material : Material
Glass material token branch (Phase 5).
- #motion : MotionScale
- #radius : RadiusScale
- #shadow : ShadowScale
- #spacing : SpacingScale
-
#touch_target_minimum_px : Float64
Minimum interactive target size in CSS pixels.
- #type : TypeScale
-
#with_brand(brand : Brand) : Tokens
Apply a
Brandoverride on top of self.
Constructor Detail
The canonical built-in brand. Transcribed from
src/components/css/tokens/amber_theme.cr (OKLCH source values).
Instance Method Detail
Returns a new Tokens with the given fields replaced; everything else
is shared by reference (all referenced types are records, so sharing is
safe).
Look up a single token by dotted path. Used by debug tooling. Unknown paths return nil.
Examples: tokens.lookup("colors.light.brand_primary") # => Color tokens.lookup("spacing.x4") # => Float64 tokens.lookup("radius.md") # => Float64 tokens.lookup("type.body.size") # => Float64
Glass material token branch (Phase 5). Carries the five
MaterialStep values + an intensity scalar consumers re-render to
observe — Phase 5 explicitly does NOT add a runtime mutator path
(see I-2 preserves in the Phase 5 brief).
Minimum interactive target size in CSS pixels. Phase 2 consumes this
to enforce WCAG 2.2 AA touch targets and to derive the lower bound
of clamp() expressions for tappable controls. Default 44.0 per
WCAG / Apple HIG.