Skip to content
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

[WB-1814.3] Refactor Switch to use semantic colors #2441

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

jandrade
Copy link
Member

Summary:

Continuing with the semantic colors migration, this PR covers the Switch
component.

  • Refactored the Switch themes to use semantic colors.
  • Added All Variants story to switch.
  • Disabled chromatic snapshots for existing stories (now using All Variants).

Implementation plan:

  1. [WB-1814.1] Refactor Checkbox and Radio to use semantic colors #2439
  2. [WB-1814.2] Refactor TextField and TextArea to use semantic colors #2440
  3. Switch (current PR)
  4. Accordion, Banner, BirthdayPicker
  5. IconButton
  6. Clickable, Link
  7. Modal
  8. Popover, Tooltip
  9. Pill, Toolbar

Issue: WB-1814

Test plan:

  • Navigate to /?path=/story/packages-switch-switch-all-variants--default
  • Verify that the styles are correct.

@jandrade jandrade self-assigned this Jan 23, 2025
Copy link

changeset-bot bot commented Jan 23, 2025

🦋 Changeset detected

Latest commit: aac58bd

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

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-switch 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 Jan 23, 2025

Size Change: +77 B (+0.08%)

Total Size: 98.1 kB

Filename Size Change
packages/wonder-blocks-switch/dist/es/index.js 2 kB +77 B (+4.01%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.77 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.77 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.12 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 2.9 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 18.9 kB
packages/wonder-blocks-form/dist/es/index.js 5.99 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-icon-button/dist/es/index.js 2.95 kB
packages/wonder-blocks-icon/dist/es/index.js 871 B
packages/wonder-blocks-labeled-field/dist/es/index.js 1.84 kB
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.42 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.88 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.34 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.74 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.54 kB
packages/wonder-blocks-toolbar/dist/es/index.js 905 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.99 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Jan 23, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 380
Tests with visual changes 1
Total stories 535
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 380

Juan Andrade added 3 commits January 23, 2025 11:55
…e `semanticColor` tokens instead of `color`. This will prepare the component for supporting a more global theming approach in the future.
…est now that we use Chromatic snapshots for all variants
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: As we have been discussing, this is a new file to run visual regression tests on all variants of a component. I auto-approved the first version in Chromatic so reviewers can compare the baseline with the semanticColor changes.

Comment on lines -112 to -117
expect(switchWithIcon).toHaveStyle(
"background-color: rgba(33, 36, 44, 0.5)",
);
expect(switchWithIcon).toHaveStyle(
"outline: 2px solid rgb(24, 101, 242)",
);
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: Removed these assertions now that we fully check this via Chromatic snapshots

Comment on lines +158 to +161
":focus-within": {
outline: `solid ${theme.size.width.small}px ${theme.color.outline.default}`,
outlineOffset: theme.size.offset.default,
},
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: I noticed that this was missing to display the focus outline on disabled switches.

Base automatically changed from form-cb-rb-semantic-v2 to main January 29, 2025 15:38
@jandrade jandrade marked this pull request as ready for review January 29, 2025 15:59
@khan-actions-bot khan-actions-bot requested a review from a team January 29, 2025 15:59
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/eight-houses-enjoy.md, __docs__/wonder-blocks-switch/switch-variants.stories.tsx, __docs__/wonder-blocks-switch/switch.stories.tsx, packages/wonder-blocks-switch/src/components/switch.tsx, packages/wonder-blocks-switch/src/themes/default.ts, packages/wonder-blocks-switch/src/themes/khanmigo.ts

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

Copy link
Contributor

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (e2b0b50) 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="PR2441"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2441

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