Skip to content

[WB-1852.2] Remove Button.light variant, modify actionStyles to support Button instances #2563

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 10 commits into from
Apr 24, 2025

Conversation

jandrade
Copy link
Member

Summary:

This PR mainly removes the light prop from the Button component and its
associated styles. The light prop was used to apply a light theme to the
button, but it is no longer maintained and has been removed to simplify the
codebase.

The inverse action style can now be used as a replacement for these kind of
scenarhos.

Details:

  • Button:
    • Removed the light prop as it is no longer maintained.
    • Simplified pseudo-states (e.g. :hover, :active), instead of using :hover:not("aria-disabled=true).
  • Styles: Adjusted actionStyles.inverse to account for Button instances.

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

Test plan:

Navigate to the Button component in storybook and verify that the light prop
is no longer available.

Test the inverse action style in storybook to ensure it looks as expected with
Button instances.

Juan Andrade added 3 commits April 17, 2025 10:33
…no longer maintained. Simplifes pseudo-states (e.g. `:hover`, `:active`).
@jandrade jandrade self-assigned this Apr 17, 2025
Copy link

changeset-bot bot commented Apr 17, 2025

🦋 Changeset detected

Latest commit: 6d406a7

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

This PR includes changesets to release 11 packages
Name Type
@khanacademy/wonder-blocks-button Major
@khanacademy/wonder-blocks-styles Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-switch 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 Apr 17, 2025

Size Change: -245 B (-0.24%)

Total Size: 103 kB

Filename Size Change
packages/wonder-blocks-button/dist/es/index.js 3.97 kB -280 B (-6.59%)
packages/wonder-blocks-styles/dist/es/index.js 503 B +35 B (+7.48%) 🔍
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.56 kB
packages/wonder-blocks-announcer/dist/es/index.js 2.04 kB
packages/wonder-blocks-banner/dist/es/index.js 1.58 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 2.09 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 886 B
packages/wonder-blocks-cell/dist/es/index.js 2.36 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.12 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.7 kB
packages/wonder-blocks-form/dist/es/index.js 6.03 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-icon-button/dist/es/index.js 2.27 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 1.98 kB
packages/wonder-blocks-modal/dist/es/index.js 5.48 kB
packages/wonder-blocks-pill/dist/es/index.js 1.54 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.34 kB
packages/wonder-blocks-switch/dist/es/index.js 1.9 kB
packages/wonder-blocks-tabs/dist/es/index.js 1.93 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.96 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 779 B
packages/wonder-blocks-timing/dist/es/index.js 1.79 kB
packages/wonder-blocks-tokens/dist/es/index.js 3.06 kB
packages/wonder-blocks-toolbar/dist/es/index.js 923 B
packages/wonder-blocks-tooltip/dist/es/index.js 7.02 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Apr 17, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 328
Tests with visual changes 0
Total stories 599
Inherited (not captured) snapshots [TurboSnap] 46
Tests on the build 374

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: Cleaned up this file to remove all the light variants in Snapshots.

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: Cleaned up the descriptions in this file now that ArgTypes are inferred better after the SB 8 migration.

Comment on lines -72 to -80
light: {
description: "Whether the button is on a dark/colored background.",
control: {type: "boolean"},
table: {
category: "Theming",
type: {
summary: "boolean",
detail: "Sets primary button background color to white, and secondary and tertiary button title to color.",
},
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: The only big change in this file was removing this argType as this light prop is now removed from the codebase.

Comment on lines +305 to +311
// NOTE: This is a workaround while we move
// this button to DAB and remove the
// `Button.khanmigo` theme.
{
background: "transparent",
":hover": {background: "transparent"},
},
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 mentioned in the comment, this will go away as soon as I remove the khanmigo theme in WB in favor of a separate DynamicActionButton component (future PR).

Copy link
Member

Choose a reason for hiding this comment

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

Does this mean call sites that use a ModalPanel with a secondary Button will also needed to apply this work around?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not all call sites. This should be solved by WB internally as far as consumers use the light=false and closeButtonVisible prop. I'm planning to update the remaining cases in webapp.

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: These variants are no longer accepted by PopoverContent as I removed the light variant from there a few weeks ago. I forgot to cleanup this bit.

@@ -175,7 +160,8 @@ const ButtonCore: React.ForwardRefExoticComponent<
sharedStyles.endIconWrapper,
kind === "tertiary" &&
sharedStyles.endIconWrapperTertiary,
(focused || hovered) &&
!disabled &&
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: Added this line as it is needed now that the complex css pseudo-selector is removed (e.g. :hover:not(aria...)).

Comment on lines +369 to +371
":hover": hoverStyling,
":focus-visible": focusStyling,
":active": activePressedStyling,
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 will simplify how selectors work (I took a similar approach with IconButton).

@@ -34,5 +34,6 @@ export const inverse = {
borderRadius: border.radius.radius_080,
// This is a slightly darker color than the inverse color.
borderColor: pressColor,
background: `color-mix(in srgb, ${semanticColor.surface.primary} 5%, transparent)`,
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 change is to provide a slightly darker bg color when pressed. You'll see it here:

https://www.chromatic.com/test?appId=5e1bf4b385e3fb0020b7073c&id=68013f858f1709244ee14785

This change was made so we control a bit more the contrast ratio in the press state.

@jandrade jandrade marked this pull request as ready for review April 17, 2025 18:44
@khan-actions-bot khan-actions-bot requested a review from a team April 17, 2025 18:45
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/fluffy-donuts-drop.md, .changeset/grumpy-seas-crash.md, __docs__/wonder-blocks-button/button-variants.stories.tsx, __docs__/wonder-blocks-button/button.argtypes.ts, __docs__/wonder-blocks-button/button.stories.tsx, __docs__/wonder-blocks-modal/modal-dialog.stories.tsx, __docs__/wonder-blocks-modal/modal-panel.stories.tsx, __docs__/wonder-blocks-popover/popover-content.argtypes.tsx, __docs__/wonder-blocks-styles/action-styles-variants.stories.tsx, __docs__/wonder-blocks-styles/action-styles.stories.tsx, __docs__/wonder-blocks-toolbar/toolbar.argtypes.tsx, packages/wonder-blocks-button/src/components/button-core.tsx, packages/wonder-blocks-button/src/components/button.tsx, packages/wonder-blocks-button/src/themes/default.ts, packages/wonder-blocks-styles/src/styles/action-styles.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 Apr 17, 2025

npm Snapshot: Published

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

Packages can also be installed manually by running:

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

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! Left some questions in the PR and comments in the snapshots before approving in Chromatic 😄

Comment on lines +305 to +311
// NOTE: This is a workaround while we move
// this button to DAB and remove the
// `Button.khanmigo` theme.
{
background: "transparent",
":hover": {background: "transparent"},
},
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean call sites that use a ModalPanel with a secondary Button will also needed to apply this work around?

[":active:not([aria-disabled=true])" as any]:
activePressedStyling,
":hover": hoverStyling,
":focus-visible": focusStyling,
Copy link
Member

Choose a reason for hiding this comment

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

Will we move this to use the global focus styling later on? 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct, I didn't want to introduce too many visual changes in this PR, and I'm planning to cut a release with this change only for now. I checked in webapp and there are ~43 instances of Button.light, so I want to avoid having to include more changes than needed atm.

@jandrade jandrade merged commit 0b47477 into main Apr 24, 2025
14 checks passed
@jandrade jandrade deleted the rm-button-light branch April 24, 2025 15:44
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (da2b962) to head (6d406a7).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

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

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 da2b962...6d406a7. 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.

3 participants