Files
webawesome/source/css/switches.css

168 lines
4.1 KiB
CSS
Raw Normal View History

2017-07-31 10:47:11 -04:00
/*! Switches */
2017-08-13 15:41:38 -04:00
:root {
--switch-font-size: var(--input-font-size);
--switch-font-size-small: var(--input-font-size-small);
--switch-font-size-big: var(--input-font-size-big);
--switch-bg-color: var(--component-border-color);
--switch-bg-color-checked: var(--state-primary);
--switch-border-radius: var(--switch-height);
--switch-height: var(--input-height);
--switch-height-small: var(--input-height-small);
--switch-height-big: var(--input-height-big);
--switch-thumb-bg-color: white;
--switch-thumb-border-radius: 50%;
--switch-thumb-spacing: 2px;
--switch-speed: .2s;
}
2017-08-04 10:20:04 -04:00
.switch {
font-size: var(--switch-font-size);
}
2017-07-31 10:47:11 -04:00
2017-07-31 10:10:17 -04:00
.switch input {
display: none;
}
.switch input + label {
position: relative;
min-width: calc(var(--switch-height) * 2);
height: var(--switch-height);
line-height: var(--switch-height);
2017-07-31 10:10:17 -04:00
display: inline-block;
cursor: pointer;
outline: none;
user-select: none;
vertical-align: middle;
text-indent: calc(var(--switch-height) * 2 + .5rem);
2017-07-31 10:10:17 -04:00
}
.switch input + label::before,
.switch input + label::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: calc(var(--switch-height) * 2);
2017-07-31 10:10:17 -04:00
bottom: 0;
display: block;
}
.switch input + label::before {
right: 0;
background-color: var(--switch-bg-color);
border-radius: var(--switch-border-radius);
transition: background-color var(--switch-speed);
}
.switch input + label:after {
top: var(--switch-thumb-spacing);
left: var(--switch-thumb-spacing);
width: calc(var(--switch-height) - var(--switch-thumb-spacing) * 2);
height: calc(var(--switch-height) - var(--switch-thumb-spacing) * 2);
2017-07-31 10:10:17 -04:00
border-radius: var(--switch-thumb-border-radius);
background-color: var(--switch-thumb-bg-color);
transition: margin var(--switch-speed);
}
.switch input:checked + label::before {
background-color: var(--switch-bg-color-checked);
}
.switch input:checked + label::after {
margin-left: var(--switch-height);
2017-07-31 10:10:17 -04:00
}
.switch input:disabled + label {
opacity: .5;
cursor: not-allowed;
}
.switch-small {
font-size: var(--switch-font-size-small);
}
.switch-small input + label {
height: var(--switch-height-small);
line-height: var(--switch-height-small);
text-indent: calc(var(--switch-height-small) * 2 + .5rem);
}
.switch-small input + label::before,
.switch-small input + label::after {
width: calc(var(--switch-height-small) * 2);
}
.switch-small input + label:after {
width: calc(var(--switch-height-small) - var(--switch-thumb-spacing) * 2);
height: calc(var(--switch-height-small) - var(--switch-thumb-spacing) * 2);
}
.switch-small input:checked + label::after {
margin-left: var(--switch-height-small);
}
.switch-big {
font-size: var(--switch-font-size-big);
}
.switch-big input + label {
height: var(--switch-height-big);
line-height: var(--switch-height-big);
text-indent: calc(var(--switch-height-big) * 2 + .5rem);
}
.switch-big input + label::before,
.switch-big input + label::after {
width: calc(var(--switch-height-big) * 2);
}
.switch-big input + label:after {
width: calc(var(--switch-height-big) - var(--switch-thumb-spacing) * 2);
height: calc(var(--switch-height-big) - var(--switch-thumb-spacing) * 2);
}
.switch-big input:checked + label::after {
margin-left: var(--switch-height-big);
}
2017-07-31 10:10:17 -04:00
.switch + .switch {
margin-left: 1rem;
}
2017-08-13 15:41:38 -04:00
/* Variations */
.switch-secondary input:checked + label::before {
background-color: var(--state-secondary);
}
.switch-success input:checked + label::before {
background-color: var(--state-success);
}
.switch-info input:checked + label::before {
background-color: var(--state-info);
}
.switch-warning input:checked + label::before {
background-color: var(--state-warning);
}
.switch-danger input:checked + label::before {
background-color: var(--state-danger);
}
.switch-light input + label::before {
background-color: var(--state-dark);
}
.switch-light input:checked + label::before {
background-color: var(--state-light);
}
.switch-dark input + label::before {
background-color: var(--state-light);
}
.switch-dark input:checked + label::before {
background-color: var(--state-dark);
}