mdb-ui-kit/scss/includes/_switch.scss

80 lines
1.9 KiB
SCSS
Raw Normal View History

.switch {
2015-11-22 00:36:03 +03:00
vertical-align: middle;
&, label, input, .switch-decorator {
2015-11-22 00:36:03 +03:00
user-select: none;
2015-11-18 23:53:05 +03:00
}
2015-11-22 00:36:03 +03:00
label {
cursor: pointer;
color: $mdb-switch-label-color;
2015-11-18 23:53:05 +03:00
2015-11-22 00:36:03 +03:00
// Hide original checkbox
input[type=checkbox] {
opacity: 0;
width: 0;
height: 0;
}
2015-11-22 00:36:03 +03:00
// Switch bg off and disabled
.switch-decorator,
input[type=checkbox][disabled] + .switch-decorator {
2015-11-22 00:36:03 +03:00
content: "";
display: inline-block;
width: 30px;
height: 15px;
background-color: rgba(80, 80, 80, 0.7);
border-radius: 15px;
margin-right: 15px;
transition: background 0.3s ease;
vertical-align: middle;
}
// Handle off
.switch-decorator:after {
2015-11-22 00:36:03 +03:00
content: "";
display: inline-block;
width: 20px;
height: 20px;
background-color: #F1F1F1;
border-radius: 20px;
position: relative;
box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.4);
left: -5px;
top: -2px;
transition: left 0.3s ease, background 0.3s ease, box-shadow 0.1s ease;
}
input[type=checkbox] {
// Handle disabled
&[disabled] {
& + .switch-decorator:after,
&:checked + .switch-decorator:after {
background-color: #BDBDBD;
}
}
& + .switch-decorator:active:after,
&[disabled] + .switch-decorator:active:after {
box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.4), 0 0 0 15px rgba(0, 0, 0, 0.1);
}
// Ripple off and disabled
&:checked + .switch-decorator:after {
left: 15px;
}
2015-11-22 00:36:03 +03:00
}
& label input[type=checkbox]:checked {
& + .switch-decorator {
background-color: rgba($brand-primary, (50/100)); // Switch bg on
}
& + .switch-decorator:after {
background-color: $brand-primary; // Handle on
}
& + .switch-decorator:active:after {
box-shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.4), 0 0 0 15px rgba($brand-primary, (10/100)); // Ripple on
}
}
2015-11-18 23:53:05 +03:00
}
}