Skip to content

feat(sandbox): Mobile Type explorer tool page - #4883

Merged
rubyycheung merged 10 commits into
mainfrom
feat/mobile-type-explorer
Aug 12, 2026
Merged

rubyycheung merged 10 commits into
mainfrom
feat/mobile-type-explorer

Conversation

@rubyycheung

@rubyycheung rubyycheung commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a fullscreen Mobile Type sandbox tool for exploring how the Astryx type scale adapts on touch devices. Styled to match the docsite playground theme editor (Layout/LayoutPanel, SegmentedControl, unprefixed @astryxdesign/core components).

This is an exploration tool for the mobile web typography strategy — it does not change any shipped tokens or component behavior. Desktop output is byte-identical.

What it shows

Desktop column is the fixed reference, computed with the exact same geometric progression as expandTypeScale (round(base × ratio^step)) and seeded from the playground default (base 14, ratio 1.2). Verified to match the real expandTypeScale output role-for-role.

Mobile adaptation is a master switch with three strategies:

  • Lift (default) — floor body to the 16px readability minimum and rebuild the whole ladder at the full desktop ratio. Nothing is pinned, so the display tier stays large and dramatic (D1 42→48).
  • Pin — hold an anchor role (H1 by default) at its desktop size and re-derive a tamer ratio so headings don't balloon (D1 42→37, H1 held at 24).
  • Custom — hand-tune each role's mobile size, seeded from the pinned scale with a Reset.

Recommended pin anchor (scale-aware)

When Pin is selected, the tool recommends an anchor based on the current desktop ratio and surfaces it two ways: a Recommended badge on that option in the dropdown, and an inline hint with a Use button (visible without opening the menu). The recommendation auto-hides once the selected anchor matches it.

The rationale: gentle scales can pin high because the whole ladder is already close together (pinning Display 1 barely tames anything), while dramatic scales need a lower anchor so the display tier doesn't tower over 16px body text on a phone.

Desktop scale (ratio) Recommended anchor
up to Major Third (≤ 1.25) Display 1
Perfect Fourth (1.333) Heading 2
Augmented Fourth → Golden Ratio (≥ 1.414) Heading 3

This is a starting recommendation, not a lock — any anchor stays selectable.

Real-component preview renders the same set of Astryx components (Heading, Text, Badge, Avatar, Button, Divider, Code) at both scales. The mobile side sits in a phone frame with the raw --font-size-* tokens overridden — a live demonstration of the token-layer mechanism a shipped implementation would use (semantic tokens are var() refs to the raw scale, so overriding the raw tokens cascades into every component with zero per-component change).

Why 16px

The 16px floor is explained inline in the tool: it matches the existing input behavior, where 8 Astryx input components already bump to 16px under @media (pointer: coarse) to stop mobile browsers auto-zooming on focus. Flooring body to match keeps text and inputs on the same scale.

Files

  • apps/sandbox/src/app/(sandbox)/pages/mobile-type/page.tsx — new tool page
  • apps/sandbox/src/app/SandboxShell.tsx — register /pages/mobile-type as fullscreen
  • apps/sandbox/src/app/sandboxPages.ts — add page under Tools

Checks

Typecheck, ESLint, and all pre-commit repo checks (sync, package-boundaries, changesets, demo-media, executable-bits, cli-structure) pass. Page renders 200. All three modes verified with screenshots.

Status

Exploration tool for review. Follow-ups (separate PRs): proposal doc, then the actual expandTypeScale + generateThemeRules change to emit a @media (pointer: coarse) block, and the sub-44px touch-target floor.

@vercel

vercel Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
astryx Ignored Ignored Aug 11, 2026 6:03pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 11, 2026
@rubyycheung
rubyycheung force-pushed the feat/mobile-type-explorer branch from 1dfff72 to 2889c2f Compare August 11, 2026 07:59
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Adds a fullscreen sandbox tool for exploring how the Astryx type scale
adapts on touch devices, mirroring the docsite playground theme editor.

