2024-12-12 12:30:13 -05:00
|
|
|
:host {
|
|
|
|
|
--background-color: var(--wa-form-control-background-color);
|
|
|
|
|
--background-color-checked: var(--wa-form-control-activated-color);
|
2025-01-07 15:41:57 -05:00
|
|
|
--border-color: var(--wa-form-control-border-color);
|
2024-12-12 12:30:13 -05:00
|
|
|
--border-color-checked: var(--background-color-checked);
|
|
|
|
|
--border-style: var(--wa-form-control-border-style);
|
|
|
|
|
--border-width: var(--wa-form-control-border-width);
|
|
|
|
|
--box-shadow: initial;
|
|
|
|
|
--height: calc(1em * var(--wa-form-control-value-line-height));
|
2025-01-07 15:41:57 -05:00
|
|
|
--thumb-color: var(--wa-form-control-border-color);
|
2024-12-12 12:30:13 -05:00
|
|
|
--thumb-color-checked: var(--wa-form-control-background-color);
|
|
|
|
|
--thumb-shadow: initial;
|
|
|
|
|
--thumb-size: calc((var(--height) - var(--border-width) * 2) * 0.75);
|
|
|
|
|
--width: calc(var(--height) * 1.75);
|
|
|
|
|
|
|
|
|
|
display: inline-block;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 21:33:52 -05:00
|
|
|
label {
|
2024-12-12 12:30:13 -05:00
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
font: inherit;
|
|
|
|
|
color: var(--wa-form-control-value-color);
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 21:33:52 -05:00
|
|
|
.switch {
|
2024-12-12 12:30:13 -05:00
|
|
|
flex: 0 0 auto;
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
width: var(--width);
|
|
|
|
|
height: var(--height);
|
|
|
|
|
background-color: var(--background-color);
|
|
|
|
|
border-color: var(--border-color);
|
|
|
|
|
border-radius: var(--height);
|
|
|
|
|
border-style: var(--border-style);
|
|
|
|
|
border-width: var(--border-width);
|
|
|
|
|
box-shadow: var(--box-shadow);
|
2024-12-18 21:33:52 -05:00
|
|
|
transition-property: translate, background, border-color, box-shadow;
|
|
|
|
|
transition-duration: var(--wa-transition-normal);
|
|
|
|
|
transition-timing-function: var(--wa-transition-easing);
|
2024-12-12 12:30:13 -05:00
|
|
|
}
|
|
|
|
|
|
2024-12-18 21:33:52 -05:00
|
|
|
.switch .thumb {
|
2024-12-12 12:30:13 -05:00
|
|
|
width: var(--thumb-size);
|
|
|
|
|
height: var(--thumb-size);
|
|
|
|
|
background-color: var(--thumb-color);
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
box-shadow: var(--thumb-shadow);
|
|
|
|
|
translate: calc((var(--width) - var(--height)) / -2);
|
2024-12-18 21:33:52 -05:00
|
|
|
transition: inherit;
|
2024-12-12 12:30:13 -05:00
|
|
|
}
|
|
|
|
|
|
2024-12-17 13:46:39 -05:00
|
|
|
.input {
|
2024-12-12 12:30:13 -05:00
|
|
|
position: absolute;
|
|
|
|
|
opacity: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
margin: 0;
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Focus */
|
2024-12-18 21:33:52 -05:00
|
|
|
label:not(.disabled) .input:focus-visible ~ .switch .thumb {
|
2024-12-12 12:30:13 -05:00
|
|
|
outline: var(--wa-focus-ring);
|
|
|
|
|
outline-offset: var(--wa-focus-ring-offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Checked */
|
2024-12-18 21:33:52 -05:00
|
|
|
.checked .switch {
|
2024-12-12 12:30:13 -05:00
|
|
|
background-color: var(--background-color-checked);
|
|
|
|
|
border-color: var(--border-color-checked);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 21:33:52 -05:00
|
|
|
.checked .switch .thumb {
|
2024-12-12 12:30:13 -05:00
|
|
|
background-color: var(--thumb-color-checked);
|
|
|
|
|
translate: calc((var(--width) - var(--height)) / 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Disabled */
|
2024-12-18 21:33:52 -05:00
|
|
|
label:has(> :disabled) {
|
2024-12-12 12:30:13 -05:00
|
|
|
opacity: 0.5;
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 21:33:52 -05:00
|
|
|
[part~='label'] {
|
2024-12-12 12:30:13 -05:00
|
|
|
display: inline-block;
|
|
|
|
|
line-height: var(--height);
|
|
|
|
|
margin-inline-start: 0.5em;
|
|
|
|
|
user-select: none;
|
|
|
|
|
-webkit-user-select: none;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-18 21:33:52 -05:00
|
|
|
:host([required]) [part~='label']::after {
|
2024-12-12 12:30:13 -05:00
|
|
|
content: var(--wa-form-control-required-content);
|
|
|
|
|
color: var(--wa-form-control-required-content-color);
|
|
|
|
|
margin-inline-start: var(--wa-form-control-required-content-offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (forced-colors: active) {
|
2024-12-18 21:33:52 -05:00
|
|
|
:checked:enabled + .switch:hover .thumb,
|
|
|
|
|
:checked + .switch .thumb {
|
2024-12-12 12:30:13 -05:00
|
|
|
background-color: ButtonText;
|
|
|
|
|
}
|
|
|
|
|
}
|