@freshworks/crayons
Version:
Crayons Web Components library
148 lines (146 loc) • 3.5 kB
CSS
/* Need to check with designer */
/* Need to check with designer */
:host {
font-family: var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
box-sizing: border-box;
}
*,
::after,
::before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.toggle-switch {
position: relative;
display: inline-block;
}
.toggle-switch.small {
width: 28px;
height: 12px;
}
.toggle-switch.medium {
width: 36px;
height: 16px;
}
.toggle-switch.large {
width: 44px;
height: 20px;
}
@media screen and (prefers-reduced-motion: reduce) {
.toggle-switch .slider {
transition: none;
}
}
.toggle-switch .slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: 34px;
background: #647a8e;
}
@media screen and (prefers-reduced-motion: reduce) {
.toggle-switch .before {
transition: none;
}
}
.toggle-switch .before {
position: absolute;
content: "";
left: 0;
bottom: -2px;
border: solid 1px #647a8e;
border-radius: 50%;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.23);
background-color: #fff;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-timing-function: ease;
transition-timing-function: ease;
-webkit-transition-duration: 0.2s;
transition-duration: 0.2s;
display: flex;
justify-content: center;
align-items: center;
}
.toggle-switch .before:hover, .toggle-switch .before:focus {
box-shadow: 0 0 4px 4px rgba(87, 108, 125, 0.3);
}
.toggle-switch .slider.small {
width: 28px;
height: 12px;
}
.toggle-switch .slider.small .before {
width: 16px;
height: 16px;
}
.toggle-switch .slider.small .before fw-icon {
transform: scale(0.375);
}
.toggle-switch .slider.small .before fw-icon.checked {
transform: scale(0.5);
}
.toggle-switch .slider.medium {
width: 36px;
height: 16px;
}
.toggle-switch .slider.medium .before {
width: 20px;
height: 20px;
}
.toggle-switch .slider.medium .before fw-icon {
transform: scale(0.5);
}
.toggle-switch .slider.medium .before fw-icon.checked {
transform: scale(0.66);
}
.toggle-switch .slider.large {
width: 44px;
height: 20px;
}
.toggle-switch .slider.large .before {
width: 24px;
height: 24px;
}
.toggle-switch .slider.large .before fw-icon {
transform: scale(0.66);
}
.toggle-switch .slider.large .before fw-icon.checked {
transform: scale(0.83);
}
.toggle-switch input {
display: none;
}
.toggle-switch input:checked + .slider {
background-color: #2c5cc5;
}
.toggle-switch input:checked + .slider .before {
border: solid 1px #2c5cc5;
}
.toggle-switch input:checked + .slider .before:hover, .toggle-switch input:checked + .slider .before:focus {
box-shadow: 0 0 4px 4px rgba(40, 61, 165, 0.3);
}
.toggle-switch input:checked + .slider.small .before {
-webkit-transform: translateX(12px);
-ms-transform: translateX(12px);
transform: translateX(12px);
}
.toggle-switch input:checked + .slider.medium .before {
-webkit-transform: translateX(16px);
-ms-transform: translateX(16px);
transform: translateX(16px);
}
.toggle-switch input:checked + .slider.large .before {
-webkit-transform: translateX(20px);
-ms-transform: translateX(20px);
transform: translateX(20px);
}
.toggle-switch input:disabled + .slider {
opacity: 0.4;
cursor: not-allowed;
}