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-1797] Address cell color contrast a11y issues #2435

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

Conversation

beaesguerra
Copy link
Member

@beaesguerra beaesguerra commented Jan 20, 2025

Summary:

Updating state styles based on the new designs to address color contrast issues: https://www.figma.com/design/qSKXmIvmsNPKFlQNP5cztQ?node-id=4337-8746#1091493830

Styles to highlight:

  • If a cell is selected (active: true), there is no hover and pressed state since clicking on the cell will bring the user to the same page. It continues to be focusable
  • Press state and selected states now have left visual indicators of different widths so that color is not the only indicator
  • The disabled focus outline is now using the disabled color token
  • See changeset for more specific details on the style changes

A new primitive color token is also added: fadedOffBlack72. This is the new value for semanticColor.text.secondary. This is a darker gray that has better color contrast with a fadedBlue8 background

Issue: WB-1797

Test plan:

  • Confirm DetailCell and CompactCell have no color contrast issues and the styling of the states are expected
    • DetailCell ?path=/docs/packages-cell-detailcell-all-variants--docs
    • CompactCell ?path=/docs/packages-cell-compactcell-all-variants--docs
  • Testing the snapshot with webapp: https://prod-znd-250120-28792-a2bc7f4.khanacademy.org/

@beaesguerra beaesguerra self-assigned this Jan 20, 2025
Copy link
Contributor

github-actions bot commented Jan 20, 2025

Size Change: +179 B (+0.18%)

Total Size: 97.8 kB

Filename Size Change
packages/wonder-blocks-cell/dist/es/index.js 2.18 kB +173 B (+8.62%) 🔍
packages/wonder-blocks-tokens/dist/es/index.js 2.53 kB +6 B (+0.24%)
ℹ️ 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-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.8 kB
packages/wonder-blocks-form/dist/es/index.js 5.87 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.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.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 20, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 123
Tests with visual changes 1
Total stories 526
Inherited (not captured) snapshots [TurboSnap] 261
Tests on the build 384

Copy link

changeset-bot bot commented Jan 20, 2025

🦋 Changeset detected

Latest commit: 018a3b9

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 Minor
@khanacademy/wonder-blocks-cell Patch
@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-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

