@ebay/skin
Version:
Skin - CSS modules that represent the brand eBay
149 lines (139 loc) • 4.25 kB
CSS
.switch {
box-sizing: border-box;
height: 40px;
position: relative;
vertical-align: middle;
}
div.switch {
display: flex;
}
span.switch {
display: inline-flex;
}
span.switch__button {
align-self: center;
background-color: var(
--switch-unchecked-background-color,
var(--color-background-secondary)
);
border-color: var(--switch-border-color, var(--color-stroke-strong));
border-radius: 400px;
border-style: solid;
border-width: 1px;
color: transparent;
display: inline-block;
position: relative;
text-indent: 100%;
width: 40px;
}
span.switch__button,
span.switch__button:after {
height: 24px;
transition: left 0.15s ease-out 0s;
}
span.switch__button:after {
background-color: var(
--switch-foreground-color,
var(--color-background-primary)
);
border-color: var(
--switch-foreground-border-color,
var(--color-stroke-strong)
);
border-radius: 50%;
border-style: solid;
border-width: 1px;
content: "";
display: block;
left: -1px;
position: absolute;
top: -1px;
transform: translateZ(0);
width: 24px;
}
input.switch__control,
span.switch__control {
height: 24px;
left: 0;
margin: 0;
outline: 0;
padding: 0;
position: absolute;
top: 8px;
width: 40px;
z-index: 1;
}
input.switch__control[disabled] + span.switch__button,
span.switch__control[aria-disabled="true"] + span.switch__button {
border-color: var(--switch-border-color, var(--color-stroke-disabled));
}
input.switch__control {
opacity: 0;
}
input.switch__control:focus + span.switch__button {
outline: 1px auto
var(--switch-custom-outline-color, var(--color-foreground-secondary));
}
input.switch__control:focus:not(:focus-visible) + span.switch__button {
outline: none;
}
input.switch__control[disabled] + span.switch__button:after,
span.switch__control[aria-disabled="true"] + span.switch__button:after {
border-color: var(--switch-border-color, var(--color-background-disabled));
}
input.switch__control:not([disabled]):focus + span.switch__button,
input.switch__control:not([disabled]):hover + span.switch__button,
span.switch__control:not([aria-disabled="true"]):focus + span.switch__button,
span.switch__control:not([aria-disabled="true"]):hover + span.switch__button {
background-color: var(
--switch-unchecked-hover-background-color,
var(--color-state-secondary-hover)
);
}
input.switch__control:not([disabled]):checked + span.switch__button,
span.switch__control:not([aria-disabled="true"])[aria-checked="true"]
+ span.switch__button {
background-color: var(
--switch-checked-background-color,
var(--color-background-accent)
);
}
input.switch__control[disabled]:checked + span.switch__button,
span.switch__control[aria-disabled="true"][aria-checked="true"]
+ span.switch__button {
background-color: var(
--switch-disabled-background-color,
var(--color-background-disabled)
);
border-color: var(--switch-border-color, var(--color-background-disabled));
}
input.switch__control:not([disabled]):focus-visible + span.switch__button,
span.switch__control:not([aria-disabled="true"]):focus-visible
+ span.switch__button {
box-shadow:
0 0 0 2px var(--color-background-primary),
0 0 0 4px var(--color-state-accent-hover);
}
input.switch__control:not([disabled]):checked:focus + span.switch__button,
input.switch__control:not([disabled]):checked:hover + span.switch__button,
span.switch__control:not([aria-disabled="true"])[aria-checked="true"]:focus
+ span.switch__button,
span.switch__control:not([aria-disabled="true"])[aria-checked="true"]:hover
+ span.switch__button {
background-color: var(
--switch-checked-hover-background-color,
var(--color-state-accent-hover)
);
}
input.switch__control:checked + span.switch__button:after,
span.switch__control[aria-checked="true"] + span.switch__button:after {
left: 15px;
}
span.switch__control:focus:not(:focus-visible) {
outline: 0;
}
@media screen and (-ms-high-contrast: active) {
input.switch__control {
opacity: 1;
}
}