Skip to content

Commit

Permalink
fix(switch): Refactor switch styles to show up in HC windows mode. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aprigogin committed Jun 1, 2018
1 parent 9b2c6a1 commit ef159c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 13 additions & 1 deletion packages/mdc-switch/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
@mixin mdc-switch-track-color($color) {
.mdc-switch__native-control:enabled:checked ~ .mdc-switch__background::before {
@include mdc-theme-prop(background-color, $color);
@include mdc-theme-prop(border-color, $color);
}
}

@mixin mdc-switch-knob-color($color) {
// stylelint-disable-next-line selector-max-specificity
.mdc-switch__native-control:enabled:checked ~ .mdc-switch__background .mdc-switch__knob {
@include mdc-theme-prop(background-color, $color);
@include mdc-theme-prop(border-color, $color);
}
}

Expand All @@ -48,13 +50,15 @@
@mixin mdc-switch-unchecked-track-color_($color) {
.mdc-switch__native-control:enabled:not(:checked) ~ .mdc-switch__background::before {
@include mdc-theme-prop(background-color, $color);
@include mdc-theme-prop(border-color, $color);
}
}

@mixin mdc-switch-unchecked-knob-color_($color) {
// stylelint-disable-next-line selector-max-specificity
.mdc-switch__native-control:enabled:not(:checked) ~ .mdc-switch__background .mdc-switch__knob {
@include mdc-theme-prop(background-color, $color);
@include mdc-theme-prop(border-color, $color);
}
}

Expand All @@ -65,10 +69,18 @@
}
}

@mixin mdc-switch-tap-target_ {
@mixin mdc-switch-native-control_ {
position: absolute;
top: -14px;
left: -14px;
width: $mdc-switch-focus-ring-diameter;
height: $mdc-switch-focus-ring-diameter;
}

@mixin mdc-switch-tap-target_ {
position: absolute;
top: -24px;
left: -24px;
width: $mdc-switch-focus-ring-diameter;
height: $mdc-switch-focus-ring-diameter;
}
14 changes: 11 additions & 3 deletions packages/mdc-switch/mdc-switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
position: relative;

&__native-control {
@include mdc-switch-tap-target_;
@include mdc-switch-native-control_;

display: inline-block;
margin-top: $mdc-switch-knob-vertical-offset_;
margin-left: 0;
transition: mdc-switch-transition(transform);
opacity: 0;
cursor: pointer;
Expand Down Expand Up @@ -73,7 +74,9 @@
left: 0;
transition:
mdc-switch-transition(opacity),
mdc-switch-transition(background-color);
mdc-switch-transition(background-color),
mdc-switch-transition(border-color);
border: 1px solid;
border-radius: 7px;
opacity: .38;
content: "";
Expand All @@ -87,12 +90,15 @@
display: block;
position: absolute;
top: $mdc-switch-knob-vertical-offset_;
box-sizing: border-box;
width: $mdc-switch-knob-diameter;
height: $mdc-switch-knob-diameter;
transform: translateX(0);
transition:
mdc-switch-transition(transform),
mdc-switch-transition(background-color);
mdc-switch-transition(background-color),
mdc-switch-transition(border-color);
border: $mdc-switch-knob-diameter / 2 solid;
border-radius: 50%;
z-index: 1;

Expand Down Expand Up @@ -149,6 +155,8 @@
}

.mdc-switch__knob {
border-width: 1px; // In high contrast mode, only show outline of the knob.
border-color: $mdc-switch-disabled-knob-color;
background-color: $mdc-switch-disabled-knob-color;
}
}

0 comments on commit ef159c8

Please sign in to comment.