@beaesguerra beaesguerra force-pushed the wb-1797-cell-color-contrast branch from 080eab9 to 962fe64 Compare January 20, 2025 23:13
@@ -94,7 +94,7 @@ const DetailCell = function (props: DetailCellProps): React.ReactElement {

const styles = StyleSheet.create({
subtitle: {
color: color.offBlack64,
color: "#6D6F74", // TODO: use token
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm getting feedback from design on if we can use a token for the new subtitle color (or if this is a one-off): https://www.figma.com/design/qSKXmIvmsNPKFlQNP5cztQ?node-id=19669-5006#1098834936

@beaesguerra beaesguerra marked this pull request as ready for review January 20, 2025 23:15
@khan-actions-bot khan-actions-bot requested a review from a team January 20, 2025 23:15
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Jan 20, 2025

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/shiny-chicken-speak.md, .changeset/wise-actors-peel.md, types/aphrodite.d.ts, __docs__/wonder-blocks-cell/compact-cell-variants.stories.tsx, __docs__/wonder-blocks-cell/detail-cell-variants.stories.tsx, __docs__/wonder-blocks-cell/detail-cell.stories.tsx, packages/wonder-blocks-cell/src/components/detail-cell.tsx, packages/wonder-blocks-tokens/src/tokens/color.ts, packages/wonder-blocks-tokens/src/tokens/semantic-color.ts, packages/wonder-blocks-cell/src/components/internal/cell-core.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

github-actions bot commented Jan 20, 2025

npm Snapshot: Published

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

Packages can also be installed manually by running:

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

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing I noticed about DetailCell is that it is used by OptionItem. The updated styles aren't propagated to the OptionItems in the dropdown component because OptionItem overrides a lot of the styles. Is it expected that DetailCell and OptionItem have different styling?

Copy link
Member

Choose a reason for hiding this comment

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

hmm good question... I would say that it's better to have different styling as OptionItems tend to be closer to "action" styles (like the button ones). My recommendation for now would be to keep it as it is for now. We could ask Design in case they want to revisit the styling for dropdowns if we want to be more consistent of course :).

@beaesguerra beaesguerra force-pushed the wb-1797-cell-color-contrast branch from ae53bdc to 6d0b1d5 Compare January 21, 2025 21:40
@beaesguerra beaesguerra marked this pull request as draft January 21, 2025 22:08
@beaesguerra
Copy link
Member Author

Converting this PR to a draft while I get some feedback on introducing a new token for the cell subtitle text (a darked fadedOffBlack value. I put together a story to show potential alternatives and will remove it once finalized!

…OffBlack shades for text on light blue backgrounds"

This reverts commit 6d0b1d5.
… semantic text secondary token to new darker gray so it works with fadedBlue8 backgrounds
… color primitive token and sets the text secondary token to this primitive. The slightly darker gray has better color contrast on a variety of backgrounds, including the fadedBlue8 background
Copy link
Member Author

Choose a reason for hiding this comment

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

This is similar to the detail-cell-variants stories, but for CompactCell! I approved the initial Chromatic diff for adding these stories so that the diff will only show the changes in the new styles. Let me know if you have any questions!

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! thanks for the heads up.

@beaesguerra beaesguerra marked this pull request as ready for review January 22, 2025 20:37
Copy link
Member

@jandrade jandrade 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 really solid! The only "blocking" think is that I noticed an issue with this story: https://5e1bf4b385e3fb0020b7073c-ekfutacxua.chromatic.com/?path=/story/packages-dropdown-multiselect--custom-styles-opened, but maybe it's something that needs to be addressed in the story example?

Copy link
Member

Choose a reason for hiding this comment

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

praise: This is the best changelog I've seen in this repo 👏

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! thanks for the heads up.

@@ -4,7 +4,7 @@ import {MemoryRouter, Route, Switch} from "react-router-dom";
import type {Meta, StoryObj} from "@storybook/react";

import {View} from "@khanacademy/wonder-blocks-core";
import {color, spacing} from "@khanacademy/wonder-blocks-tokens";
import {border, color, spacing} from "@khanacademy/wonder-blocks-tokens";
Copy link
Member

Choose a reason for hiding this comment

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

super-nit: Would it be possible to replace color with semanticColor here? no worries is you can't, but I've been doing that with my current PRs as the end goal is to use examples to advocate for using these colors instead of primitive ones.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will do this in a follow up PR and release the changes together!

Copy link
Member

Choose a reason for hiding this comment

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

hmm good question... I would say that it's better to have different styling as OptionItems tend to be closer to "action" styles (like the button ones). My recommendation for now would be to keep it as it is for now. We could ask Design in case they want to revisit the styling for dropdowns if we want to be more consistent of course :).


// hover + enabled
[":hover[aria-disabled=false]" as any]: {
background: color.offBlack8,
background: color.fadedBlue8,
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: You could probably use semanticColor.status.notice.background here (and in all the similar cases in this file).

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll switch to using semantic tokens in a follow up PR and include this! Thanks for the suggestion!

…or so that we don't set overflow: hidden on clickable items since that was causing layout issues in OptionItems for dropdown components
@khan-actions-bot khan-actions-bot requested a review from a team January 22, 2025 23:32
// state because setting the styles on the clickable element
// directly causes issues since overflow must be hidden for cases where
// the border is rounded
[":active[aria-disabled=false]:not([aria-current=true]) > *:first-child" as any]:
Copy link
Member Author

Choose a reason for hiding this comment

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

This selector 😅 Let me know if there's a better way to do this!

More context:

  • This addresses the issue caught in Chromatic where providing a maxHeight to the MultiSelect caused the OptionItems to overlap. This was introduced when adding overflow: hidden to the root of the cell
  • We need the overflow: hidden because there are custom overrides in webapp that sets the border-radius on DetailCell and we want to make sure the new left bar indicator stays within the cell
  • To fix this, the overflow: hidden and the left bar indicator :before styling is moved to the innerWrapper of the cell, instead of the root
  • Since the pressed styling (:active) is on the root element, we use > *:first-child to access to innerWrapper

Alternatives I considered:

  • keep track of pressed state using JS and apply pressed styles directly to the innerWrapper (won't be able to capture :active state in visual regression tests)
  • using an alternative way to apply the left bar indicator where we don't have to set overflow: hidden

@beaesguerra beaesguerra requested a review from jandrade January 22, 2025 23:55
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