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-1814.2] Refactor TextField and TextArea to use semantic colors #2440

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

jandrade
Copy link
Member

Summary:

  • Form: Migrated color instances to use semanticColor internally in
    TextField and TextArea.

  • Tokens: Added border.focus semantic color token to use for the focus outline

Issue: WB-1814

Test plan:

Navigate to the Storybook for TextField and TextArea components and verify
that the colors are looking as expected.

  • /?path=/docs/packages-form-textarea--docs
  • /?path=/docs/packages-form-textfield--docs

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

changeset-bot bot commented Jan 22, 2025

🦋 Changeset detected

Latest commit: b4b0762

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-form Patch
@khanacademy/wonder-blocks-tokens Minor
@khanacademy/wonder-blocks-search-field 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-cell Patch
@khanacademy/wonder-blocks-clickable Patch
@khanacademy/wonder-blocks-dropdown 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-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 22, 2025 20:17
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/ninety-radios-reflect.md, .changeset/spicy-grapes-invite.md, __docs__/wonder-blocks-form/text-area-variants.stories.tsx, __docs__/wonder-blocks-form/text-area.stories.tsx, __docs__/wonder-blocks-form/text-field.stories.tsx, __docs__/wonder-blocks-search-field/search-field-variants.stories.tsx, packages/wonder-blocks-form/src/components/field-heading.tsx, packages/wonder-blocks-form/src/components/text-area.tsx, packages/wonder-blocks-form/src/components/text-field.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 22, 2025

npm Snapshot: Published

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

Packages can also be installed manually by running:

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

Copy link
Contributor

github-actions bot commented Jan 22, 2025

Size Change: +190 B (+0.19%)

Total Size: 98 kB

Filename Size Change
packages/wonder-blocks-form/dist/es/index.js 6.05 kB +181 B (+3.08%)
packages/wonder-blocks-tokens/dist/es/index.js 2.53 kB +9 B (+0.36%)
ℹ️ 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 18.9 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 22, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

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

Comment on lines +139 to +148
color: semanticColor.text.primary,
},
description: {
color: color.offBlack64,
color: semanticColor.text.secondary,
},
error: {
color: color.red,
color: semanticColor.status.critical.foreground,
},
required: {
color: color.red,
color: semanticColor.status.critical.foreground,
Copy link
Member

Choose a reason for hiding this comment

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

So clean and straightforward 🤩

"::placeholder": {
color: color.offBlack64,
color: semanticColor.text.secondary,
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here around if we want to have a separate token for placeholder text color! (comment from other PR: #2438 (comment))

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed with Design and they are good with this approach.

border: `1px solid ${color.red}`,
color: color.offBlack,
background: semanticColor.status.critical.background,
border: `${border.width.hairline}px solid ${semanticColor.status.critical.foreground}`,
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to have semanticColor.status.critical.border here and in the focus-visible state?

Copy link
Member Author

Choose a reason for hiding this comment

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

As mentioned in other PRs, the goal is to keep status as it is. I'll create a ticket to also simplify the action tokens once we have something more defined a more stable visual direction for the new experience.

@@ -4,6 +4,7 @@ const border = {
primary: color.fadedOffBlack16,
subtle: color.fadedOffBlack8,
strong: color.fadedOffBlack50,
focus: color.blue,
Copy link
Member

Choose a reason for hiding this comment

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

🎉

Copy link
Member

Choose a reason for hiding this comment

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

Same comments from TextArea for TextField since they have similar styles!

@jandrade jandrade requested a review from beaesguerra January 27, 2025 16:18
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! 🚀

@jandrade jandrade merged commit c162abb into main Jan 28, 2025
14 checks passed
@jandrade jandrade deleted the form-text-semantic branch January 28, 2025 22:09
Copy link

codecov bot commented Jan 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (c774f7d) to head (b4b0762).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

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

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 c774f7d...b4b0762. Read the comment docs.

jandrade added a commit that referenced this pull request Jan 31, 2025
## Summary:

Continuing with the semantic colors migration, this PR covers the `Switch`
component.

- Refactored the `Switch` themes to use semantic colors.
- Added `All Variants` story to switch.
- Disabled chromatic snapshots for existing stories (now using All Variants).

### Implementation plan:

1. #2439
2. #2440
3. Switch (current PR)
4. Accordion, Banner, BirthdayPicker
5. IconButton
6. Clickable, Link
7. Modal
8. Popover, Tooltip
9. Pill, Toolbar


Issue: WB-1814

## Test plan:

- Navigate to /?path=/story/packages-switch-switch-all-variants--default
- Verify that the styles are correct.

Author: jandrade

Reviewers: jandrade, beaesguerra

Required Reviewers:

Approved By: beaesguerra

Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Chromatic - Build and test on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ gerald, ⏭️  dependabot

Pull Request URL: #2441
jandrade added a commit that referenced this pull request Jan 31, 2025
…c colors (#2446)

## Summary:

Next step is to refactor the `Accordion`, `Banner`, and `BirthdayPicker`
components to use semantic colors.

### Implementation plan:

1. #2439
2. #2440
3. #2441
4. Accordion, Banner, BirthdayPicker (current PR)
5. IconButton
6. Clickable, Link
7. Modal
8. Popover, Tooltip
9. Pill, Toolbar


Issue: WB-1814

## Test plan:

Verify that the Chromatic snapshots are unchanged.

Author: jandrade

Reviewers: jandrade, beaesguerra

Required Reviewers:

Approved By: beaesguerra

Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Chromatic - Build and test on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ⏭️  dependabot

Pull Request URL: #2446
jandrade added a commit that referenced this pull request Jan 31, 2025
## Summary:

Next step is to refactor the `IconButton` component to use semantic colors.

Besides the migration, this PR also includes the following changes:

- Reworked the theme structure to make it closer to the semanticColor structure.
- Moved all the color-related CSS properties to a separate function (`getStylesByKind`).
- Added `border` to all the states to prepare the work for Polaris as these
icon buttons will look similar to the Button ones.

### Implementation plan:

1. #2439
2. #2440
3. #2441
4. #2446
5. IconButton (current PR)
6. Clickable, Link
7. Modal
8. Popover, Tooltip
9. Pill, Toolbar


Issue: WB-1814

## Test plan:

Verify that the Chromatic snapshots are unchanged.

URL: `/?path=/story/packages-iconbutton-all-variants--default`

Author: jandrade

Reviewers: jandrade, marcysutton, beaesguerra

Required Reviewers:

Approved By: marcysutton, beaesguerra

Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Chromatic - Build and test on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ⏭️  dependabot

Pull Request URL: #2449
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