class UI::DesignTokens::Tokens

Overview

Top-level token aggregate. Held immutable: #with_brand returns a new Tokens rather than mutating self.

Defined in:

ui/design_tokens.cr

Constructors

Instance Method Summary

Constructor Detail

def self.default : Tokens #

The canonical built-in brand. Transcribed from src/components/css/tokens/amber_theme.cr (OKLCH source values).


[View source]
def self.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) #

[View source]

Instance Method Detail

def breakpoints : Breakpoints #

[View source]
def colors_dark : ColorPalette #

[View source]
def colors_light : ColorPalette #

[View source]
def 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 Tokens with the given fields replaced; everything else is shared by reference (all referenced types are records, so sharing is safe).


[View source]
def lookup(path : String) : Color | Float64 | Int32 | String | TypeStep | Nil #

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


[View source]
def material : Material #

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).


[View source]
def motion : MotionScale #

[View source]
def radius : RadiusScale #

[View source]
def shadow : ShadowScale #

[View source]
def spacing : SpacingScale #

[View source]
def touch_target_minimum_px : Float64 #

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.


[View source]
def type : TypeScale #

[View source]
def with_brand(brand : Brand) : Tokens #

Apply a Brand override on top of self. Returns a NEW Tokens — never mutates self. Phase 6's consumer-side override path lands here.


[View source]