Skip to content

[ColorSync][math-input] Convert math-input font and colors to semantic tokens#3744

Open
Myranae wants to merge 13 commits into
mainfrom
tb/LEMS-4244/math-input-color-sync
Open

[ColorSync][math-input] Convert math-input font and colors to semantic tokens#3744
Myranae wants to merge 13 commits into
mainfrom
tb/LEMS-4244/math-input-color-sync

Conversation

@Myranae

@Myranae Myranae commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary:

Part of the ColorSync migration. Converts hardcoded color and font values in the math-input package to WonderBlocks semantic tokens. See images below for color comparisons and affected widget areas.

math-input-color-comparison

Main Changes Visible

Keypad Button Pressed (outline and background)
Screenshot 2026-06-10 at 4 01 13 PM
image

Cursor Handle
Screenshot 2026-06-10 at 10 13 44 AM

Navigation Button Pressed
Screenshot 2026-06-10 at 10 13 34 AM

Issue: LEMS-4244

Test plan:

  • Confirm all checks pass
  • Chromatic diffs reviewed and approved — 3 expected stories:
    • CursorHandleVisible (new regression story, cursor handle fill/stroke)
    • KeypadButtonPressed (pressed state background + border)
    • NavigationButtonPressed (pressed state border)

@Myranae Myranae self-assigned this Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Size Change: -55 B (-0.01%)

Total Size: 508 kB

📦 View Changed
Filename Size Change
packages/math-input/dist/es/index.js 98.5 kB -55 B (-0.06%)
ℹ️ 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.32 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 12 kB
packages/perseus-core/dist/es/index.js 26.3 kB
packages/perseus-editor/dist/es/index.js 105 kB
packages/perseus-linter/dist/es/index.js 9.8 kB
packages/perseus-score/dist/es/index.js 10.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/index.js 200 kB
packages/perseus/dist/es/strings.js 8.6 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 8, 2026

Copy link
Copy Markdown
Contributor

npm Snapshot: Published

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

Example:

pnpm add @khanacademy/perseus@PR3744

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

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

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

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

@github-actions github-actions Bot added schema-change Attached to PRs when we detect Perseus Schema changes in it and removed schema-change Attached to PRs when we detect Perseus Schema changes in it labels Jun 10, 2026
@Myranae Myranae changed the title WIP [ColorSync][math-input] Convert colors and fonts in relevant math-input related files to semantic tokens [ColorSync][math-input] Convert math-input font and colors to semantic tokens Jun 10, 2026
@Myranae Myranae marked this pull request as ready for review June 10, 2026 22:12
@Myranae

Myranae commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@claude review once

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — mechanical color/font token migration with visual regression coverage.

Extended reasoning...

Overview

This PR is part of the ColorSync migration and converts hardcoded color/font values in the math-input package to WonderBlocks semantic tokens. Changes touch the cursor handle SVG fill/stroke, keypad button pressed state (border + background + font family), and navigation button pressed state. It also adds three new visual regression stories (CursorHandleVisible, KeypadButtonPressed, NavigationButtonPressed) plus a MathQuill cursor-blink stabilization decorator for deterministic snapshots. Snapshot updates are purely class-name churn from the aphrodite style hash changing.

Security risks

None. The changes are color/font constant replacements and additive Storybook stories — no auth, data handling, or input parsing is touched.

Level of scrutiny

Low. This is a presentation-only token swap following an established migration pattern (matches prior ColorSync PRs). The author has chromatic diffs reviewed and called out the three expected visual changes; the snapshot churn is the expected mechanical side effect. The TODO comment on the unreachable action branch in keypad-button.tsx is a helpful annotation, not a behavior change.

Other factors

  • No bugs found by the bug hunting system.
  • The MathQuill blink-decorator in expression-interactions-regression.stories.tsx is well-commented (explains the @layer shared !important inversion) and scoped to the story file, so it does not affect production code.
  • Bundle size delta is -55 B, consistent with the simplification of the pressed-state gradient into a single token.


const meta: Meta<typeof CursorHandle> = {
title: "Math Input/Components/Visual Regression Tests/Initial State",
component: CursorHandle,

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.

Would this still be considered general math input initial state regression story if the main component being tested is CursorHandle? I almost feel like this should be cursor-handle-regression.stories.tsx instead?


const meta: Meta<typeof NavigationPad> = {
title: "Math Input/Components/Visual Regression Tests/Interactions",
component: NavigationPad,

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.

Same comment here but for NavigationPad.

border: "2px solid #1B50B3",
border: `2px solid ${semanticColor.core.border.instructive.strong}`,
padding: 0,
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${semanticColor.core.background.base.default}`,

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.

oh whoa, what was this linear gradient doing before?

decorators: [
(Story) => {
// MathQuill toggles `mq-blink` via setInterval, making snapshots
// non-deterministic. The blink rules in main.css use `!important`

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.

I love a good use of non-deterministic, but can we say flakey here so it's more immediately obvious what the problem is?

Or maybe just add a sentence above this that says "text field cursor blinking can make snapshots flakey"


// This component is touch-only in production and never reached via mouse
// interactions, so it is tested here in isolation.
export const CursorHandleVisible: Story = {

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.

I don't think I see this in the UI Tests check on your PR?

},
};

export const KeypadButtonPressed: Story = {

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.

I don't think I see this in the UI Tests check on your PR either?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants