2016-01-26 21:12:48 +03:00
|
|
|
// http://codepen.io/rosskevin/pen/EPPwRR?editors=110
|
|
|
|
.switch {
|
|
|
|
label {
|
|
|
|
position: relative;
|
2016-03-28 23:18:19 +03:00
|
|
|
padding-left: $bmd-switch-width + $bmd-switch-label-padding; // absolutely positioned so add the radio size
|
2016-01-26 21:12:48 +03:00
|
|
|
|
2016-03-21 17:56:51 +03:00
|
|
|
.bmd-switch-track {
|
2016-01-26 21:12:48 +03:00
|
|
|
position: absolute;
|
2016-03-28 23:18:19 +03:00
|
|
|
top: calc-top($line-height-base, $font-size-base, $bmd-switch-height);
|
2016-01-26 21:12:48 +03:00
|
|
|
left: 0;
|
|
|
|
display: inline-block;
|
2016-03-28 23:18:19 +03:00
|
|
|
width: $bmd-switch-width;
|
|
|
|
height: $bmd-switch-height;
|
2016-01-26 21:12:48 +03:00
|
|
|
cursor: pointer;
|
|
|
|
background-image: linear-gradient(
|
2017-08-11 17:59:31 +03:00
|
|
|
to right,
|
|
|
|
$bmd-switch-unchecked-bg 0%,
|
|
|
|
$bmd-switch-unchecked-bg 50%,
|
|
|
|
$bmd-switch-checked-bg 50%,
|
|
|
|
$bmd-switch-checked-bg 100%
|
2016-01-26 21:12:48 +03:00
|
|
|
);
|
|
|
|
background-position: 0%;
|
2016-03-28 23:18:19 +03:00
|
|
|
background-size: $bmd-switch-width * 2 $bmd-switch-height;
|
|
|
|
border-radius: $bmd-switch-width;
|
2016-01-26 21:12:48 +03:00
|
|
|
transition: background-position 0.2s ease-in;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 0;
|
|
|
|
display: block;
|
2016-04-29 23:27:08 +03:00
|
|
|
align-self: center;
|
2016-03-28 23:18:19 +03:00
|
|
|
width: $bmd-switch-handle-size;
|
|
|
|
height: $bmd-switch-handle-size;
|
2016-01-26 21:12:48 +03:00
|
|
|
content: "";
|
2016-03-28 23:18:19 +03:00
|
|
|
background: $bmd-switch-handle-unchecked-bg;
|
2016-01-26 21:12:48 +03:00
|
|
|
border-radius: 100%;
|
|
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
|
2017-08-11 17:59:31 +03:00
|
|
|
transition: left 0.2s ease-in, background-color 0.2s ease-in,
|
|
|
|
transform 0.3s ease;
|
2016-01-26 21:12:48 +03:00
|
|
|
transform: translateY(-50%);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Jelly effect on click
|
|
|
|
&:active::after {
|
|
|
|
transform: translateY(-50%) scale3d(1.15, 0.85, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input {
|
|
|
|
// Hide original checkbox, but don't use `display: none` to allow focus on it using keyboard
|
|
|
|
position: absolute;
|
|
|
|
display: block;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
opacity: 0;
|
|
|
|
|
|
|
|
&:checked {
|
2016-03-21 17:56:51 +03:00
|
|
|
+ .bmd-switch-track {
|
2016-01-26 21:12:48 +03:00
|
|
|
background-position: -100%;
|
|
|
|
&::after {
|
2017-08-11 17:59:31 +03:00
|
|
|
left: unquote(
|
|
|
|
"calc(100% - #{$bmd-switch-handle-size})"
|
|
|
|
); //calc(100% - $bmd-switch-handle-size);
|
2016-03-28 23:18:19 +03:00
|
|
|
background-color: $bmd-switch-handle-checked-bg;
|
2016-01-26 21:12:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
// No jelly effect on disabled switchs
|
2016-03-21 17:56:51 +03:00
|
|
|
+ .bmd-switch-track:active::after {
|
2016-01-26 21:12:48 +03:00
|
|
|
transform: translateY(-50%);
|
|
|
|
}
|
|
|
|
|
2016-03-21 17:56:51 +03:00
|
|
|
+ .bmd-switch-track {
|
2016-01-26 21:12:48 +03:00
|
|
|
cursor: default;
|
2016-03-28 23:18:19 +03:00
|
|
|
background: $bmd-switch-disabled-bg;
|
2016-01-26 21:12:48 +03:00
|
|
|
&::after {
|
2016-03-28 23:18:19 +03:00
|
|
|
background: $bmd-switch-handle-disabled-bg;
|
2016-01-26 21:12:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|