Skip to content

feat(switch): s2 migration #2651

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 9 commits into from
Apr 15, 2024
Merged

feat(switch): s2 migration #2651

merged 9 commits into from
Apr 15, 2024

Conversation

mdt2
Copy link
Collaborator

@mdt2 mdt2 commented Apr 9, 2024

Description

Migrate Switch component to align with Spectrum 2 design spec. Includes:

  • Make medium t-shirt size the default, removing .spectrum-Switch--sizeM class
  • Rework of Windows High Contrast Mode to only need custom prop reassignment to work (no more custom CSS for WHCM)
  • Refactor states to be within their parent for ease of reading and editing the code in the future
  • Update story instances and add Chromatic coverage where possible
  • Mod changes. A lot of mods had to be updated for this migration because of the design changes for this component (addition of a track border, handle color change, removal of border on handle, etc). You can find documentation for the affected mods here: https://github.com/adobe/spectrum-css/pull/2651/files#diff-502c3aa8ef2c53072543f6bfaaf332e97df6f71e8bc80f4e402c351a07c8c9bdR9-R56

How and where has this been tested?

Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.

Validation steps

For Default and Emphasized in Storybook, validate these cases: @rise-erpelding

  • Unchecked
  • Unchecked hover
  • Unchecked active
  • Unchecked with keyboard focus
  • Unchecked disabled (ensure no hover state or transforms occur)
  • Checked
  • Checked hover
  • Checked active
  • Checked with keyboard focus
  • Checked disabled (ensure no hover state or transforms occur)

Other validation steps:

Regression testing

Validate:

  1. The documentation pages for at least two other components are still loading, including:
  • The pages render correctly, are accessible, and are responsive.
  1. If components have been modified, VRTs have been run on this branch:
  • VRTs have been run and looked at.
  • Any VRT changes have been accepted (by reviewer and/or PR author), or there are no changes.

To-do list

  • I have read the contribution guidelines.
  • I have updated relevant storybook stories and templates.
  • I have tested these changes in Windows High Contrast mode.
  • If my change impacts documentation, I have updated the documentation accordingly.
  • ✨ This pull request is ready to merge. ✨

@mdt2 mdt2 added the run_vrt For use on PRs looking to kick off VRT label Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

🚀 Deployed on https://pr-2651--spectrum-css.netlify.app

Copy link
Contributor

github-actions bot commented Apr 9, 2024

File metrics

Summary

Total size: 4.55 MB*
Total change (Δ): ⬇ 0.60 KB (-0.01%)

Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.

Package Size Δ
switch 26.36 KB ⬆ 0.96 KB

Details

switch

File Head Base Δ
index-base.css 26.36 KB 24.08 KB ⬆ 2.28 KB (9.47%)
index-vars.css 26.36 KB 25.43 KB ⬆ 0.96 KB (3.68%)
index.css 26.36 KB 25.43 KB ⬆ 0.96 KB (3.68%)
metadata.json 12.61 KB 12.92 KB ⬇ 0.32 KB (-2.40%)
index-theme.css - 1.92 KB 🚨 deleted, moved, or renamed
themes/express.css - 1.26 KB 🚨 deleted, moved, or renamed
themes/spectrum.css - 1.25 KB 🚨 deleted, moved, or renamed
* Size determined by adding together the size of the main file for all packages in the library.
* Results are not gzipped or minified.
* An ASCII character in UTF-8 is 8 bits or 1 byte.

@mdt2 mdt2 force-pushed the mdt2/css-716-s2-switch branch 4 times, most recently from bfc4743 to b8c836e Compare April 9, 2024 18:14
Copy link
Collaborator

@rise-erpelding rise-erpelding left a comment

Choose a reason for hiding this comment

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

This is looking really nice! It matches the design spec and the new/updated tokens! My main callouts below are questions because I'm still relatively new here.

I was also wondering about the switch animation, it looks like some things about it may have unintentionally changed, when clicking the switch from off to on, the switch animates the way I'd expect it to (I click, and on mouse up I see the switch handle transform from left to right at the same time that the color transitions). When clicking the switch from on to off, though, the switch handle moves left on mouse down and the color transitions on mouse up, which is a change from the previous version:

switch-animation.mov

Copy link
Collaborator

@jawinn jawinn 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 great, including the Storybook Chromatic template and the down state. I only noticed two small things and have one Storybook suggestion.

Checked state corners

I noticed one oddity in the way the corners are appearing when the Switch is in the checked state. The edges look a little squared off as compared to when it is unchecked (Chrome, non-retina monitor).
Screenshot 2024-04-11 at 4 41 12 PM
I experimented in the inspector a little bit and if I set the ::after pseudo element to an opacity of 0, the jaggedness goes away. It looks like this has a border and it's not playing well when it's layered on top of the background in the same spot; is this element needed or only for high contrast mode?

High contrast selected

The circle looks a little hard to read for me with the white (CanvasText?) on top of Highlight. I'm wondering if it's be better to use a contrasting HighlightText here for the circle.
Screenshot 2024-04-11 at 4 50 24 PM

Suggestion: focused in Storybook

Would it be possible to also show the focused state in Storybook, like it was added recently for ActionButton? It'd be good to have that captured in VRTs if possible.

@mdt2 mdt2 force-pushed the mdt2/css-716-s2-switch branch from 3d27683 to 1319996 Compare April 12, 2024 17:43
@mdt2
Copy link
Collaborator Author

mdt2 commented Apr 12, 2024

@jawinn thanks for the feedback! Some answers:

  • Checked state corners - Good question. The ::after pseudo element is used for the focus state. So setting ::after to opacity: 0 breaks the focus state. I don't have access to a non-retina monitor, so I'll need you to double check if my solution attempt worked, but what I did was move the border to .spectrum-Switch-switch in hopes that having the border and the background-color in the same place might help.

  • High contrast selected - Great suggestion, thank you! I've updated to HighlightText

  • Suggestion: focused in Storybook - While it would be nice to have coverage in Chromatic for these states, when we wire that up in Storybook (example in ActionButton), it adds classes like is-hover and is-focus-visible to the markup (image below)... In the past we've made the choice not to add a class in Storybook if the component wouldn't get a class normally (like in the case of .is-keyboardFocused where we have CSS associated with that class). It feels like we need to have a bigger discussion of what our standard should be here

    • Screen_Shot_2024-04-12_at_2_10_05_PM

@mdt2 mdt2 force-pushed the mdt2/css-716-s2-switch branch from 9ee8f19 to 69f7469 Compare April 12, 2024 18:32
@mdt2 mdt2 requested review from jawinn and rise-erpelding April 12, 2024 18:33
castastrophe pushed a commit that referenced this pull request Apr 30, 2024
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Apr 30, 2024
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
pfulton pushed a commit that referenced this pull request May 1, 2024
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
pfulton pushed a commit that referenced this pull request May 3, 2024
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
rise-erpelding pushed a commit that referenced this pull request May 7, 2024
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
pfulton pushed a commit that referenced this pull request May 10, 2024
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
@rise-erpelding rise-erpelding added the S2 Spectrum 2 label Sep 3, 2024
castastrophe pushed a commit that referenced this pull request Dec 27, 2024
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Dec 29, 2024
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Dec 29, 2024
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
aramos-adobe pushed a commit that referenced this pull request Jan 9, 2025
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Jan 17, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Jan 17, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Jan 21, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
aramos-adobe pushed a commit that referenced this pull request Jan 22, 2025
* feat(switch): s2 migration

* chore: remove themes

* fix: animation

* fix: whcm light mode unchecked handle shows

* docs(storybook): align chromatic setup with new standard

* fix: checked corners for non-retina display

* fix: whcm handle selected color

* fix: namespace mods, use semantic tokens instead of global

* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Jan 22, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 5, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 7, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 7, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 7, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 11, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 24, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 24, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
castastrophe pushed a commit that referenced this pull request Feb 25, 2025
* feat(switch): s2 migration
* chore: remove themes
* fix: animation
* fix: whcm light mode unchecked handle shows
* docs(storybook): align chromatic setup with new standard
* fix: checked corners for non-retina display
* fix: whcm handle selected color
* fix: namespace mods, use semantic tokens instead of global
* fix: handle state colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review run_vrt For use on PRs looking to kick off VRT S2 Spectrum 2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants