theme toggle tweaks

- use standard sun/moon icons
- reduce button size by .5rem
This commit is contained in:
John Bowdre 2024-08-16 16:18:35 -05:00
parent 00d71d21e9
commit f0b675cddc
3 changed files with 41 additions and 17 deletions

View file

@ -33,7 +33,7 @@
})();
</script>
<!-- FontAwesome <https://fontawesome.com/> -->
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" />
<!-- ForkAwesome <https://forkaweso.me/> -->

View file

@ -8,7 +8,15 @@
</ul>
</nav>
<button id="themeToggle" class="theme-toggle" aria-label="Toggle light/dark theme" title="Toggle light/dark theme">
<svg class="theme-toggle__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M448 256c0-106-86-192-192-192l0 384c106 0 192-86 192-192zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256z"/>
</svg>
<!--!Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<span class="theme-toggle__icon theme-toggle__icon--sun">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"/>
</svg>
</span>
<span class="theme-toggle__icon theme-toggle__icon--moon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"/>
</svg>
</span>
</button>

View file

@ -70,12 +70,39 @@ body {
border: none;
cursor: pointer;
padding: 0;
width: 2rem;
height: 2rem;
width: 1.5rem;
height: 1.5rem;
z-index: 1000;
transition: opacity 0.3s ease;
}
.theme-toggle__icon {
width: 100%;
height: 100%;
transition: opacity 0.3s ease;
}
.theme-toggle__icon svg {
width: 100%;
height: 100%;
fill: var(--off-fg);
transition: fill 0.3s ease;
}
.theme-toggle:hover .theme-toggle__icon svg {
fill: var(--hover);
}
.theme-toggle__icon--sun,
[data-theme="dark"] .theme-toggle__icon--moon {
display: none;
}
[data-theme="dark"] .theme-toggle__icon--sun,
.theme-toggle__icon--moon {
display: block;
}
.theme-toggle:hover {
opacity: 0.7;
}
@ -89,21 +116,10 @@ body {
outline-offset: 2px;
}
.theme-toggle__icon {
width: 100%;
height: 100%;
transition: transform 0.3s ease, fill 0.3s ease;
fill: var(--off-fg);
}
.theme-toggle:hover .theme-toggle__icon {
fill: var(--hover);
}
[data-theme="dark"] .theme-toggle__icon {
transform: rotate(180deg);
}
.page__nav ul {
padding-right: 3rem;
}