Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
EdamAme-x committed Nov 18, 2023
1 parent 97d6a8d commit 5f4093e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Binary file added assets/JSPCE-Cover2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/public/background-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/src/layout/Header/ThemeSwitch.astro
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@
localStorage.setItem("theme", currentTheme);
switchIcon.setAttribute("src", sunImage);
}

window.dispatchEvent(new Event("themeChanged"));
})
</script>
17 changes: 16 additions & 1 deletion src/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@ import Layout from '../layout/Layout.astro';
<div style={{
background: "url('/background.png')",
backgroundSize: "cover",
}} class="min-h-screen flex items-center justify-center">
}} class="min-h-screen flex items-center justify-center" id="hero">

<div>
<div class="text-3xl font-bold">Hello JavaScriptist 👋</div>
</div>

</div>
</Layout>

<script>
window.addEventListener("themeChanged", () => {
const currentTheme = localStorage.getItem("theme") || "light";
const hero = document.getElementById("hero");

if (currentTheme === "dark") {
hero.style.background = "url('/background.png')";
hero.style.backgroundSize = "cover";
}else {
hero.style.background = "url('/background-dark.png')";
hero.style.backgroundSize = "cover";
}
})
</script>

0 comments on commit 5f4093e

Please sign in to comment.