Skip to content

Commit

Permalink
Update site CSS to include dark mode toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
IanWold committed Sep 21, 2023
1 parent 4d9babc commit 635962a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Static/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ a {



#dark-mode-toggle {
border: 0;
background-color: transparent;
color: whitesmoke;

position: fixed;
top: 24px;
right: 24px;
z-index: 999;
}
.dark #dark-mode-toggle {
color: #A0A0A0;
}



nav {
padding-top: 72px;
display: flex;
Expand Down
21 changes: 21 additions & 0 deletions Templates/layout.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
</title>
</head>
<body>
<button id="dark-mode-toggle"><i data-feather="sun"></i></button>

<nav class="content">
<div class="headshot">
<img src="{{ directoryPrefix }}images/hero1.svg" />
Expand Down Expand Up @@ -66,6 +68,25 @@
observer.observe(section);
});
});
const darkModeToggle = document.getElementById("dark-mode-toggle");
const body = document.body;
function toggleDarkMode() {
body.classList.toggle("dark");
if (localStorage.getItem("dark") === "enabled") {
localStorage.setItem("dark", "disabled");
} else {
localStorage.setItem("dark", "enabled");
}
}
darkModeToggle.addEventListener("click", toggleDarkMode);
if (localStorage.getItem("dark") === "enabled") {
toggleDarkMode();
}
</script>
</body>
</html>

0 comments on commit 635962a

Please sign in to comment.