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-1849] Rework action semantic color tokens #2428

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

jandrade
Copy link
Member

Summary:

Reworked semanticColor actions to use a new structure. Every action now
includes default, hover and press states, and each state includes
border, background and foreground tokens.

By doing this change, we'll offer a more consistent and predictable styling
direction for our interactive components.

Issue: https://khanacademy.atlassian.net/browse/WB-1849

Test plan:

Navigate to /?path=/docs/foundations-using-color--docs and check that the
Action section includes all the new tokens and the structure is readable and
makes sense.

Juan Andrade added 2 commits January 15, 2025 16:33
…tions to use a new structure. Every `action` now includes `default`, `hover` and `press` states, and each state includes `border`, `background` and `foreground` tokens.
@jandrade jandrade self-assigned this Jan 15, 2025
Copy link

changeset-bot bot commented Jan 15, 2025

🦋 Changeset detected

Latest commit: 480a8d1

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

This PR includes changesets to release 23 packages
Name Type
@khanacademy/wonder-blocks-tokens Major
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-breadcrumbs Patch
@khanacademy/wonder-blocks-button 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-icon-button Patch
@khanacademy/wonder-blocks-labeled-field Patch
@khanacademy/wonder-blocks-layout Patch
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-modal 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-switch Patch
@khanacademy/wonder-blocks-toolbar Patch
@khanacademy/wonder-blocks-tooltip 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

@khan-actions-bot khan-actions-bot requested a review from a team January 15, 2025 21:43
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/hot-panthers-kneel.md, __docs__/foundations-color.mdx, __docs__/components/color.tsx, packages/wonder-blocks-tokens/src/tokens/semantic-color.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

github-actions bot commented Jan 15, 2025

npm Snapshot: Published

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

Packages can also be installed manually by running:

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

Copy link
Contributor

github-actions bot commented Jan 15, 2025

Size Change: +167 B (+0.17%)

Total Size: 98.5 kB

Filename Size Change
packages/wonder-blocks-tokens/dist/es/index.js 2.52 kB +167 B (+7.09%) 🔍
ℹ️ 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 19.1 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 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.94 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.85 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.36 kB
packages/wonder-blocks-switch/dist/es/index.js 1.92 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-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 15, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

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

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 good! Had some non-blocking questions I wanted to get your thoughts on!

I noticed in the docs some of the token names wrap (you mentioned this also!). I confirmed that copy + pasting it still copies the name without the line break though!
image

border: color.activeBlue,
background: color.activeBlue,
foreground: color.white,
},
Copy link
Member

Choose a reason for hiding this comment

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

Should the focus state also have tokens associated with it?

Copy link
Member Author

Choose a reason for hiding this comment

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

focus will have its own separate state, that is directly allocated in the semanticColor.border.focus token. This is something Caitlyn and I have discussed and the goal is that any focus on any component should use a blue outline, so that's the reason why I'm not including it here.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good! There is also the disabled focus outline!

border: color.activeRed,
background: color.fadedRed,
foreground: color.activeRed,
},
},
disabled: {
Copy link
Member

Choose a reason for hiding this comment

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

Should the tokens associated with the disabled state also have the backgorund, foreground, border structure?

Copy link
Member Author

Choose a reason for hiding this comment

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

It might be in the future, but for now I'm leaving them out of every specific semantic global token and I'm defining them inside Button for now. Buttons need simplification and before doing that, I prefer to keep it this way. FWIW Design also has this structure, but this could change in the next weeks.

default: color.blue,
active: color.activeBlue,
// For primary actions
progressive: {
Copy link
Member

Choose a reason for hiding this comment

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

For my own understanding, what was the reason for using the progressive/progressiveInverse terminology instead of primary/secondary?

And should we start using this terminology for component kind variants too?

Copy link
Member Author

Choose a reason for hiding this comment

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

ahh good question. progressive refers to the type of action (defined as color in Button), which currently maps to blue, and destructive that maps to any action meant to delete/cancel etc (maps to red).

The primary and secondary are more distinctive for the kind of look and feel.

I'd say that we can categorize these kinds this way:

  • primary: Filled buttons (or buttons with a dark background).
  • secondary: outlined buttons (or buttons with white/transparent background).
  • tertiary: text buttons.

Now I'm wondering if we should create a third subcategory to account for the tertiary case.

TBH our variants became overcomplicated at some point, and it would be nice to simplify this. I'm glad that design is trying to do it with the Polaris/ThunderBlocks theme.

@jandrade
Copy link
Member Author

@beaesguerra I made some changes based on your feedback/questions (also after discussing offline).

  • Changed the structure to use filled and outlined to represent primary/semantic values (this might change in the future depending on the visuals approved for polaris).
  • Changed the structure of the "Using color" page to include an example of how all these new tokens work in their context + modified the layout to make it more readable.

https://5e1bf4b385e3fb0020b7073c-xynstbxfft.chromatic.com/?path=/docs/foundations-using-color--docs

Screenshot 2025-01-21 at 5 17 51 PM

Let me know what you think, and thanks again for the suggestions!

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! Thanks for making those updates! 🎉

@jandrade jandrade merged commit 0de25cd into main Jan 21, 2025
14 checks passed
@jandrade jandrade deleted the wb-semantic-color-refactor branch January 21, 2025 23:23
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (3fbcb28) to head (480a8d1).
Report is 22 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

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

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 3fbcb28...480a8d1. Read the comment docs.

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.

3 participants