@c8y/style
Version:
Styles for Cumulocity IoT applications
214 lines (189 loc) • 4.19 kB
text/less
.c8y-switch {
display: flex;
position: relative;
overflow: hidden;
margin: 0;
padding: 0 3px 0 calc(@switch-sm * 2 + 5px);
min-height: @form-control-height-base;
color: @form-control-color-default;
text-transform: none;
text-overflow: ellipsis;
white-space: nowrap;
letter-spacing: 0;
font-weight: normal;
font-size: inherit;
line-height: @form-control-height-base;
+ .c8y-switch {
margin-left: 6px;
}
&:hover {
cursor: pointer;
}
input[type='checkbox'] {
position: absolute;
top: 0;
left: 0;
opacity: 0;
& + span {
position: absolute;
top: calc((32px - @switch-sm) / 2);
left: 2px;
z-index: 1;
height: @switch-sm;
border: 0;
background-color: transparent;
&:before,
&:after {
position: absolute;
content: '';
}
&::before {
top: 0;
bottom: 0;
left: 0;
z-index: -1;
width: calc(@switch-sm * 2 - 2px);
border-radius: calc(@switch-sm / 2);
background-color: @switch-background-default;
box-shadow: none;
.transition(background 0.25s ease);
}
&::after {
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
z-index: -1;
width: calc(@switch-sm - 6px);
border-radius: calc(@switch-sm / 2) ;
background-color: var(--c8y-switch-handle-background, @form-control-background-default);
content: '';
.box-shadow(0 2px 3px fade(@black, 20%));
.transition(all 0.25s ease) !important;
}
}
&:focus {
+ span {
&::before {
outline: 2px solid @component-color-focus;
}
}
}
}
input[disabled] + span {
opacity: 0.5;
&:before,
&:after {
cursor: not-allowed;
}
}
input:checked + span {
&:before {
background-color: @switch-background-active;
}
&:after {
left: @switch-sm;
}
}
&--inline {
overflow: visible;
min-height: @switch-sm;
height: @switch-sm;
line-height: @line-height-base;
display: inline-flex;
& input[type='checkbox'] + span {
position: absolute;
top: 0;
}
}
}
.c8y-switch-multistate {
display: flex;
justify-content: stretch;
align-items: center;
height: @form-control-height-base;
border-radius: 16px;
width: 100%;
background: @gray-60;
position: relative;
line-height: 1;
[class^='dlt-c8y-icon-'],
[class*=' dlt-c8y-icon-'],
.c8y-icon {
font-size: 16px;
}
input {
opacity: 0;
width: 0;
height: 0;
margin: 0;
}
label {
flex: 1 1 100%;
margin: 0;
opacity: 1;
display: block;
text-align: center;
cursor: pointer;
position: relative;
z-index: 100;
}
&__handle {
display: block;
height: 24px;
width: calc(33.333% - 8px);
background-color: var(--c8y-switch-handle-background, @form-control-background-default);
.box-shadow(0 2px 3px fade(@black, 20%));
border-radius: 16px;
position: absolute;
transition: left 0.25s ease;
top: 4px;
z-index: 40;
transform: translate(-50%, 0);
.c8y-dark-theme &{
--c8y-switch-handle-background: @brand-primary;
}
.c8y-system-theme &{
@media (prefers-color-scheme: dark){
--c8y-switch-handle-background: @brand-primary;
}
}
}
input {
&:focus {
~ .c8y-switch-multistate__handle {
outline: 2px solid @component-color-focus;
}
}
&:checked,
&:focus {
&:nth-child(1) {
~ .c8y-switch-multistate__handle {
left: calc(100% / 6);
}
}
&:nth-child(3) {
~ .c8y-switch-multistate__handle {
left: calc((100% / 6) * 3);
}
}
&:nth-child(5) {
~ .c8y-switch-multistate__handle {
left: calc((100% / 6) * 5);
}
}
}
}
.c8y-dark-theme &{
input:checked + label {
color: @gray-100;
}
}
.c8y-system-theme &{
@media (prefers-color-scheme: dark){
input:checked + label {
color: @gray-100;
}
}
}
}