Skip to content

fix(core): a numeric typography weight builds through an extended base's adaptation rules - #12154

Closed
josephfarina wants to merge 2 commits into
mainfrom
core-adaptation-numeric-weight
Closed

josephfarina wants to merge 2 commits into
mainfrom
core-adaptation-numeric-weight

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What users see

A typography weight that reaches Core as a number now works everywhere. That happens in a theme written in JavaScript, or one read from JSON:

defineTheme({
  name: 'acme',
  extends: neutralTheme,
  typography: {scale: {base: 16, ratio: 1.2}, heading: {weight: 700}},
});

Before, a theme like this failed to load whenever its base had adaptation rules, as neutral, stone, chocolate and butter do: defineTheme("acme").adaptations.rules[0].value.tokens["--text-heading-1-weight"] must resolve to a concrete CSS string. The message named a rule the author never wrote and gave no fix. On a base without adaptation rules (matcha, gothic, y2k), or without extends, the same theme already built. The number was passed through as a number, and only the adaptation path required text.

Change

  • resolveFontWeight writes a number as its text (700 → '700'), so the root tokens and every adaptation rule's tokens hold the same CSS string.
  • The public FontWeight type does not change: TypeScript still asks for the string form. This is runtime tolerance only.

Tests

packages/core/src/theme/themeAdaptations.test.ts: a child of a base with an adaptation rule, given untyped heading: {weight: 700, weights: {2: 800}} and body: {weight: 450}, builds. Both the root tokens and the rule's tokens hold '700', '800' and '450'. The test fails without this change. All Core theme tests pass.

Changeset

[fix] for @astryxdesign/core.

…heme extending a base with adaptation rules builds
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 17, 2026 2:07am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 2:13 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 16a06dc

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request needs an owner decision before approval. The runtime fix is sound: a numeric weight is now written as its text, and a red-first test proves that a theme extending a base with adaptation rules builds. The new number member of the public FontWeight type has no governing spec, so approval needs a maintainer to provide or identify the governing spec for it; what must be settled is whether FontWeight accepts a number beside the raw CSS string '700' it already takes. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner.

Blocking findings:

  • type FontWeight changes outside this pull request's scope (core names no component and the description has no ## Scope line), so name FontWeight on a Components: line under a ## Scope heading and get the owner decision, or split the widening into its own pull request.
  • astryx theme build still warns, and astryx experimental theme compile still exits 1, on heading: {weight: 700} as "a type mismatch the theme's types refuse" (packages/cli/api/theme/build/typography-values.mjs:178-188 and its tests), so either accept a number from 1 to 1000 there or drop | number from packages/core/src/theme/types.ts:19.
  • The description says every bundled base has adaptation rules, but matcha, gothic and y2k have none and already build a numeric weight on main, so it should name neutral, stone, chocolate and butter instead.
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: a numeric weight in a theme that extends a base with adaptation rules failed with "must resolve to a concrete CSS string": verified (red-first test; a neutralTheme probe on main).
  • Claim: every bundled base has adaptation rules: false (matcha, gothic and y2k have none).
  • Claim: the same theme without extends already built: verified at runtime (main writes the number 700; its type refused a number).
  • Claim: the number passed through unchanged and only the adaptation path required text: verified (resolveFontWeight on main; themeAdaptations.ts:684-698).
  • Claim: resolveFontWeight writes a number as its text, so root and rule tokens hold the same string: verified (resolveThemeValues.ts:152-154; both '700').
  • Claim: FontWeight takes number as an additive widening: verified (types.ts:19); its authority waits on the owner decision.
  • Claim: the new test builds and asserts '700', '800' and '450' in root and rule tokens, and fails without the change: verified (themeAdaptations.test.ts:1718-1748; red-first run).
  • Claim: all Core theme tests pass: verified (31 files, 1,810 tests).
  • Changeset claim: a numeric weight is written as its text everywhere it is read: verified for Core; the CLI check still calls it a type mismatch (finding above).
  • Changeset claim: a theme extending a base with adaptation rules builds instead of failing: verified.
  • Changeset claim: FontWeight takes a number too: verified; waits on the owner decision.
  • File .changeset/core-numeric-font-weight.md: see the CLI finding.
  • File packages/core/src/theme/resolveThemeValues.ts: clear.
  • File packages/core/src/theme/themeAdaptations.test.ts: clear.
  • File packages/core/src/theme/types.ts: owner decision, scope and CLI findings.

Automated review (maintainer link)

Comment thread packages/core/src/theme/types.ts Resolved

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: the CI workflow did not run on this head (it was cancelled because CI was full), so it needs a re-run before merge.

The runtime fix is sound: resolveFontWeight now writes a numeric weight as its text, so a JavaScript or JSON theme that extends a base with adaptation rules builds, and the new test fails without the change. FontWeight is unchanged, so the earlier type, CLI and scope points no longer apply, and the description now names the right bases.

  • Optional: the ThemeMode comment change in packages/core/src/theme/types.ts already matches main, so it adds nothing on merge; drop it or merge main to keep the diff to the fix.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Claim: a numeric weight that reaches Core from a JavaScript or JSON theme now works through defineTheme: verified (resolveThemeValues.ts:152-155, themeAdaptations.test.ts:1718-1750).
  • Claim: before, such a theme failed whenever its base had adaptation rules (neutral, stone, chocolate, butter), with the "must resolve to a concrete CSS string" error: verified (the new test fails on the base with that error; those four theme sources declare one adaptation rule each).
  • Claim: on a base without rules (matcha, gothic, y2k) or with no extends, the same theme already built, and only the adaptation path required text: verified (those theme sources declare no rules; the root path passes values through at resolveThemeValues.ts:135-142, the rule path checks leaves at themeAdaptations.ts:684-698).
  • Claim: root tokens and every rule's tokens hold the same CSS string: verified (the test asserts '700', '800' and '450' in both).
  • Claim: the public FontWeight type does not change; this is runtime tolerance only: verified (types.ts:17-18 matches the base; the public API delta has no rows).
  • Claim: the test fails without the change and all Core theme tests pass: verified (fails on the base; 31 files and 1,810 tests pass on the head).
  • Claim: the changeset is a [fix] patch for @astryxdesign/core: verified.
  • Changeset: a number is written as its text everywhere defineTheme reads a weight: verified (every resolveFontWeight call in buildTypeScaleConfig, resolveThemeValues.ts:208-230).
  • Changeset: a theme extending a base with adaptation rules now builds instead of failing: verified (the new test).
  • Changeset: the FontWeight type does not change: verified.
  • File .changeset/core-numeric-font-weight.md: clear.
  • File packages/core/src/theme/resolveThemeValues.ts: clear.
  • File packages/core/src/theme/themeAdaptations.test.ts: clear.
  • File packages/core/src/theme/types.ts: note (the ThemeMode comment hunk already matches main); FontWeight unchanged.

Automated review (maintainer link)

@josephfarina josephfarina reopened this Nov 17, 2026
josephfarina added a commit that referenced this pull request Nov 18, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #12252 docs(cli): agent docs name the prop names that differ from other libraries
  Author: Joey Farina <[email protected]>
- #12154 fix(core): a numeric typography weight builds through an extended base's adaptation rules
  Author: Joey <[email protected]>
- #12092 fix(cli): theme build reads the Core it builds with for variant declarations, and names the build command alone
  Author: Joey Farina <[email protected]>
- #12316 fix(core): a shorthand never follows its own longhand in one style merge
  Author: josephfarina <[email protected]>
- #12357 fix(core): a Table stays the scroll region when a host scrolls every table's parent
  Author: Joey Farina <[email protected]>
- #12349 fix(core): end a mouse drag a sandboxed frame never saw released
  Author: josephfarina <[email protected]>
- #12425 fix(cli): use a stored doc parse only with the zod release that made it
  Author: Joey <[email protected]>
- #12396 fix(AppShell): with the standard width points, a server-rendered shell hides its inline side nav on a phone before its script runs
  Author: Joey <[email protected]>
- #12438 fix(charts): end dots draw whole and a thinned axis keeps its last label
  Author: Joey Farina <[email protected]>
- #12448 fix(cli): upgrade outside a project names the project, not --from
  Author: Joey Farina <[email protected]>
- #12459 fix(templates): the dashboard scorecard fits a phone screen
  Author: Joey Farina <[email protected]>
- #12428 fix(core): Field labels draw in a bolder face than their description
  Author: Joey Farina <[email protected]>
- #12435 fix(theme-matcha): dark menus, popovers and muted fills take the theme's deep gray neutral
  Author: Joey <[email protected]>
- #12432 fix(templates): dashboard chart labels show whole instead of clipped by the chart edge
  Author: Joey Farina <[email protected]>
- #12441 fix(cli): mark icon-set generated calls pure so apps drop unused icons
  Author: Joey Farina <[email protected]>
- #12472 fix(MetadataListItem): a value breaks only a word longer than its line
  Author: Joey <[email protected]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12718.

@github-actions
github-actions Bot deleted the core-adaptation-numeric-weight branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 16a06dce Deployed Nov 17, 2026 by vercel[bot]
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