Skip to content

[WB-2381] 🔷 Migrate WB font tokens to font.body.size / --wb-font-body-size#3835

Merged
jandrade merged 3 commits into
mainfrom
WB-2381
Jul 2, 2026
Merged

[WB-2381] 🔷 Migrate WB font tokens to font.body.size / --wb-font-body-size#3835
jandrade merged 3 commits into
mainfrom
WB-2381

Conversation

@jandrade

@jandrade jandrade commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Migrates the deprecated Wonder Blocks font.size / --wb-font-size tokens to the newer font.body.size / --wb-font-body-size tokens across Perseus.

Sizes map 1:1 by value: xSmall/small/medium have identical body equivalents. The body scale has no large, so the old font.size.large (2rem) maps to font.heading.size.medium, which is also 2rem — no visual change anywhere. All swaps are locked down by existing unit tests that assert the exact emitted CSS variables.

Risk: 🔷 Low · Complexity: Low

Issue: WB-2381

Test plan

No manual testing required — styling-token swaps with identical rendered values, verified by unit tests:

  • pnpm tsc — passes
  • locked-label, movable-point-labels-layer, and start-coords suites — pass
  • interactive-graph.test.tsx asserts the exact --wb-font-body-size-* / --wb-font-heading-size-medium CSS variables

Optional Storybook spot-check (no visual change expected): interactive-graph locked labels (small/medium/large) and the start-coords editor equation tiles.

Review plan

No High or Medium risk changes. This PR only renames Wonder Blocks font sizing tokens to their newer equivalents; every value is preserved (the one non-1:1 case, large, maps to a token with the same 2rem value), and behavior is covered by unit tests asserting the exact emitted CSS variables.

Common patterns

4 Files: Swapped the deprecated font.size.* JS token for the newer font.body.size.* token (and font.heading.size.medium where the old value was large).

-                fontSize: font.size.xSmall,
+                fontSize: font.body.size.xsmall,

-                fontSize: font.size.large,
+                fontSize: font.heading.size.medium,

2 Files: Swapped the deprecated --wb-font-size-* CSS variable for the newer --wb-font-body-size-* variable.

-    font-size: var(--wb-font-size-xSmall) !important;
+    font-size: var(--wb-font-body-size-xsmall) !important;

1 File: Replaced the dynamic font.size[size] lookup in locked-label with an explicit map, since large has no body equivalent.

+const labelFontSize: Record<LockedLabelType["size"], string> = {
+    small: font.body.size.small,
+    medium: font.body.size.medium,
+    large: font.heading.size.medium,
+};
...
-                    fontSize: font.size[size],
+                    fontSize: labelFontSize[size],

…-size

Replaces the deprecated Wonder Blocks `font.size` / `--wb-font-size` tokens
with the newer `font.body.size` / `--wb-font-body-size` tokens across Perseus.

Sizes map 1:1 by value: `xSmall`/`small`/`medium` have identical `body`
equivalents. The `body` scale has no `large`, so the old `font.size.large`
(2rem) maps to `font.heading.size.medium`, which is also 2rem — so there is
no visual change anywhere. All swaps are covered by existing unit tests
(interactive-graph.test.tsx asserts the exact emitted CSS variables).

Reviewers: #perseus

Issue: WB-2381

## Test plan:

No manual testing required. All changes are styling-token swaps with
identical rendered values, verified by unit tests:
- `pnpm tsc` — passes
- locked-label, movable-point-labels-layer, and start-coords suites — pass
- interactive-graph.test.tsx asserts the exact `--wb-font-body-size-*` /
  `--wb-font-heading-size-medium` CSS variables

Optional spot-check in Storybook (no visual change expected):
- Interactive graph locked labels (small/medium/large)
- Interactive graph editor start-coords equation tiles

## Review plan:

No High or Medium risk changes. This PR only renames Wonder Blocks font
sizing tokens to their newer equivalents; every value is preserved (the one
non-1:1 case, `large`, maps to a token with the same 2rem value), and the
behavior is locked down by unit tests asserting the exact CSS variables
emitted. Highest individual risk is Low.

### Common patterns:

**4 Files:** Swapped the deprecated `font.size.*` JS token for the newer
`font.body.size.*` token (and `font.heading.size.medium` where the old
value was `large`).

```diff
-                fontSize: font.size.xSmall,
+                fontSize: font.body.size.xsmall,

-                fontSize: font.size.large,
+                fontSize: font.heading.size.medium,
```

**2 Files:** Swapped the deprecated `--wb-font-size-*` CSS variable for the
newer `--wb-font-body-size-*` variable.

```diff
-    font-size: var(--wb-font-size-xSmall) !important;
+    font-size: var(--wb-font-body-size-xsmall) !important;
```

**1 File:** Replaced the dynamic `font.size[size]` lookup in locked-label
with an explicit map, since `large` has no `body` equivalent.

```diff
+const labelFontSize: Record<LockedLabelType["size"], string> = {
+    small: font.body.size.small,
+    medium: font.body.size.medium,
+    large: font.heading.size.medium,
+};
...
-                    fontSize: font.size[size],
+                    fontSize: labelFontSize[size],
```
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Size Change: +53 B (+0.01%)

Total Size: 517 kB

📦 View Changed
Filename Size Change
packages/perseus-editor/dist/es/index.js 104 kB +6 B (+0.01%)
packages/perseus/dist/es/index.js 204 kB +47 B (+0.02%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.6 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 6.31 kB
packages/math-input/dist/es/index.js 98.5 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12.9 kB
packages/perseus-core/dist/es/index.js 27.6 kB
packages/perseus-linter/dist/es/index.js 9.79 kB
packages/perseus-score/dist/es/index.js 9.86 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 12.4 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.71 kB

compressed-size-action

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (b06d5f9) and published it to npm. You
can install it using the tag PR3835.

Example:

pnpm add @khanacademy/perseus@PR3835

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3835

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3835

@jandrade jandrade marked this pull request as ready for review June 29, 2026 15:43

@mark-fitzgerald mark-fitzgerald 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.

Thank you for keeping our tokens up to date!

@jandrade jandrade merged commit e5c4c92 into main Jul 2, 2026
11 of 12 checks passed
@jandrade jandrade deleted the WB-2381 branch July 2, 2026 14:01
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.

2 participants