Skip to content

refactor(ui): wire the dimension classes to their tokens, and guard the token files - #184

Draft
renefloor wants to merge 3 commits into
chore/prune-unused-tokensfrom
chore/wire-dimension-tokens
Draft

refactor(ui): wire the dimension classes to their tokens, and guard the token files#184
renefloor wants to merge 3 commits into
chore/prune-unused-tokensfrom
chore/wire-dimension-tokens

Conversation

@renefloor

Copy link
Copy Markdown
Collaborator

Third in the stack: #182#183 → this. Base is chore/prune-unused-tokens, so the diff is only the wiring.

Why this exists

StreamSpacing, StreamRadius and StreamTokensTypography hard-coded the same numbers the vendored token files already held. The design system's dimensions were mirrored twice, with nothing tying the copies together — the swatch-versus-baked-hex hazard one layer up, where an upstream change gets applied to one and not the other in silence.

An earlier revision of #183 deleted those 180 unread constants instead. That removed the evidence of the gap rather than the gap, which is why they came back here and got wired.

What changed

The three classes now read their tokens. The type ramp gains most:

height: 1.1111111111111112,                       // before
height: StreamTokensDimensions.typographyLineHeightNormal /
        StreamTokensDimensions.typographyFontSizeLg,   // after

which says what the number is. All five ratios resolve bit-identically, so no golden moves — flutter test is +397 -56, matching the baseline exactly.

New internal/tokens/stream_tokens_dimensions.dart sits beside the existing mode-independent typography file rather than under light//dark/, because the token repo publishes one set of dimensions for every mode — all 180 constants were byte-identical between the two files. Values come from the web flavor, the only one carrying the Geist family this package ships. Typed double so they satisfy Radius, EdgeInsets and TextStyle directly.

Two tokens are deliberately not carried, because nothing can read them: font weights, since TextStyle.fontWeight takes a FontWeight that cannot be built from a number in a const expression; and radiusNone, since the analyzer's use_named_constants prefers Radius.zero over circular(0). Both are noted where they would otherwise puzzle a reader.

The guard

scripts/check_tokens.dart, wired as melos run check:tokens next to check:barrels in the same CI step. It fails when a vendored constant is never referenced, and when light/ and dark/ disagree about which constants exist — the second because a field resolving from a constant in one mode but not the other silently falls back instead of failing.

It earned its place while being written: it caught radiusNone having no reader, and a stale directory-wide skip that was hiding the typography file's own reads. Both failure modes were also verified by introducing them deliberately and watching it exit 1.

✓ 163 color tokens and 31 dimension tokens, all referenced, light/ and dark/ in agreement.

The allowlist is intentionally empty.

Verification

analyze clean across all four packages; format:verify, check:barrels and check:tokens pass; flutter test +397 -56, identical to baseline.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.57%. Comparing base (c662af3) to head (ad73473).

Files with missing lines Patch % Lines
...ives/internal/tokens/stream_tokens_dimensions.dart 0.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                      Coverage Diff                      @@
##           chore/prune-unused-tokens     #184      +/-   ##
=============================================================
- Coverage                      68.57%   68.57%   -0.01%     
=============================================================
  Files                            210      211       +1     
  Lines                           8593     8594       +1     
=============================================================
  Hits                            5893     5893              
- Misses                          2700     2701       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renefloor
renefloor added this pull request to stack #185 September 10, 2026 12:29
@renefloor
renefloor force-pushed the chore/wire-dimension-tokens branch from 8c4696c to 5a8684e Compare September 10, 2026 12:43
renefloor and others added 3 commits September 10, 2026 16:37
StreamSpacing, StreamRadius and StreamTokensTypography hard-coded the
same numbers the vendored token files already held, so the design
system's dimensions were mirrored twice with nothing tying the copies
together — the swatch-versus-baked-hex hazard one layer up, where an
upstream change can be applied to one and not the other in silence.

The three classes now read the tokens. The type ramp gains from it:
`height: 1.1111111111111112` becomes
`typographyLineHeightNormal / typographyFontSizeLg`, which says what
the number is instead of leaving a magic constant. Every ratio resolves
bit-identically, so no golden moves.

Adds internal/tokens/stream_tokens_dimensions.dart, beside the
mode-independent typography file rather than under light/ and dark/,
because the token repo publishes one set of dimensions for every mode —
all 180 constants were byte-identical between the two files. Values
come from the web flavor, the only one carrying the Geist family this
package ships. They are typed `double` so they satisfy Radius,
EdgeInsets and TextStyle directly.

Two tokens are deliberately not carried, since nothing can read them:
font weights, because TextStyle.fontWeight takes a FontWeight that
cannot be built from a number in a const expression, and radiusNone,
because the analyzer's use_named_constants prefers Radius.zero over
circular(0).

Also extends check_tokens.dart to hold the dimension file to the same
rule, which is what caught radiusNone and a stale skip that hid the
typography file's own reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The skill still said the dimension classes hard-code their values and
that a change has to be applied to them by hand, which this branch
makes false. It now says a dimension is a value edit in
stream_tokens_dimensions.dart and the classes follow, records why font
weights and radiusNone are absent, and names melos run check:tokens as
what enforces the rule — so there is no judgment call about what
belongs in a token file.

Also brings three now-stale details in line: the file table gains the
dimensions row, the reader list gains the three dimension classes, and
After editing runs check:tokens next to analyze.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The skill gained this in the previous commit, but CLAUDE.md still described
`StreamSpacing`, `StreamRadius` and `StreamTokensTypography` as hard-coding
their values, which this PR is what changes. It now points at
`stream_tokens_dimensions.dart` and at `check:tokens`, so the repo overview and
the skill agree.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@renefloor
renefloor force-pushed the chore/wire-dimension-tokens branch from 5a8684e to ad73473 Compare September 10, 2026 14:39
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