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

Increase contrast of switch track and thumb #5484

Merged
merged 4 commits into from
Mar 19, 2025
Merged

Conversation

jmuzina
Copy link
Member

@jmuzina jmuzina commented Mar 6, 2025

Done

  • Increases color contrast of the switch track and thumb by applying the high border contrast color to the thumb border and the entirety of the track.
  • Simplifies the switch by removing external borders (except in the focused state) and box shadows
  • Flattens the high contrast border color in order to allow it to be drawn over the thumb background without influencing the color of the thumb border.

Fixes #5470 , WD-19209

QA

  • Open switch component
  • Verify it looks as expected in all color themes
  • Make sure to check the focused state

Check if PR is ready for release

If this PR contains Vanilla SCSS or macro code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention
    • if existing APIs (CSS classes & macro APIs) are not changed it can be a bugfix release (x.x.X)
    • if existing APIs (CSS classes & macro APIs) are changed/added/removed it should be a minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) or macros should be listed on the what's new page.

Screenshots

image
image
image

Sorry, something went wrong.

@webteam-app
Copy link

@jmuzina jmuzina requested a review from lyubomir-popov March 6, 2025 19:56
@jmuzina
Copy link
Member Author

jmuzina commented Mar 6, 2025

As far as I understand the source issue #5470 , there are also some changes that need to be made to the figma library, that are not in scope of this PR.

@jmuzina jmuzina marked this pull request as ready for review March 6, 2025 20:16
@jmuzina jmuzina requested a review from advl March 7, 2025 14:05
@lyubomir-popov
Copy link
Contributor

lyubomir-popov commented Mar 7, 2025

@jmuzina almost there! Can we please make the thumb border the same high contrast grey, for consistency? ATM, in the on state, it is blue and overlaps the border of the track, the two should match:
image

@jmuzina
Copy link
Member Author

jmuzina commented Mar 7, 2025

@jmuzina almost there! Can we please make the thumb border the same high contrast grey, for consistency? ATM, in the on state, it is blue and overlaps the border of the track, the two should match

@lyubomir-popov

The high contrast border color has some transparency, and is drawn over areas with different background colors so it appears differently over the track vs the thumb:

Screenshot 2025-03-07 at 10 12 42 Screenshot 2025-03-07 at 10 20 18

Is this an expected result? Otherwise, we could flatten the high contrast border color.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@jmuzina
Copy link
Member Author

jmuzina commented Mar 11, 2025

Explored two possible directions for the switch to go with @lyubomir-popov

  1. Flatten the high contrast border color & apply it on the border of the entire component, for a consistent outline color.
Screenshot 2025-03-11 at 09 23 07
  1. Get rid of the outline & box shadows entirely, use a more flat approach where the track area and thumb area both have uniform color throughout. This is similar to Carbon's approach.
Screenshot 2025-03-11 at 09 28 43

@jmuzina
Copy link
Member Author

jmuzina commented Mar 12, 2025

Discussed with @lyubomir-popov and Diana: We will go for option 2 above. I'll update this PR accordingly

@jmuzina jmuzina marked this pull request as draft March 12, 2025 13:10
advl
advl previously approved these changes Mar 12, 2025
@jmuzina
Copy link
Member Author

jmuzina commented Mar 12, 2025

@lyubomir-popov I've updated the PR per our recent discussions.

I also flattened the high contrast border color to get rid of the very slight discoloration visible in the "off" state when the high contrast border color has transparency:

Before:
image
After:
image

This color settings change also effects other components that use the high contrast border. Have a look at the visual regression test and let me know if anything unexpected has changed.

@jmuzina
Copy link
Member Author

jmuzina commented Mar 13, 2025

Diana has some questions about potential improvements to the focus state. These will be discussed during visual office hours on Monday.

@jmuzina jmuzina marked this pull request as ready for review March 18, 2025 14:25
@lyubomir-popov
Copy link
Contributor

@jmuzina I've approved the percy build, nothing looks out of place to me.

@advl advl merged commit 6b34f84 into main Mar 19, 2025
11 checks passed
@jmuzina jmuzina deleted the WD-19209-switch-contrast branch March 19, 2025 13:50
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.

[Component amendment]: <Switch>
4 participants