P5.2 — Generative typography/motion/radius scale primitives#113
Merged
Conversation
Add typestyles/token-scale subpath with generateGeometricScale, generateLinearScale, and expandDurationBand — generic numeric ramp generators for font-size ladders, radius steps, and duration min/max bands. Pure numeric outputs with zero naming opinions in core. Spec: specs/type-motion-radius-scale-generation.md Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements P5.2 from
IMPROVEMENTS.mdperspecs/type-motion-radius-scale-generation.md(core-only scope — the design-system wiring lives in var-ui).What's new
New
typestyles/token-scalesubpath (packages/typestyles/src/token-scale.ts) with three generic numeric ramp generators, so a theme author writes 2-3 numbers instead of hand-picking a whole ladder:generateGeometricScale({ base, ratio, steps, round? })—base * ratio ** offsetfor each signed integer offset insteps(font-size-style modular ladders). Offset0always returns exactlybase.generateLinearScale({ base, multiplier, steps, round? })—base * step * multiplierfor each ordinal insteps(radius-style grid ladders).multiplier: 0is allowed (all zeros).expandDurationBand({ base, ratio, roundTo? })— expands one duration anchor into{ min, base, max }(min = base * ratio,max = base / ratio), rounded to the nearest 5ms by default so bands look hand-picked instead of computed (no93.75ms).Pure numeric outputs, zero naming opinions — no
fontSize/radius/fastvocabulary in core. Rounding defaults to whole numbers (Math.round), withround/roundTooverrides. Clear[typestyles]-prefixed errors guard non-finite inputs,ratio <= 0,roundTo <= 0, and non-integer geometric offsets.Wiring mirrors
typestyles/color-scale(P5.1): tsup entrysrc/token-scale-entry.ts, ESM+CJSexportsblock, separate subpath with zero impact on the main bundle (bundle-size check still passes: 16794 / 16900 budget). Docs added toapi-reference.mdandtheming-patterns.mdalongside the color-scale sections; changeset.changeset/p5-2-token-scale.md(typestyles: minor); P5.2 checked off inIMPROVEMENTS.md.Test evidence
pnpm test(packages/typestyles): 26 files / 381 tests passed (includes newtoken-scale.test.ts: 23 tests covering deterministic math, rounding defaults + overrides, step ordering, steps=1/empty edge cases, and zero/negative/non-finite guards)pnpm typecheck: passpnpm build: pass —dist/token-scale.{js,cjs,d.ts,d.cts}emitted; verifiedimport/requireoftypestyles/token-scaleboth resolve and return correct values at runtimepnpm lint: pass (1 pre-existing warning incolor-scale.test.ts, none in new code)🤖 Generated with Claude Code