151 lines
3.7 KiB
SCSS
151 lines
3.7 KiB
SCSS
@import "../variables";
|
|
@import "../mixins";
|
|
|
|
$switch-color: unquote("rgb(#{$color-primary})") !default;
|
|
$switch-text-color: unquote("rgb(#{$color-black})") !default;
|
|
$switch-thumb-off-color: unquote("rgb(#{$palette-grey-50})") !default;
|
|
$switch-track-on-color: unquote("rgba(#{$color-primary}, 0.5)") !default;
|
|
$switch-track-off-color: unquote("rgba(#{$color-black}, 0.26)") !default;
|
|
$switch-off-ripple-color: unquote("rgba(#{$color-black}, 0.4)") !default;
|
|
$switch-on-focus-color: unquote("rgba(#{$color-primary}, 0.26)") !default;
|
|
$switch-off-focus-color: unquote("rgba(#{$color-black}, 0.1)") !default;
|
|
$switch-disabled-thumb-color: unquote("rgb(#{$palette-grey-400})") !default;
|
|
$switch-disabled-track-color: unquote("rgba(#{$color-black}, 0.12)") !default;
|
|
$switch-disabled-text-color: unquote("rgba(#{$color-black}, 0.26)") !default;
|
|
|
|
$switch-total-height: 2.4 * $unit !default;
|
|
$switch-track-length: 3.6 * $unit !default;
|
|
$switch-track-height: 1.4 * $unit !default;
|
|
$switch-thumb-size: 2 * $unit !default;
|
|
$switch-thumb-on-color: $switch-color !default;
|
|
$switch-focus-init-size: .8 * $unit !default;
|
|
$switch-focus-size: $switch-total-height * 2 !default;
|
|
$switch-focus-diff: ($switch-focus-size - $switch-focus-init-size) / 2;
|
|
|
|
.field {
|
|
position: relative;
|
|
display: block;
|
|
height: $switch-total-height;
|
|
margin-bottom: 1.5 * $unit;
|
|
white-space: nowrap;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.text {
|
|
display: inline-block;
|
|
padding-left: $unit;
|
|
font-size: 1.4 * $unit;
|
|
line-height: $switch-total-height;
|
|
color: $switch-text-color;
|
|
white-space: nowrap;
|
|
vertical-align: top;
|
|
}
|
|
|
|
%switch {
|
|
position: relative;
|
|
display: inline-block;
|
|
width: $switch-track-length;
|
|
height: $switch-track-height;
|
|
margin-top: ($switch-total-height - $switch-track-height) / 2;
|
|
vertical-align: top;
|
|
cursor: pointer;
|
|
border-radius: $switch-track-height;
|
|
}
|
|
|
|
.thumb {
|
|
@include material-animation-default(.28s);
|
|
position: absolute;
|
|
top: ($switch-track-height - $switch-thumb-size) / 2;
|
|
width: $switch-thumb-size;
|
|
height: $switch-thumb-size;
|
|
cursor: pointer;
|
|
border-radius: 50%;
|
|
transition-property: left;
|
|
}
|
|
|
|
.ripple {
|
|
background-color: $switch-color;
|
|
opacity: .3;
|
|
transition-duration: 650ms;
|
|
}
|
|
|
|
.switch-on {
|
|
@extend %switch;
|
|
background: $switch-track-on-color;
|
|
|
|
.thumb {
|
|
@include shadow-3dp();
|
|
left: $switch-track-length - $switch-thumb-size;
|
|
background: $switch-thumb-on-color;
|
|
}
|
|
}
|
|
|
|
.switch-off {
|
|
@extend %switch;
|
|
background: $switch-track-off-color;
|
|
|
|
.thumb {
|
|
@include shadow-2dp();
|
|
left: 0;
|
|
background: $switch-thumb-off-color;
|
|
}
|
|
|
|
.ripple {
|
|
background: $switch-off-ripple-color;
|
|
}
|
|
}
|
|
|
|
%thumb-focus {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
box-sizing: border-box;
|
|
display: inline-block;
|
|
width: $switch-focus-init-size;
|
|
height: $switch-focus-init-size;
|
|
content: "";
|
|
background-color: transparent;
|
|
border-radius: 50%;
|
|
transform: translate(- $switch-focus-init-size / 2, - $switch-focus-init-size / 2);
|
|
}
|
|
|
|
.input {
|
|
width: 0;
|
|
height: 0;
|
|
overflow: hidden;
|
|
opacity: 0;
|
|
|
|
&:focus:not(:active) {
|
|
+ .switch-on > .thumb:before {
|
|
@extend %thumb-focus;
|
|
background-color: $switch-on-focus-color;
|
|
box-shadow: 0 0 0 $switch-focus-diff $switch-on-focus-color;
|
|
}
|
|
|
|
+ .switch-off > .thumb:before {
|
|
@extend %thumb-focus;
|
|
background-color: $switch-off-focus-color;
|
|
box-shadow: 0 0 0 $switch-focus-diff $switch-off-focus-color;
|
|
}
|
|
}
|
|
}
|
|
|
|
.disabled {
|
|
@extend .field;
|
|
|
|
.text {
|
|
color: $switch-disabled-text-color;
|
|
}
|
|
|
|
.switch-on, .switch-off {
|
|
cursor: auto;
|
|
background: $switch-disabled-track-color;
|
|
}
|
|
|
|
.thumb {
|
|
cursor: auto;
|
|
background-color: $switch-disabled-thumb-color;
|
|
border-color: transparent;
|
|
}
|
|
}
|