Skip to content

feat(ui): author the caption/data type-scale tier (batch 1 of #7844)#8053

Merged
JSONbored merged 1 commit into
mainfrom
type-scale-tokens-7844
Jul 24, 2026
Merged

feat(ui): author the caption/data type-scale tier (batch 1 of #7844)#8053
JSONbored merged 1 commit into
mainfrom
type-scale-tokens-7844

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

#7808 converted every UPPERCASE eyebrow label to mg-type-micro/mg-type-label, but the bare-arbitrary-text-size guardrail still reports ~1,181 warnings in apps/ui (52 in ui-kit) — the bulk being body-adjacent sizes that have no utility class to reach for: text-[12px] and text-[13px], plus widespread font-mono text-[10px]/[11px] data/numeric text (timestamps, hashes, tabular values) that #7808 deliberately left alone since it isn't the uppercase-label idiom.

This is batch 1 of #7844 ("Batch PRs — utilities first, then sweeps"): tokens + utility classes + the classification pass, no .tsx sites converted yet.

New utilities (packages/ui-kit/src/styles.css)

  • --mg-type-caption (12px) / .mg-type-caption — sans, line-height 1.45
  • --mg-type-caption-lg (13px) / .mg-type-caption-lg — sans, line-height 1.5
  • .mg-type-data — mono, 11px, line-height 1.4, no uppercase/tracking
  • .mg-type-data-sm — mono, 10px, line-height 1.35, no uppercase/tracking

The mono pair is deliberately not uppercase/tracked, unlike mg-type-micro/label — that distinction is exactly why #7808 correctly skipped these sites.

Classification pass (2026-07-24, both packages)

Bucketed every text-[10px]/[11px]/[12px]/[13px] site by whether font-mono co-occurs on the same class string (the mono/sans split heuristic — data/data-sm vs caption/caption-lg):

Size apps/ui total mono → data/data-sm non-mono → caption/caption-lg
text-[10px] 295 198 97
text-[11px] 582 412 170
text-[12px] 231 127 104
text-[13px] 47 8 39

ui-kit adds its own smaller counts on top (22/31/9/5 respectively). Combined text-[12px] + text-[13px] across both packages = 240 + 52, matching the issue's own 2026-07-24 baseline exactly.

Follow-up sweep PRs will convert by directory, carrying the same per-site line-height-regression check the issue calls out: today's bare text-[12px] inherits its container's line-height, while .mg-type-caption sets its own (1.45) — a dense table row may need an explicit leading-* override or become a documented exception rather than silently reflowing.

Verification

  • tsc --noEmit clean in both packages
  • eslint . (full package) — 0 errors, warning counts unchanged (this PR adds no .tsx conversions, so nothing should drop yet)
  • vitest run — 191 files / 1465 tests in apps/ui, 16 files / 88 tests in ui-kit, all passing
  • packages/ui-kit rebuilt (dist/index.css)
  • Live preview: getComputedStyle confirms all four new classes resolve to their intended font-size/line-height/font-family

Part of #7844

#7808 converted every UPPERCASE eyebrow label to mg-type-micro/mg-type-label,
but the bare-arbitrary-text-size guardrail still reports ~1,181 warnings in
apps/ui (52 in ui-kit) -- the bulk being body-adjacent sizes that have no
utility class to reach for: text-[12px] x240 and text-[13px] x52 combined
across both packages, plus widespread font-mono text-[10px]/[11px]
data/numeric text (timestamps, hashes, tabular values) that #7808
deliberately left alone since it isn't the uppercase-label idiom.

Adds four utilities to packages/ui-kit/src/styles.css:
- --mg-type-caption (12px) / .mg-type-caption -- sans, line-height 1.45
- --mg-type-caption-lg (13px) / .mg-type-caption-lg -- sans, line-height 1.5
- .mg-type-data -- mono, 11px, line-height 1.4, no uppercase/tracking
- .mg-type-data-sm -- mono, 10px, line-height 1.35, no uppercase/tracking

Classification pass (2026-07-24, both packages, same-line font-mono
co-occurrence as the mono/sans split heuristic):

| Size | Total | mono (-> data/data-sm) | non-mono (-> caption/caption-lg) |
|---|---|---|---|
| text-[10px] | 295 | 198 | 97 |
| text-[11px] | 582 | 412 | 170 |
| text-[12px] | 231 | 127 | 104 |
| text-[13px] | 47 | 8 | 39 |

(ui-kit has its own smaller counts on top: 22/31/9/5 respectively.)

This PR is utilities-only, per the issue's own "batch PRs (utilities first,
then sweeps)" plan -- no .tsx sites converted yet. Follow-up PRs will sweep
by directory, with the same per-site line-height-regression check the issue
calls out (today's bare text-[12px] inherits line-height; mg-type-caption
sets one, so a dense table row needs an explicit leading-* override or
becomes a documented exception).

Verified via getComputedStyle: all four classes resolve to their intended
font-size/line-height/font-family.

Part of #7844
@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
metagraphed-ui 8cad937 Commit Preview URL

Branch Preview URL
Jul 24 2026, 09:21 PM

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.68%. Comparing base (bc3e949) to head (8cad937).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8053   +/-   ##
=======================================
  Coverage   97.68%   97.68%           
=======================================
  Files         220      220           
  Lines       27246    27246           
  Branches    10805    10805           
=======================================
  Hits        26614    26614           
  Misses        140      140           
  Partials      492      492           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit ac29181 into main Jul 24, 2026
11 checks passed
@JSONbored
JSONbored deleted the type-scale-tokens-7844 branch July 24, 2026 21:32
JSONbored added a commit that referenced this pull request Jul 24, 2026
… scale (#8077)

Converts every text-[12px]/[13px] site (both packages, unconditional -- the
caption/caption-lg tiers don't touch font-family, so any existing font-mono
class stays valid alongside them) and every mono-context text-[10px]/[11px]
site (detected by font-mono co-occurring on the same class string; the
redundant font-mono utility is dropped since mg-type-data/data-sm already
set that font-family) onto the four utilities #8053 authored.

Non-mono text-[10px]/[11px] sites are left untouched -- no token exists for
a sans 10/11px tier in this design system, and forcing them into caption
(12px, a size up) or data/data-sm (which would incorrectly switch them to
mono) would both be real visual regressions. These are the "genuine
exception" bucket the issue's own classification pass calls for; the
warn-tier guardrail added in #8053 continues to flag them as a residual
worklist, same convention every other token rule in this codebase uses.

Result: apps/ui's bare-arbitrary-text-size warning count drops from the
1,181 baseline to 301 (-74.5%, well past the issue's >=60% target).
ui-kit drops from 52 to 44.

Verified: tsc clean, eslint 0 errors, prettier clean, vitest green (1465
tests in apps/ui, 88 in ui-kit) in both packages; packages/ui-kit rebuilt.
Live preview: getComputedStyle confirms all four mg-type-* classes resolve
to their intended font-size/line-height/font-family on real rendered
content (a subnet detail page), and a visual spot-check showed no layout
regression.

Closes #7844
@JSONbored JSONbored mentioned this pull request Jul 25, 2026
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