Skip to content

Commit

Permalink
Merge pull request #34 from ArmandPhilippot/fix/content-collections-v…
Browse files Browse the repository at this point in the history
…5-themeicon
  • Loading branch information
sarah11918 authored Nov 30, 2024
2 parents 00a7df7 + 86bb446 commit a320857
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/ThemeIcon.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
---

<button id="themeToggle">
Expand All @@ -17,7 +18,7 @@
</button>

<style>
#themeToggle {
#themeToggle {
border: 0;
background: none;
}
Expand All @@ -40,7 +41,7 @@
<script>
const theme = (() => {
if (typeof localStorage !== "undefined" && localStorage.getItem("theme")) {
return localStorage.getItem("theme");
return localStorage.getItem("theme") ?? "light";
}
if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
return "dark";
Expand All @@ -66,5 +67,5 @@

document
.getElementById("themeToggle")
.addEventListener("click", handleToggleClick);
?.addEventListener("click", handleToggleClick);
</script>

0 comments on commit a320857

Please sign in to comment.