Repository navigation
feat(themes): pin type scale on touch + narrow viewports - #6699
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression42 of 448 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 22 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
This change pins the type scale of the four 14px-base themes (neutral, chocolate, butter, stone) on touch + narrow viewports, and the implementation checks out against the theme adaptation contract — the condition, the re-derived ratios, the pinned Display 1, and the unchanged desktop scale are all covered by the new per-theme tests.
Approval needs a maintainer decision first. The adaptation spec covers the mechanism, but it expressly leaves adding adaptation rules to bundled themes and choosing product-specific values out of scope, and the existing 16px floor in the specs is scoped to iOS text entry. So a maintainer needs to provide or identify the governing spec for this addition — a theme-level 16px floor for all type roles on coarse-pointer viewports under 768px (including non-iOS devices), Display 1 as the pin anchor, and the re-derived ratios for these four themes — or update the existing spec. Once that is settled, the change can be judged on its merits; nothing here asks for the change to be removed or split in the meantime.
One fix is needed regardless: the CLI theme bundle copies were not regenerated, so astryx theme add scaffolds of the four themes would not include the new rule, and the bundle drift check fails for exactly those four themes. Running pnpm bundle:cli-themes and committing the regenerated bundle resolves it.
[Automated review]
e39c09f to
00e74d3
Compare
There was a problem hiding this comment.
This change pins the type scale of the four 14px-base themes (neutral, chocolate, butter, stone) on touch + narrow viewports, and the implementation checks out against the theme adaptation contract — the condition, the re-derived ratios, the pinned Display 1, and the unchanged desktop scale are all covered by the new per-theme tests, and the rendered result was reproduced in Chromium at a phone viewport (body 14px → 16px, Display 1 unchanged). The CLI theme bundle copies are also regenerated, so scaffolded themes carry the same rule.
Approval needs a maintainer decision first. The adaptation spec covers the mechanism, but it expressly leaves adding adaptation rules to bundled themes and choosing product-specific values out of scope, and the existing 16px floor in the specs is scoped to iOS text entry. So a maintainer needs to provide or identify the governing spec for this addition — a theme-level 16px floor for all type roles on coarse-pointer viewports under 768px (including non-iOS devices), Display 1 as the pin anchor, and the re-derived ratios for these four themes — or update the existing spec. Once that is settled, the change can be judged on its merits; nothing here asks for the change to be removed or split in the meantime.
[Automated review]
Mobile Type (Pin model): under (width < 768px) and (pointer: coarse), the 14px-base themes floor their type base to 16px and re-derive the ratio so Display 1 (the recommended anchor for ratio <= 1.25) holds its desktop size. - neutral, chocolate: base 14 -> 16, ratio 1.2 -> 1.1736 (display-1 42px) - butter, stone: base 14 -> 16, ratio 1.25 -> 1.2225 (display-1 53px) - gothic, matcha, y2k are already base 16; their pinned ladder equals their desktop ladder, so they need no adaptation rule. Desktop scales are unchanged. Body/label/code rise 14px -> 16px to match the existing 16px coarse-pointer input floor.
00e74d3 to
9057ebe
Compare
There was a problem hiding this comment.
This change pins the type scale of the four 14px-base themes (neutral, chocolate, butter, stone) on touch + narrow viewports, and the implementation checks out against the theme adaptation contract — the condition, the re-derived ratios, the pinned Display 1, and the unchanged desktop scale are all covered by the new per-theme tests, and the rendered result was reproduced in Chromium at a phone viewport (body 14px → 16px, Display 1 unchanged). The CLI theme bundle copies are also regenerated, so scaffolded themes carry the same rule.
Approval needs a maintainer decision first. The adaptation spec covers the mechanism, but it expressly leaves adding adaptation rules to bundled themes and choosing product-specific values out of scope, and the existing 16px floor in the specs is scoped to iOS text entry. So a maintainer needs to provide or identify the governing spec for this addition — a theme-level 16px floor for all type roles on coarse-pointer viewports under 768px (including non-iOS devices), Display 1 as the pin anchor, and the re-derived ratios for these four themes — or update the existing spec. Once that is settled, the change can be judged on its merits; nothing here asks for the change to be removed or split in the meantime.
[Automated review]
kentonquatman
left a comment
There was a problem hiding this comment.
Change looks good from the design side 👍
…6771) * docs(specs): add AST-049 mobile typography spec (draft) * docs(specs): make AST-049 plan concise * docs(specs): make AST-049 concise and spec-only * docs(specs): define Pin targets by desktop ratio * docs(specs): minimise AST-049 to the sourced Pin rule * docs(specs): make AST-049 a minimal normative spec * docs(specs): add rubyycheung as AST-049 co-owner * docs(specs): address Ruby review on AST-049 * docs(specs): use lg breakpoint for AST-049 mobile predicate
AST-049 as merged sets the mobile condition to (width < 1024px) and (pointer: coarse) — the effective lg breakpoint, upper edge exclusive — instead of md/768px. Update the four 14px-base themes' adaptation rules, their tests, the changeset text, and the regenerated CLI theme templates. Pin math is unchanged: both ratios (1.2, 1.25) stay in the r <= 1.25 branch pinning Display 1 at +6.
There was a problem hiding this comment.
This change pins the type scale of the four 14px-base themes (neutral, chocolate, butter, stone) on touch + narrow viewports, and the implementation checks out against the theme adaptation contract — the condition, the re-derived ratios, the pinned Display 1, and the unchanged desktop scale are all covered by the new per-theme tests, the CLI theme bundle copies are regenerated and in sync, and the rendered result was reproduced in Chromium at phone, portrait-tablet (900px), boundary (1024px), and desktop widths (body 14px → 16px where the condition matches, Display 1 unchanged, no pin at or above 1024px).
Approval needs a maintainer decision first. The adaptation spec covers the mechanism, but it expressly leaves adding adaptation rules to bundled themes and choosing product-specific values out of scope, and the existing 16px floor in the specs is scoped to iOS text entry. The new spec proposed alongside this change is still a draft with approval pending, so a maintainer needs to provide or identify the governing spec for this addition — a theme-level 16px floor for all type roles on coarse-pointer viewports below 1024px (including whether it applies beyond iOS), Display 1 as the pin anchor, and the re-derived ratios for these four themes — or update the existing spec. Once that is settled, the change can be judged on its merits; nothing here asks for the change to be removed or split in the meantime.
One tiny wording fix can ride along: the proposed spec still says this PR changes only the specification, which is no longer accurate now that the spec and the implementation travel together.
[Automated review]
There was a problem hiding this comment.
This change pins the type scale of the four 14px-base themes (neutral, chocolate, butter, stone) on touch + narrow viewports. The implementation lines up with the theme adaptation contract on static checking — the condition, the re-derived ratios, the pinned Display 1, the unchanged desktop scale asserted in the new per-theme tests, and CLI theme bundle copies that match their sources byte-for-byte, so scaffolded themes carry the same rule.
Approval needs a maintainer decision first. The adaptation spec covers the mechanism, but it expressly leaves adding adaptation rules to bundled themes and choosing product-specific values out of scope, and the existing 16px floor in the specs is scoped to iOS text entry. The new spec proposed alongside this change travels inside the PR and is not yet the governing record on main, so a maintainer needs to provide or identify the governing spec for this addition — a theme-level 16px floor for all type roles on coarse-pointer viewports below 1024px (including whether it applies beyond iOS), Display 1 as the pin anchor, and the re-derived ratios for these four themes — or update the existing spec. Once that is settled, the change can be judged on its merits; nothing here asks for the change to be removed or split in the meantime.
[Automated review]
There was a problem hiding this comment.
This change pins the type scale of the four 14px-base themes (neutral, chocolate, butter, stone) on touch + narrow viewports. The implementation lines up with the theme adaptation contract on static checking — the condition, the re-derived ratios, the pinned Display 1, the unchanged desktop scale asserted in the new per-theme tests, and CLI theme bundle copies that match their sources byte-for-byte, so scaffolded themes carry the same rule.
Approval needs a maintainer decision first. The adaptation spec covers the mechanism, but it expressly leaves adding adaptation rules to bundled themes and choosing product-specific values out of scope, and the existing 16px floor in the specs is scoped to iOS text entry. The mobile-typography proposal that travelled with this PR was moved out in the latest commit and is not yet the governing record on main, so a maintainer needs to provide or identify the governing spec for this addition — a theme-level 16px floor for all type roles on coarse-pointer viewports below 1024px (including whether it applies beyond iOS), Display 1 as the pin anchor, and the re-derived ratios for these four themes — or update the existing spec. Once that is settled, the change can be judged on its merits; nothing here asks for the change to be removed or split in the meantime.
[Automated review]
There was a problem hiding this comment.
Approving. On narrow touch screens, the four 14px themes now raise body text to 16px and keep Display 1 at its desktop size, as the merged mobile typography record specifies.
- Values: I computed every step from 4xs to 5xl with the record's formula, using its exact pinned ratio and rounding halves up. Butter and stone (ratio 1.25) and neutral and chocolate (1.2) match at all twelve steps; the four-decimal ratios in the themes give the same pixels. Display 1 stays at 53px and 42px, and body goes from 14 to 16px. Gothic, matcha and y2k already start at 16px and correctly have no rule. The CLI templates carry the same rules, and regenerating them from the theme packages reproduces those files exactly.
- In Chrome with a touch pointer, the mobile sizes apply at 390 and 1023px and not at 1024 or 1280px. Without a touch pointer they never apply, and the root font size stays 16px throughout.
- Merged onto current main, where none of its files have changed, the theme and core theme tests (1,476) pass, the five built themes produce the expected rule, and the sync, Changeset, CLI-structure, lint and Prettier checks pass. The touch-pointer story guards added to main since the last CI run give identical results with and without this change.
[Automated review]
There was a problem hiding this comment.
The theme rules match the now-current mobile typography design record: the shipped ratios reproduce its ladder at every step, Display 1 keeps its desktop size, and the pin applies only to coarse pointers below 1024px. Before this can be approved, the [breaking] Changeset needs three corrections:
- Name app themes that extend these themes with their own
typography.scaleor type-size tokens: on touch + narrow screens the inherited rule replaces their values (a base-18 child drops to 16px body and 42px Display 1), so tell them to append their own rule for the same condition. - For butter and stone, the opt-out recipe should also write
'--text-supporting-size': '12px', because scale alone restores supporting text to 11px rather than the previous 12px. - Replace "the display tier no longer grows": only Display 1 holds, while Display 2 and 3, headings and supporting text grow by 1–2px.
[Automated review]
| '@astryxdesign/cli': minor | ||
| --- | ||
|
|
||
| [breaking] On touch devices narrower than the `lg` breakpoint (`(width < 1024px) and (pointer: coarse)`), the 14px-base first-party themes now floor their type base to 16px and re-derive the ratio so Display 1 keeps its desktop size: neutral and chocolate (base 14, ratio 1.2 → 1.1736) and butter and stone (base 14, ratio 1.25 → 1.2225). Body, label and code text rise from 14px to 16px on phones and the display tier no longer grows; desktop sizes are unchanged. gothic, matcha and y2k already use a 16px base and need no rule. The CLI's theme templates carry the same rule, so a newly scaffolded theme gets it too. |
There was a problem hiding this comment.
Only Display 1 keeps its desktop size here. Display 2 and 3 still grow 1–2px (neutral 35 → 36 and 29 → 30; butter 43 → 44 and 34 → 36), headings and supporting text grow too, and butter and stone supporting text moves from its 12px pin to 13px. Could this sentence say that Display 1 keeps its desktop size and every other role follows the pinned ladder?
|
|
||
| [breaking] On touch devices narrower than the `lg` breakpoint (`(width < 1024px) and (pointer: coarse)`), the 14px-base first-party themes now floor their type base to 16px and re-derive the ratio so Display 1 keeps its desktop size: neutral and chocolate (base 14, ratio 1.2 → 1.1736) and butter and stone (base 14, ratio 1.25 → 1.2225). Body, label and code text rise from 14px to 16px on phones and the display tier no longer grows; desktop sizes are unchanged. gothic, matcha and y2k already use a 16px base and need no rule. The CLI's theme templates carry the same rule, so a newly scaffolded theme gets it too. | ||
|
|
||
| Migration: nothing to change to take the new phone scale. To keep the previous 14px phone scale in an app, extend the theme and append a later rule for the same condition, which wins by order: `defineTheme({name: 'app', extends: neutralTheme, adaptations: {rules: [{when: {pointer: 'coarse', width: {below: 'lg'}}, value: {typography: {scale: {base: 14, ratio: 1.2}}}}]}})` (butter and stone: `ratio: 1.25`). A theme that already sets its own touch-and-narrow typography rule keeps it. This cannot be rewritten by a codemod: whether an app wants the floor is a product choice. |
There was a problem hiding this comment.
The migration has two gaps:
- App themes that
extendsone of these themes and set their owntypography.scaleor type-size tokens are affected too. On touch + narrow screens the inherited rule replaces their values (a base-18 child renders 16px body and 42px Display 1), so they need to append their own rule for the same condition. - For butter and stone,
scale: {base: 14, ratio: 1.25}alone restores supporting text to 11px (var(--font-size-sm)), not the previous 12px. The appended rule also needstokens: {'--text-supporting-size': '12px'}.
…pin supporting text in the butter/stone opt-out, and state which tiers grow
There was a problem hiding this comment.
Approving: on narrow touch screens the four 14px-base themes now raise body text to 16px while Display 1 keeps its desktop size, matching the current mobile typography design record at every step of the scale, and the rule applies only to coarse pointers below 1024px with the root font size, desktop output and CLI theme copies unchanged or in sync. The [breaking] Changeset now covers app themes that extend these themes and gives an opt-out that restores the previous phone sizes, including butter and stone's 12px supporting text. The one failing CI test is a CLI watch-mode test on an unrelated fixture theme that passes repeatedly against this revision outside CI, so rerunning that job should clear it.
[Automated review]
User impact
On a touch device in a narrow viewport (< 1024px, coarse pointer), every first-party theme with a 14px type base rendered body/label/code at 14px — below the 16px input minimum that applies only on iOS/WebKit when
(pointer: coarse)and@supports (-webkit-touch-callout: none)both match, to prevent zoom-on-focus — while the naive alternative (lifting the whole ladder to a 16px base at the desktop ratio) would have grown Display 1 from 42px to 48px (neutral/chocolate) or 53px to 61px (butter/stone) on a phone.This change applies the Mobile Type Pin model (sandbox explorer:
apps/sandboxMobile Type page, Pin strategy): floor the base to 16px, re-derive the ratio from the theme's own desktop scale so Display 1 — the mobile typography design proposal's pin target for ratio ≤ 1.25 (step +6) — holds its desktop size, and let every role between follow the pinned ladder.Full pinned ladder (px), neutral/chocolate: display 42/36/30, headings 26/22/19/16/14/12, body/label/code 16, large 19, supporting 14. Butter/stone: display 53/44/36, headings 29/24/20/16/13/11, body/label/code 16, large 20, supporting 13 (the pinned ladder supersedes butter/stone's desktop-only
--text-supporting-size: 12pxpin under this condition, per the adaptation contract that a declared scale's generated leaves are rule writes).Visual authority
Design spec: #6842 (docs/design/mobile-typography.md) — proposed base floor
M = max(B, 16)with1remas the 16px reference (no document-root change), the ratio-to-target table (both ratios here fall in ther ≤ 1.25→ Display 1, step+6branch), and the mobile condition on the effectivelgbreakpoint (stock 1024 CSS px, upper edge exclusive, governed byspec:AST-012). Mechanism:spec:AST-012(Theme adaptations, current) — one ordered rulewhen: {pointer: 'coarse', width: {below: 'lg'}}, compiled to@media (width < 1024px) and (pointer: coarse), CSS-first with runtime/built parity. Values: the Mobile Type explorer's Pin derivation above; 16px floor matches the existing iOS/WebKit input minimum in core, gated by both(pointer: coarse)and@supports (-webkit-touch-callout: none).Design approval: rubyycheung on #6771 (2b88483)
Before and after
Real Chromium (Playwright, 390px, touch/mobile context so
(pointer: coarse)and(width < 1024px)both match), neutral theme built CSS, same sample card — before = built CSS with the adaptation block removed, after = this PR:Before/after screenshots were captured from the same harness (390px card, body text visibly larger, display headline identical); the computed probe above is the machine-checked form of that evidence.
State matrix
--font-size-basestays 0.875rem,--font-size-5xlstays at desktop display-1).lgcutoff.Sarinadisplay pins): preserved. The generated adaptation media block writes tokens only — invariant type-scale component rules are omitted per fix(theme): preserve component overrides in type-scale adaptations #6710 (merged,039a67ea539), so butter's rootfont-family: Sarinapins for display-1/2/3 are no longer clobbered under touch + narrow. Verified on this branch rebased onto that main: the built buttertheme.cssmedia block contains nofont-familydeclaration and the root Sarina pins are intact.Scope
Testing
*Theme.test.tsfor neutral/chocolate/butter/stone) assert the rule condition, the media query(width < 1024px) and (pointer: coarse), pinned tokens (base 1rem, display-1 token identical to desktop), and that desktop tokens are untouched: 4 files, 15 tests passed (pnpm vitest run --project=node).pnpm -F @astryxdesign/theme-{neutral,chocolate,butter,stone} build— all build; builttheme.csscontains exactly one adaptation media block with the pinned ladder.pnpm check:changesets,eslintandprettier --checkon all touched files — pass.pnpm bundle:cli-themesregenerated: the CLI's bundled theme copies carry the same adaptation blocks, satisfying the drift guard (scripts/check-cli-theme-bundle.test.mjs— 7 themes pass).packages/core/src/theme/themeAdaptations.test.ts— 55 tests passed; butter rebuilt and its media block re-inspected (token writes only, no componentfont-familyrules).lg-cutoff verification (per design:mobile-typography): 4 theme suites re-run — 15 tests pass; CLI bundle drift guardscripts/check-cli-theme-bundle.test.mjs— 15 tests pass; core + 4 themes rebuilt, each builttheme.cssre-inspected — exactly one@media (width < 1024px) and (pointer: coarse)block, token writes only, zero768remnants, butter root Sarina pins intact; grep across the PR's changed files for768/below: 'md'— zero hits.Brought to mergeable for 0.7.0 (maintainer, 2026-10-12)
mainmerged in (no conflicts); Ivor's commits and credit are preserved.design:mobile-typographyDR1–DR3 (merged). The four rules match DR2's table exactly: r ≤ 1.25 → Display 1 pinned at step +6, sor_pin = r·(14/16)^(1/6)= 1.1736 for neutral/chocolate and 1.2225 for butter/stone; activation is DR3's(width < lg) and (pointer: coarse).[breaking](a visible change for existing apps on touch + narrow) for the four theme packages and the CLI (its theme templates carry the rule), with a migration: extend the theme and append a later rule for the same condition to keep the 14px phone scale.check:changesetsvalid under the declared 0.7.0;check:syncclean.(pointer: coarse)at 390px, light and dark, all four themes: body 14 → 16px, large 17 → 19px (neutral/chocolate) and 18 → 20px (butter/stone), supporting 12 → 14/13px; a 1280px fine-pointer viewport is unchanged. Private evidence: https://artifacts.internalmeta.com/a/893496983731812