roadmap
roadmap copied to clipboard
Create a fun dark mode toggle
For example: https://github.com/JoseRFelix/react-toggle-dark-mode
Or https://github.com/heisenberg-ayush/svg_Morphing_Animation (demo)
We would also need a middle state saying "auto" for when we want to follow the system settings.
Other resources:
- https://github.com/shubhamhackz/light_dark_toggle
- https://github.com/cawfree/react-dark-mode-toggle
Maybe svgator.com could help.
Thanks to Jim we have this one:
<div class="container">
<div class="moon"></div>
<div class="straaltje" style="--shine-id: 1;"></div>
<div class="straaltje" style="--shine-id: 2;"></div>
<div class="straaltje" style="--shine-id: 3;"></div>
<div class="straaltje" style="--shine-id: 4;"></div>
<div class="straaltje" style="--shine-id: 5;"></div>
<div class="straaltje" style="--shine-id: 6;"></div>
<div class="straaltje" style="--shine-id: 7;"></div>
<div class="straaltje" style="--shine-id: 8;"></div>
<div class="straaltje" style="--shine-id: 9;"></div>
<div class="straaltje" style="--shine-id: 10;"></div>
<div class="straaltje" style="--shine-id: 11;"></div>
<div class="straaltje" style="--shine-id: 12;"></div>
</div>
:root {
--size: 300px;
--duration: .5s;
--shine-id: 1; /* Default value */
--background-color: #2a3638;
--moon-color: #9aa7b4;
--sun-color: gold;
}
body {
background-color: var(--background-color);
margin: 100px 300px;
}
.container {
display: block;
position: relative;
cursor: pointer;
width: var(--size);
height: var(--size);
overflow: hidden;
}
.moon {
display: block;
position: relative;
width: 100%;
height: 100%;
background: var(--moon-color);
border-radius: 50%;
transition: all var(--duration);
}
.moon::after {
content: '';
display: block;
border-radius: 50%;
position: absolute;
right: calc(var(--size) / -3);
top: calc(var(--size) / -4);
width: var(--size);
height: var(--size);
transition: all var(--duration);
background-color: var(--background-color);
}
.container:hover .moon {
transform: scale(0.6);
background-color: var(--sun-color);
}
.container:hover .moon::after {
width: 0;
height: 0;
transform: scale(.6);
}
.straaltje {
--width: calc(var(--size) / 10);
--height: calc(var(--size) / 10);
position: absolute;
top: 0;
border-radius: 50%;
left: calc(50% - 5px / 2);
width: var(--width);
height: var(--height);
background-color: gold;
transform-origin: 2.5px calc(var(--size) / 2);
transition: all var(--duration);
transform: rotate(calc(360deg / 12 * var(--shine-id))) translateY(var(--width));
opacity: 0;
z-index: -1;
}
.container:hover .straaltje {
transform: rotate(calc(360deg / 12 * var(--shine-id)));
opacity: 1;
}
https://user-images.githubusercontent.com/1079135/147704430-ae6d4e75-59d7-43fb-a393-e0134fda1ce1.mp4
https://codepen.io/jimvandervoort/pen/RwLQbqQ