kopia lustrzana https://github.com/wagtail/wagtail
96 wiersze
2.1 KiB
SCSS
96 wiersze
2.1 KiB
SCSS
![]() |
@use 'sass:math';
|
||
![]() |
|
||
![]() |
$switch-width: 36px;
|
||
|
$switch-height: 18px;
|
||
![]() |
$switch-border: 2px;
|
||
|
$switch-outline: 3px;
|
||
|
|
||
![]() |
$switch-border-radius: math.div(($switch-height + $switch-border * 2), 2);
|
||
![]() |
|
||
|
.switch {
|
||
![]() |
display: inline-flex;
|
||
|
align-items: center;
|
||
|
margin: 5px 0;
|
||
![]() |
position: relative;
|
||
![]() |
|
||
|
// Disable forms styling that's applied to the <label> tag
|
||
|
width: unset;
|
||
|
float: unset;
|
||
|
|
||
![]() |
&__tick {
|
||
|
width: 12px;
|
||
|
height: $switch-height;
|
||
|
position: absolute;
|
||
|
top: 50%;
|
||
|
transform: translate(5px, -50%);
|
||
|
color: $color-white;
|
||
|
|
||
|
@media (forced-colors: active) {
|
||
|
color: SelectedItemText;
|
||
|
}
|
||
|
}
|
||
|
|
||
![]() |
&__toggle {
|
||
|
position: relative;
|
||
|
cursor: pointer;
|
||
|
|
||
|
&::before,
|
||
|
&::after {
|
||
|
content: '';
|
||
|
transition: all 100ms cubic-bezier(0.4, 0, 0.2, 1);
|
||
|
display: block;
|
||
![]() |
}
|
||
|
|
||
![]() |
&::before {
|
||
![]() |
height: $switch-height + $switch-border * 2;
|
||
|
width: $switch-width + $switch-border * 2;
|
||
![]() |
border-radius: $switch-border-radius;
|
||
![]() |
background: theme('colors.grey.400');
|
||
|
border: $switch-border solid theme('colors.grey.400');
|
||
![]() |
}
|
||
|
|
||
![]() |
&::after {
|
||
|
position: absolute;
|
||
|
top: 50%;
|
||
|
transform: translate($switch-border, -50%);
|
||
|
height: $switch-height;
|
||
|
width: $switch-height;
|
||
|
border: $switch-border solid $color-white;
|
||
![]() |
border-radius: theme('borderRadius.full');
|
||
![]() |
background-color: $color-white;
|
||
![]() |
}
|
||
![]() |
}
|
||
|
|
||
|
[type='checkbox']:checked + &__toggle::before {
|
||
|
background: $color-teal;
|
||
|
border-color: $color-teal;
|
||
![]() |
|
||
|
@media (forced-colors: active) {
|
||
|
background: SelectedItem;
|
||
|
border-color: SelectedItem;
|
||
|
}
|
||
![]() |
}
|
||
|
|
||
|
[type='checkbox']:checked + &__toggle::after {
|
||
![]() |
transform: translate(calc(#{$switch-width + $switch-border} - 100%), -50%);
|
||
![]() |
}
|
||
|
|
||
|
[type='checkbox']:disabled + &__toggle {
|
||
|
cursor: not-allowed;
|
||
|
filter: grayscale(100%);
|
||
|
opacity: 0.3;
|
||
|
}
|
||
|
|
||
|
[type='checkbox']:focus + &__toggle {
|
||
|
outline: $color-focus-outline solid $switch-outline;
|
||
|
}
|
||
|
|
||
|
[type='checkbox'] {
|
||
|
position: absolute;
|
||
|
opacity: 0;
|
||
|
pointer-events: none;
|
||
![]() |
width: 100%;
|
||
|
height: 100%;
|
||
![]() |
}
|
||
![]() |
}
|