buildsomething/sass/darkmode_toggle.scss

58 lines
1.1 KiB
SCSS
Raw Normal View History

2024-11-09 20:49:46 +01:00
:root {
2024-11-09 22:31:00 +01:00
/*--primary-color: var(--primary-color); */
/* --primary-text-color: var(--primary-text-color); */
2024-11-09 20:49:46 +01:00
}
2024-11-09 22:31:00 +01:00
$diameter: 50px;
2024-11-09 20:49:46 +01:00
.toggle-switch {
position: relative;
2024-11-09 22:31:00 +01:00
width: $diameter * 2;
2024-11-09 20:49:46 +01:00
}
label {
position: absolute;
width: 100%;
2024-11-09 22:31:00 +01:00
height: $diameter;
background-color: var(--primary-text-color);
border-radius: $diameter / 2;
2024-11-09 20:49:46 +01:00
cursor: pointer;
}
input {
position: absolute;
display: none;
}
.slider {
position: absolute;
width: 100%;
height: 100%;
2024-11-09 22:31:00 +01:00
border-radius: $diameter / 2;
2024-11-09 20:49:46 +01:00
transition: 0.3s;
}
input:checked~.slider {
2024-11-09 22:31:00 +01:00
background-color: var(--primary-color);
2024-11-09 20:49:46 +01:00
}
.slider::before {
content: "";
position: absolute;
2024-11-09 22:31:00 +01:00
top: $diameter * 0.13;
left: $diameter * 0.16;
width: $diameter * 0.75;
height: $diameter * 0.75;
2024-11-09 20:49:46 +01:00
border-radius: 50%;
2024-11-09 22:31:00 +01:00
box-shadow: inset $diameter * .28 $diameter * -.04 0px 0px var(--primary-color);
background-color: var(--primary-text-color);
2024-11-09 20:49:46 +01:00
transition: 0.3s;
}
input:checked~.slider::before {
2024-11-09 22:31:00 +01:00
transform: translateX($diameter * 0.95);
background-color: var(--primary-text-color);
2024-11-09 20:49:46 +01:00
box-shadow: none;
}