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-1871] IconButton: Rename color prop to actionType #2510

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

Conversation

jandrade
Copy link
Member

Summary:

We are trying to get more alignment with design, and part of that is that icon
buttons will use an actionType prop, which supports progressive and
destructive.

This PR includes the following API changes:

  • color => actionType.
  • color=default => actionType=progressive.

NOTE: progressive is now the default value.

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

Test plan:

Navigate to the IconButton docs and verify that the prop is now actionType
instead of color.

/?path=/docs/packages-iconbutton--docs#actiontype

@jandrade jandrade self-assigned this Mar 20, 2025
Copy link

changeset-bot bot commented Mar 20, 2025

🦋 Changeset detected

Latest commit: d5ebb1e

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

This PR includes changesets to release 8 packages
Name Type
@khanacademy/wonder-blocks-icon-button Major
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-tooltip Patch
@khanacademy/wonder-blocks-birthday-picker 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 Mar 20, 2025

Size Change: -37 B (-0.04%)

Total Size: 98.8 kB

Filename Size Change
packages/wonder-blocks-icon-button/dist/es/index.js 3.14 kB -37 B (-1.17%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.54 kB
packages/wonder-blocks-banner/dist/es/index.js 1.55 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.88 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 886 B
packages/wonder-blocks-button/dist/es/index.js 4.34 kB
packages/wonder-blocks-cell/dist/es/index.js 2.35 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.07 kB
packages/wonder-blocks-core/dist/es/index.js 2.85 kB
packages/wonder-blocks-data/dist/es/index.js 6.25 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.5 kB
packages/wonder-blocks-form/dist/es/index.js 6.04 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-icon/dist/es/index.js 873 B
packages/wonder-blocks-labeled-field/dist/es/index.js 1.26 kB
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.04 kB
packages/wonder-blocks-modal/dist/es/index.js 5.5 kB
packages/wonder-blocks-pill/dist/es/index.js 1.49 kB
packages/wonder-blocks-popover/dist/es/index.js 4.92 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.32 kB
packages/wonder-blocks-switch/dist/es/index.js 2.02 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.91 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 679 B
packages/wonder-blocks-timing/dist/es/index.js 1.79 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.7 kB
packages/wonder-blocks-toolbar/dist/es/index.js 923 B
packages/wonder-blocks-tooltip/dist/es/index.js 7.01 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Mar 20, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 233
Tests with visual changes 0
Total stories 574
Inherited (not captured) snapshots [TurboSnap] 155
Tests on the build 388

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: Simplified argTypes here to rely on the code comments directly (instead of duplicating the description here).

disabled: boolean,
kind: Kind,
light: boolean,
theme: IconButtonThemeContract,
) {
let actionType: ActionType = getActionType(buttonColor, disabled);
const themeVariant = theme.color[kind][actionType];
let actionTypeOrDisabled: ActionType = disabled ? "disabled" : actionType;
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 replaces the logic of getActionType() now that we have a correct mapping. This is just to add support to the disabled variant.

@jandrade jandrade marked this pull request as ready for review March 20, 2025 22:14
@khan-actions-bot khan-actions-bot requested a review from a team March 20, 2025 22:15
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/hot-days-cross.md, __docs__/wonder-blocks-icon-button/icon-button-variants.stories.tsx, __docs__/wonder-blocks-icon-button/icon-button.argtypes.ts, __docs__/wonder-blocks-icon-button/icon-button.stories.tsx, packages/wonder-blocks-icon-button/src/components/icon-button-core.tsx, packages/wonder-blocks-icon-button/src/components/icon-button.tsx

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 (52d08e8) 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="PR2510"

Packages can also be installed manually by running:

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

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, but I'll be curious to hear @beaesguerra's thoughts! I think it will clarify how color is used in themes. It was a bit confusing to me before with the levels of tokens and configuration objects.

My only other thought is: should there be tests for these changes, or does Storybook cover it?

@jandrade
Copy link
Member Author

My only other thought is: should there be tests for these changes, or does Storybook cover it?

@marcysutton Great question! We have been moving a lot of unit tests that covered styling to Visual regression testing with Storybook + Chromatic, and in this case it would be covered by these tests:

https://5e1bf4b385e3fb0020b7073c-zqttvbhhap.chromatic.com/?path=/story/packages-iconbutton-all-variants--default

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! Glad we're also moving towards semantic naming for props too!

Few follow up questions:

  • Are there plans to also update perseus before webapp since it's a breaking change?
  • Will we still also be updating the icon semantic tokens (primary to neutral, getting rid of the secondary semantic icon token, etc)? And having the kind prop values match those values? (related to the thread from last week!)

@jandrade
Copy link
Member Author

jandrade commented Mar 21, 2025

  • Are there plans to also update perseus before webapp since it's a breaking change?

That's correct. I'll chat with the LEMS team before landing this change (sometime next week).

  • Will we still also be updating the icon semantic tokens (primary to neutral, getting rid of the secondary semantic icon token, etc)? And having the kind prop values match those values? (related to the thread from last week!)

Yes, but that will happen in an upcoming PR: https://khanacademy.atlassian.net/browse/WB-1902

I'm going to add an "Implementation plan" to this PR and the stacked ones to make the plan clearer.

Thanks for asking these questions @beaesguerra!

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.

4 participants