Skip to content

[WB-1896] Tokens: Add thunderblocks theme to Wonder Blocks #2562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 14, 2025
Merged

Conversation

jandrade
Copy link
Member

@jandrade jandrade commented Apr 16, 2025

Summary:

Adds the new thunderblocks theme to support the new classroom experience.

This new theme is based on the existing default theme (OG) but it uses its own
primitive colors.

Also added theming support in Chromatic modes, so that the new theme can be
used for visual regression testing. Note that this was only added to the
IconButton snapshots for now to verify that the new theme works as expected.

More changes will come in future PRs to start using all the correct tokens in
all the required components (including sizing, borders, offsets,
typography, etc).

Issue: WB-1896

Test plan:

Verify that the new theme is available in the Storybook via the "Theme" toolbar.

Verify that the component colors change when the theme is switched to
thunderblocks.

/?path=/docs/foundations-using-color--docs&globals=theme:thunderblocks

Screenshot 2025-04-16 at 6 01 45 PM

Also verify that the IconButton snapshots now include the thunderblocks theme.

Screenshot 2025-04-16 at 6 02 29 PM

@jandrade jandrade self-assigned this Apr 16, 2025
Copy link

changeset-bot bot commented Apr 16, 2025

🦋 Changeset detected

Latest commit: b2c1090

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@khanacademy/wonder-blocks-theming Minor
@khanacademy/wonder-blocks-tokens Minor
@khanacademy/wonder-blocks-button Patch
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-switch Patch
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-breadcrumbs Patch
@khanacademy/wonder-blocks-cell Patch
@khanacademy/wonder-blocks-clickable Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-form Patch
@khanacademy/wonder-blocks-grid Patch
@khanacademy/wonder-blocks-labeled-field Patch
@khanacademy/wonder-blocks-layout Patch
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-pill Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-progress-spinner Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-styles Patch
@khanacademy/wonder-blocks-tabs Patch
@khanacademy/wonder-blocks-toolbar Patch
@khanacademy/wonder-blocks-tooltip Patch
@khanacademy/wonder-blocks-typography Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Apr 16, 2025

Size Change: 0 B

Total Size: 91 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 2.98 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-banner/dist/es/index.js 1.42 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.91 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 723 B
packages/wonder-blocks-button/dist/es/index.js 3.4 kB
packages/wonder-blocks-cell/dist/es/index.js 2.06 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.67 kB
packages/wonder-blocks-core/dist/es/index.js 2.48 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-dropdown/dist/es/index.js 16.6 kB
packages/wonder-blocks-form/dist/es/index.js 4.9 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 1.89 kB
packages/wonder-blocks-icon/dist/es/index.js 690 B
packages/wonder-blocks-labeled-field/dist/es/index.js 1.2 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.65 kB
packages/wonder-blocks-modal/dist/es/index.js 4.98 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.32 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.09 kB
packages/wonder-blocks-styles/dist/es/index.js 451 B
packages/wonder-blocks-switch/dist/es/index.js 1.71 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.45 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.51 kB
packages/wonder-blocks-testing/dist/es/index.js 985 B
packages/wonder-blocks-theming/dist/es/index.js 577 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.88 kB
packages/wonder-blocks-toolbar/dist/es/index.js 889 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.41 kB
packages/wonder-blocks-typography/dist/es/index.js 905 B

compressed-size-action

@jandrade jandrade changed the title [WB-1896] Tokens: Add thunderblocks theme to Wonder Blocks. [WB-1896] Tokens: Add thunderblocks theme to Wonder Blocks Apr 16, 2025
@jandrade jandrade marked this pull request as ready for review April 16, 2025 22:03
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Apr 16, 2025

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to package.json, pnpm-lock.yaml, .changeset/flat-tables-grin.md, .storybook/preview.tsx, __docs__/wonder-blocks-icon-button/icon-button-testing-snapshots.stories.tsx, packages/wonder-blocks-theming/src/types.ts, packages/wonder-blocks-tokens/src/theme/thunderblocks.ts, packages/wonder-blocks-tokens/src/theme/semantic/semantic-color-thunderblocks.ts, packages/wonder-blocks-tokens/src/theme/semantic/internal/primitive-color-thunderblocks.ts

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@khan-actions-bot khan-actions-bot requested a review from a team April 16, 2025 22:04
Copy link
Contributor

github-actions bot commented Apr 16, 2025

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (713be65) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2562"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2562

Comment on lines 104 to 126
// Black
black_100: black,
black_90: fade(black, 0.9),
black_80: fade(black, 0.8),
black_70: fade(black, 0.7),
black_60: fade(black, 0.6),
black_50: fade(black, 0.5),
black_40: fade(black, 0.4),
black_30: fade(black, 0.3),
black_20: fade(black, 0.2),
black_10: fade(black, 0.1),
// White
white_100: white,
white_90: fade(white, 0.9),
white_80: fade(white, 0.8),
white_70: fade(white, 0.7),
white_60: fade(white, 0.6),
white_50: fade(white, 0.5),
white_40: fade(white, 0.4),
white_30: fade(white, 0.3),
white_20: fade(white, 0.2),
white_10: fade(white, 0.1),
white_01: fade(white, 0.01),
Copy link
Member Author

Choose a reason for hiding this comment

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

note: This might change based on a convo with Caitlyn.

Copy link
Contributor

github-actions bot commented Apr 17, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-qsrtitvbwn.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 379
Tests with visual changes 3
Total stories 607
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 379

Copy link
Member

@marcysutton marcysutton left a comment

Choose a reason for hiding this comment

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

This looks good to me! It's a big piece I was missing for typography theming.

Copy link
Member

@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

Looks great! So exciting to see the theme colors get updated when we toggle the theme 😄

{
value: "thunderblocks",
icon: "lightning",
title: "Thunder Blocks (Classroom)",
Copy link
Member

Choose a reason for hiding this comment

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

Do we also want to include OG in the title for the default theme? In case others are referring to the default theme as OG!

import {fade} from "../../../util/utils";

// Base colors
const black = "#191918";
Copy link
Member

Choose a reason for hiding this comment

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

My one thought on working through some font theming is: should the default theme be put into these theme folders to keep similar objects near each other in the codebase? I think it could help reduce some cognitive complexity for theming.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great question! My main reasoning for not putting the default color primitives was because those tokens are public (TB primitive colors are not). I left color.ts and spacing.ts inside the tokens package as the goal is to mark them as deprecated at some point in the future (or OG colors are going to be marked as internal at some point).

OG colors are public mostly for historic reasons (we didn't use semanticColor tokens before), and the overall goal is to make these colors private at some point, but I'm not fully sure if we are going to be able to do it. That will happen for sure after completing Polaris and doing all the cleanup work from legacy UIs that won't be used by the Classic Experience anymore (aka things that are deprecated from ka.org and moved to Polaris).... same applies with Spacing -> Sizing.

That said, if you think that it is better to move OG colors to the theme folder, then I can do it without any problem :) (at the end, it is an internal thing, and the public export remains the same).

wdyt?

Base automatically changed from feature/css-vars to main April 22, 2025 14:48
@marcysutton
Copy link
Member

@jandrade FYI I think this one might need to be updated with main to get the latest changes for color-utils!

@jandrade jandrade merged commit c7d95bf into main May 14, 2025
14 checks passed
@jandrade jandrade deleted the tb-theme branch May 14, 2025 00:47
Copy link

codecov bot commented May 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (39b8c17) to head (b2c1090).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #2562   +/-   ##
============================
============================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39b8c17...b2c1090. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

4 participants