@navelpluisje/pcb-components
Version:
A library with native components. They are all pcb components, like a dip-switch, resitor etc.
144 lines (131 loc) • 3.44 kB
CSS
.dip-switch {
--background: hsl(0, 0%, 100%);
--switch-bg: hsl(var(--switch-color), var(--switch-saturation), 50%);
--switch-shadow: hsl(var(--switch-color), var(--switch-saturation), 35%);
--switch-shadow-fine: hsl(var(--switch-color), var(--switch-saturation), 45%);
--switch-text-color: hsl(0, 0%, 100%);
--switch-switch-color: hsl(var(--switch-color), 0%, 100%);
--switch-switch-shadow: hsl(var(--switch-color), 0%, 67%);
--switch-switch-shadow-fine: hsla(var(--switch-color), 0%, 67%, .45);
background-color: var(--switch-bg);
display: inline-flex;
padding: 1.25rem .5rem .125rem;
position: relative;
}
.dip-switch::before {
background-color: var(--switch-shadow);
content: '';
display: block;
height: 100%;
left: 100%;
position: absolute;
top: 0;
transform: skewY(60deg);
transform-origin: top left;
width: .15rem;
}
.dip-switch::after {
background-color: var(--switch-shadow);
content: '';
display: block;
height: .25rem;
left: 0;
position: absolute;
top: 100%;
transform: skewX(30deg);
transform-origin: top left;
width: 100%;
}
.dip-switch-switches {
display: inline-flex;
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
.dip-switch-chip {
background-color: var(--switch-shadow-fine);
border-color: var(--switch-shadow) transparent transparent var(--background);
border-style: solid;
border-width: .125rem 0 0 .0625rem;
content: '';
display: block;
height: 33.33333%;
left: 0;
position: absolute;
top: 33.33333%;
width: .25rem;
}
.dip-switch-label,
.dip-switch-value {
color: var(--switch-text-color);
font-family: monospace;
position: absolute;
text-transform: uppercase;
top: .25rem;
}
.dip-switch-value {
left: .5rem;
right: .5rem;
text-align: right;
}
.dip-switch-switch {
clip: rect(0, 0, 0, 0);
display: block;
position: absolute;
}
.dip-switch-switch + label {
background-color: var(--switch-switch-color);
border-color: var(--switch-shadow);
border-style: solid;
border-width: .0625rem 0 0 .0625rem;
box-shadow: .0625rem .0625rem 0 0 var(--switch-switch-shadow-fine) inset;
display: block;
height: 1.5rem;
margin: 0 .25rem;
position: relative;
width: .7rem;
}
.dip-switch-switch:focus + label {
box-shadow: 0 0 2px 2px white;
}
.dip-switch-switch + label::after {
background-image: linear-gradient(
180deg,
var(--switch-switch-color) 20%,
var(--switch-switch-shadow) 20%,
var(--switch-switch-shadow) 40%,
var(--switch-switch-color) 40%,
var(--switch-switch-color) 60%,
var(--switch-switch-shadow) 60%,
var(--switch-switch-shadow) 80%,
var(--switch-switch-color) 80%
);
background-position: top;
border: .0625rem solid var(--switch-switch-shadow);
box-shadow: .0625rem 0 0 0 var(--switch-switch-shadow);
box-sizing: border-box;
content: '';
display: block;
height: .6rem;
left: -.0625rem;
position: absolute;
top: calc(100% - .7rem + .125rem);
transition:
top .25s ease,
box-shadow .25s ease;
width: .7rem;
}
.dip-switch-switch:checked + label::after {
box-shadow:
.0625rem .125rem 0 0 var(--switch-switch-shadow),
.0625rem 0 0 0 var(--switch-switch-shadow-fine),
0 .0625rem 0 0 var(--switch-switch-shadow-fine);
top: -.0625rem;
}
.dip-switch-switch-id {
color: var(--switch-text-color);
font-family: monospace;
padding-top: .125rem;
text-align: center;
}