- Desktop column is the fixed reference, computed with the same
  geometric progression as expandTypeScale (round(base × ratio^step)),
  matching the playground default (base 14, ratio 1.2).
- Mobile adaptation is a master switch with three strategies:
  - Lift: floor body to the 16px readability minimum and rebuild the
    whole ladder at the full desktop ratio, keeping the display tier
    large and dramatic.
  - Pin: hold an anchor role (H1 by default) at its desktop size and
    re-derive a tamer ratio so headings do not balloon.
  - Custom: hand-tune each role's mobile size.
- Real-component preview renders the same Astryx components at both
  scales; the mobile side sits in a phone frame with the raw
  --font-size-* tokens overridden, demonstrating the token-layer
  mechanism a shipped implementation would use.
- 16px floor is explained inline: it matches the existing input
  behavior under @media (pointer: coarse).
@rubyycheung
rubyycheung force-pushed the feat/mobile-type-explorer branch from 2889c2f to 449fa0a Compare August 11, 2026 08:06
github-actions Bot added a commit that referenced this pull request Aug 11, 2026
The real-component preview didn't change with scale/lift/pin/custom
adjustments. Components read the semantic type-scale tokens
(--text-body-size, --text-display-3-size, …), which the base theme
defines as var(--font-size-*) refs on :root. The browser resolves those
refs at :root, so overriding the raw --font-size-* tokens on a wrapper
had no effect — the semantic token had already captured root's value.

Override the semantic --text-*-size (and -leading) tokens directly, as
literal rem values, on each preview side. This is the token layer real
components actually read, so they now render at the adapted scale.
Verified against the built stylesheet: desktop reads 29/24/14px for
display-3/heading-1/body, mobile reads 33/28/16px.
github-actions Bot added a commit that referenced this pull request Aug 11, 2026
Add a live formula caption to the Mobile column that explains how each
adaptation mode derives its sizes, with the current numbers substituted:
- Lift: size = round(16 × ratio^step)
- Pin:  ratioₚ = ratio × (base/bottom)^(1/pinStep); size = round(16 × ratioₚ^step)
It reacts to scale, mode, and anchor changes so the math is self-explanatory.
…o preview

- Show the derivation as plain text beside the Mobile column heading, with
  'Base floored 14 → 16px' leading the note line. Updates live per mode.
- Add a Display 1 sample to the real-component preview so the very top of the
  scale is visible when the anchor/mode changes.
@rubyycheung
rubyycheung marked this pull request as ready for review August 11, 2026 16:18
… anchors

- HStack vAlign only accepts center/start/end/stretch; 'baseline' broke the
  sandbox type-check build. Use 'center'.
- Add Display 1 and Display 2 to the Pin anchor list now that Display 1 is in
  the preview.
The gray preview background only wrapped its content, leaving white to the
right and below. Make the pane fill the scroll area (height 100% + overflow-y
auto) and wrap the content in a centered max-width container.
… width

The Astryx Layout root is flex:0 1 auto, so inside the fixed-position page
wrapper it collapsed to content width and left a white gap on wide screens.
Pass xstyle flex:1/width:100% so it fills, letting the muted preview pane
span the full remaining width with content centered inside it.
github-actions Bot added a commit that referenced this pull request Aug 11, 2026
github-actions Bot added a commit that referenced this pull request Aug 11, 2026
Gentle scales pin high; dramatic scales need a lower anchor so the display
tier doesn't tower over 16px body on a phone. Map ratio → recommended anchor:
- ≤ Major Third (1.25): Display 1
- Perfect Fourth (1.333): Heading 2
- Aug Fourth and above (≥ 1.414): Heading 3
Show a 'Recommended' badge on that option in the dropdown, plus an inline hint
with a 'Use' button so it's visible without opening the menu.
github-actions Bot added a commit that referenced this pull request Aug 11, 2026
@rubyycheung
rubyycheung merged commit 47af759 into main Aug 12, 2026
19 checks passed
@github-actions
github-actions Bot deleted the feat/mobile-type-explorer branch August 13, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant