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

[v4] [core] fix(Switch): fix text color and indicator border #5058

Merged
merged 4 commits into from
Dec 6, 2021

Conversation

johnly13
Copy link
Contributor

@johnly13 johnly13 commented Dec 3, 2021

Fixes #5046 (comment)

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

  • Uses normal button box-shadow instead of inset box-shadow for dark switch indicators
  • Fixes text colors for switches
  • Removes borders for disabled switch indicator
  • Fixes dark switch indicator background colors

Reviewers should focus on:

Screenshot

Before After
Screen Shot 2021-12-03 at 15 32 47 Screen Shot 2021-12-06 at 14 32 02
Screen Shot 2021-12-03 at 15 32 52 Screen Shot 2021-12-06 at 14 32 08
Screen Shot 2021-12-03 at 15 32 57 Screen Shot 2021-12-06 at 17 17 44
Screen Shot 2021-12-03 at 15 33 03 Screen Shot 2021-12-06 at 17 17 49

(note: I think the indicator looks off center vertically in some of these screenshots. I think this is an artifact of zooming in + screenshotting, rather than how they actually are styled)

@@ -48,13 +48,13 @@ $button-box-shadow-overlay-active:
inset 0 1px 1px rgba($black, 0.1) !default;

$dark-button-box-shadow:
inset 0 0 0 1px rgba(17, 20, 24, 0.8) !default;
inset 0 0 0 $button-border-width rgba($black, 0.8) !default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

using variables instead of hardcoded values

@@ -300,6 +300,10 @@ $control-indicator-spacing: $pt-grid-size !default;

$switch-indicator-text-font-size: 0.7em;

$switch-text-color: $pt-text-color !default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicitly setting text colors for switch's inner text (for light/dark and enabled/disabled)

@@ -321,19 +329,23 @@ $control-indicator-spacing: $pt-grid-size !default;
$switch-indicator-background-color: $white !default;
$switch-indicator-background-color-disabled: rgba($white, 0.8) !default;
$dark-switch-indicator-background-color: $dark-gray5 !default;
$dark-switch-indicator-box-shadow: 0 0 0 $button-border-width rgba($black, 0.8) !default;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicitly set dark switch indicator's box shadow to not be inset, to be consistent with other indicator box shadows.

@blueprint-bot
Copy link

Remove inset border for dark checked switch indicator

Previews: documentation | landing | table | modern colors demo

}

input:checked ~ .#{$ns}-control-indicator::before {
// inset shadow so it forms a dark line instead of blurring into the blue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since the box shadow is different now, we don't get this blurring effect anymore without the inset

@@ -275,104 +275,7 @@ table.#{$ns}-html-table {
}
}

// Contrast for switches
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed these overrides, now built in the backgrounds into switch variables


&::before {
background: $disabled-indicator-color;
box-shadow: none;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no borders for disabled switch indicator

@johnly13
Copy link
Contributor Author

johnly13 commented Dec 6, 2021

@adidahiya this PR should be ready for review now!

@blueprint-bot
Copy link

Fix switch indicator background colors and borders

Previews: documentation | landing | table | modern colors demo

Copy link
Contributor

@adidahiya adidahiya 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 kind of an an explosion of Sass variables... probably unnecessary complexity which makes the code harder to work with... but since that's kind of the existing code pattern for these styles, we can leave it as-is and try to refactor in a separate PR 🙃

code changes look fine, and visuals lgtm... I'll wait for @aycai for final design approval

@johnly13
Copy link
Contributor Author

johnly13 commented Dec 6, 2021

yeah, I was pretty sad adding all these new variables, but given that the switch styles have diverged slightly from the button styles, it didn't make sense to use the existing button variables. I'll think of ways to improve this in a follow up - I think low hanging fruit is to remove variables that are only used once (which I'd imagine there are a few of)

this is kind of an an explosion of Sass variables... probably unnecessary complexity which makes the code harder to work with... but since that's kind of the existing code pattern for these styles, we can leave it as-is and try to refactor in a separate PR 🙃

code changes look fine, and visuals lgtm... I'll wait for @aycai for final design approval

@aycai
Copy link
Contributor

aycai commented Dec 6, 2021

@johnly13 Shoot, didn't show switch with text in the mocks - light mode + enabled + disabled state text should be 60% opacity to match other states, but rest looks good!

@johnly13
Copy link
Contributor Author

johnly13 commented Dec 6, 2021

@johnly13 Shoot, didn't show switch with text in the mocks - light mode + enabled + disabled state text should be 60% opacity to match other states, but rest looks good!

Done - updated screenshots above as well!

@blueprint-bot
Copy link

60% opacity for light mode disabled text

Previews: documentation | landing | table | modern colors demo

@adidahiya adidahiya changed the title [v4] [core] fix(Switch): fix switch text color and indicator border [v4] [core] fix(Switch): fix text color and indicator border Dec 6, 2021
@adidahiya adidahiya merged commit 36bd511 into next Dec 6, 2021
@adidahiya adidahiya deleted the jl/fix-switch-button-borders branch December 6, 2021 22:27
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.

4 participants