module UI::DesignTokens

Overview

Unified design-token model. This is the single source of truth for all Tier 1 brand decisions in the asset_pipeline cross-platform UI system.

The model is platform-agnostic: scalars are stored in Float64 rem-equivalent units (1 rem = 16 logical points) and colors are stored with both an OKLCH triple (the canonical source) and a precomputed RGBA bake (used by native renderers that have no OKLCH support).

Three generators consume this model:

copy_with policy

All record-based aggregate types in this module rely on the Crystal record macro's auto-generated copy_with method. This was verified on the pinned compiler version (Crystal 1.20.0) — the brand override surface in Brand#apply and any consumer-side palette.copy_with(brand_primary: …) call paths depend on it. If a future compiler upgrade drops copy_with from record, hand-roll one per type — ColorPalette, SpacingScale, TypeScale, TypeStep, RadiusScale, ShadowScale, ShadowLevel, MotionScale, Breakpoints — taking keyword arguments matching the record fields. Tokens itself is a class with its own copy_with.

Defined in:

ui/design_tokens.cr
ui/design_tokens/conversion.cr
ui/design_tokens/generators/apple_generator.cr
ui/design_tokens/generators/web_generator.cr
ui/design_tokens/material.cr