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-1847: Dropdown - Update SelectOpener to match design specs #2422

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

Conversation

jandrade
Copy link
Member

@jandrade jandrade commented Jan 10, 2025

Summary:

The dropdown opener currently uses a darkBlue/transparent background and that
could cause accessibility issues (color contrast). These styles are not matching
the current Figma specs, which use a white background.

Also, took the opportunity to switch from color to semanticColor in most of
the cases of that component.

Specific style changes:

  • Light version: Changed from darkBlue to a white background, and also changed the disabled state to use disabled semantic colors instead of blue shades.
  • Switched from border to outline when focused/active for better consistency across the library.
  • Modified focus/active outlines to be inset (located inside the box).
  • Fixed the pressed/placeholder state to use an activeBlue text color.

New semanticColor tokens

Additionally, I've added a couple of new tokens in semanticColor to include
some missing colors that are defined in Figma.

https://www.figma.com/design/VbVu3h2BpBhH80niq101MHHE/%F0%9F%92%A0-Main-Components?node-id=17450-482&t=jCX4iO74AL9fsTwh-4

Screenshot 2025-01-10 at 12 44 33 PM

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

Test plan:

Navigate to /?path=/story/packages-dropdown-singleselect--light and verify that
the SelectOpener component now has a white background.

Also verify all the variants in /?path=/docs/packages-dropdown-singleselect-all-variants--docs

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

changeset-bot bot commented Jan 10, 2025

🦋 Changeset detected

Latest commit: 3ae0350

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-dropdown Minor
@khanacademy/wonder-blocks-tokens Minor
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-breadcrumbs Patch
@khanacademy/wonder-blocks-button Patch
@khanacademy/wonder-blocks-cell Patch
@khanacademy/wonder-blocks-clickable 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

Copy link
Contributor

github-actions bot commented Jan 10, 2025

Size Change: +131 B (+0.14%)

Total Size: 96.6 kB

Filename Size Change
packages/wonder-blocks-dropdown/dist/es/index.js 19.2 kB +115 B (+0.6%)
packages/wonder-blocks-tokens/dist/es/index.js 2.37 kB +16 B (+0.68%)
ℹ️ 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-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 72 B
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 10, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

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

Comment on lines -152 to -154
? disabled || error
? "currentColor"
: tokens.color.white
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 was no longer needed, so I got rid of this (now light uses a similar style compared to the default version).

Comment on lines -239 to -243
// These values are default padding (16 and 12) minus 1, because
// changing the borderWidth to 2 messes up the button width
// and causes it to move a couple pixels. This fixes that.
const adjustedPaddingLeft = tokens.spacing.medium_16 - 1;
const adjustedPaddingRight = tokens.spacing.small_12 - 1;
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 hack is no longer needed now that we use outline instead of border.

cursor: "not-allowed",
":focus-visible": {
boxShadow: `0 0 0 1px ${tokens.color.white}, 0 0 0 3px ${tokens.color.offBlack32}`,
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: Also changed this box-shadow to outline for consistency.

@jandrade jandrade marked this pull request as ready for review January 10, 2025 17:51
@khan-actions-bot khan-actions-bot requested a review from a team January 10, 2025 17:52
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/tender-points-melt.md, .changeset/yellow-mails-fold.md, __docs__/foundations-color.mdx, __docs__/wonder-blocks-dropdown/multi-select-variants.stories.tsx, __docs__/wonder-blocks-dropdown/single-select-variants.stories.tsx, __docs__/wonder-blocks-dropdown/single-select.stories.tsx, packages/wonder-blocks-dropdown/src/components/select-opener.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

npm Snapshot: Published

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

Packages can also be installed manually by running:

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

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.

Thanks for updating our components to match the designs more and use more semantic tokens 😄 Left some comments and questions in the PR and in Chromatic!

@@ -9,10 +9,12 @@ export const semanticColor = {
primary: {
default: color.blue,
active: color.activeBlue,
pressing: color.fadedBlue,
Copy link
Member

Choose a reason for hiding this comment

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

question (non-blocking): In our tokens meeting last week, we were chatting about active vs pressed naming and decided to go with the pressed (or is it press) naming since it doesn't have to match the CSS names. I see we have active and pressing token names from the original semantic colors in Figma. Do we want to start moving towards that, or is that a later thing we want to handle?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for bringing this up! As we discussed in the WB cubby meeting, I'm going to rename this to press.foreground and active will change to press.background.

// Provides an outline around the button to match the border width
outlineOffset: -(tokens.border.width.thin + borderWidth),
outlineStyle: "solid",
outlineWidth: tokens.border.width.thin,
Copy link
Member

Choose a reason for hiding this comment

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

The outline in Figma visually is 3px wide instead of 2! In Figma, it's shown with a 2px border and a shadow with 1px spread (I think it's fine we've simplified it to using only an outline!). We don't have a border width token for 3px though. Would this be a one-off, a new token, or an update to the designs so it uses 2px instead? Let me know what you think!

image

The error outline when light=true is 2px though!
image

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm yeah, tbh that's a bit confusing. In Figma, they are using border: inset, 2px for the normal outline, but I see it translated as 3px. I'll bring this topic today to our WB sync meeting.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, based on the last WB cubby discussion, I'll use the same focus that we use with TextField/TextArea for better consistency.

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