Skip to content

refactor(ui): compose text styles as role triplets at the call site #1875

Closed

Description

@Astro-Han

Problem

Renderer CSS restates typography as independent values at ~130 declaration blocks: font-size, line-height, font-weight, and font-family are each picked separately per call site. Nothing structurally ties them together, so a size can change without its leading, or a weight can be inherited from the UA while its neighbours are explicit.

This is the mechanism that produced the three competing leading vocabularies converged in the leading PR that follows #1857 (product semantic ratios / Astryx role tokens / --maka-line-body). Converging the values removes today's divergence; it does not remove the ability to diverge again.

Astryx's own answer is that a text style is one indivisible role triplet:

Semantic tokens that combine size, weight, and line-height into a single type style. Each token triplet (--text-*-size, --text-*-weight, --text-*-leading) is consumed by Text and Heading. Use the component props rather than composing raw font tokens.
— packages/cli/docs/typography.doc.mjs

Why this is not part of the leading PR

Measured across the 130 blocks that declare a line height:

count
declaration blocks 130
declare font-weight explicitly 32
declare font-family explicitly 11
selectors relying on UA/inherited weight (strong, h1–h6, code, …) with no explicit font-weight 13

The CSS-native form of a role triplet is the font shorthand (font: var(--text-body-weight) var(--text-body-size)/var(--text-body-leading) var(--font-family-body)), which makes size and leading structurally inseparable. But the shorthand resets font-weight, font-style, font-variant, and font-family: applying it would silently move 98 blocks to weight 400 — 13 of them visibly, from bold — and drop the mono family on 11 blocks. Carrying the full triplet is therefore mandatory, which makes this a weight and family migration, not a leading change. Both must move together or not at all.

Scope

  • Decide the target form: Astryx <Text> / <Heading> components (the vendor's answer, a JSX migration) vs a CSS font-shorthand role token per role (same guarantee, stays in the existing CSS architecture).
  • Migrate the call sites to name a role instead of restating values.
  • Replace the size↔leading pairing contract added by the leading PR with the stronger invariant the triplet gives for free: no call site declares raw font tokens at all.

Prerequisite

The leading convergence PR. After it, every block is provably role-consistent for (size, leading) — Astryx's leading is a pure function of size, so no per-site judgement remains and this migration becomes mechanical.

Activity

  1. Astro-Han commented on Aug 2, 2026

    @Astro-Han
    ContributorAuthor

    Claiming this — starting work now.

    Measured on current main (resolving every value through astryx-theme/maka.css and the maka-tokens.css aliases), the surface is larger than the issue body records, because #1878 paired size and leading across the tree: 348 declaration blocks now declare both, not 130. They collapse to 29 distinct (size, leading, weight, family) tuples, and 210 of the 348 are just two of them — supporting and body with no weight or family of their own.

    Going with the CSS role-token route, not <Text>/<Heading>. TextProps['as'] is typed 'span' | 'p' | 'div' | 'label' | 'h1' | 'h2' | 'h3', so it cannot render the strong / small / li / dt / dd / code / pre / h4 that terminate 142 of those selectors, and the markdown-rendered nodes (.maka-turn [data-maka-contract="markdown"] h1, .maka-deep-research-run-summary strong) have no JSX call site at all. Components would cover part of the tree and leave CSS as a second authority for the rest, which is the thing this issue exists to end.

    That means resolving the font: shorthand ban #1878 landed. The resolution is to tighten it rather than relax it: font: becomes legal only as var(--maka-text-<role>), never as an ad-hoc value. The shorthand's reset semantics turn from hazard into guarantee — weight and family are supplied by the role token, so no site can move one without the others.

    Two consequences worth flagging up front:

    • No product roles. All 42 blocks whose tuple has no Astryx equivalent are hand-rolled values the ladder never chose — every Astryx heading is 600, yet 10 blocks use 700; the 12px tier offers only 400 and 600, yet 11 blocks use 500. They migrate to existing roles.
    • Family stops being a call-site axis. font: requires a family slot, which would override the single :where(code, kbd, samp, pre) mono authority. Instead the role tokens end in var(--maka-font-family), rebound once on that same selector, and the 17 mono class sites become <code> / <pre> markup. After this, exactly one rule in the repo names a monospace stack.

    findLeadingPairingOffenders is replaced, not kept alongside — once no call site can write a raw font longhand, the pairing it guards is unrepresentable.

    Branch: refactor/typography-role-triplet. Will open as draft.

  2. self-assigned this
    on Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions