1
1
mirror of https://github.com/xplosionmind/quitsocialmedia.club.git synced 2024-12-13 09:06:25 +01:00
quitsocialmedia.club/_includes/theme-toggle.html
2021-01-01 01:48:06 +01:00

21 lines
1.1 KiB
HTML

<script type="text/javascript">
const currentTheme = localStorage.getItem("theme");
if (currentTheme == "dark") {
document.body.classList.add("dark");
}
function themetoggle() {
document.body.classList.toggle("dark");
if (document.body.classList.contains("dark")) {
theme = "dark";
} else {
theme = "light"
}
localStorage.setItem("theme", theme);
};
</script>
<svg onclick="themetoggle()" class="theme-toggle button tool" title="Toggle theme" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="background:var(--background)"><path d="M12 7a5 5 0 0 0-3 9v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a5 5 0 0 0-3-9z" fill="var(--text)"/><path d="M12 6a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v2a1 1 0 0 0 1 1z" fill="var(--text)"/><path d="M21 11h-2a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2z" fill="var(--text)"/><path d="M5 11H3a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2z" fill="var(--text)"/><path d="M7.66 6.42L6.22 5a1 1 0 0 0-1.39 1.47l1.44 1.39a1 1 0 0 0 .73.28 1 1 0 0 0 .72-.31 1 1 0 0 0-.06-1.41z" fill="var(--text)"/><path d="M19.19 5.05a1 1 0 0 0-1.41 0l-1.44 1.37a1 1 0 0 0 0 1.41 1 1 0 0 0 .72.31 1 1 0 0 0 .69-.28l1.44-1.39a1 1 0 0 0 0-1.42z" fill="var(--text)"/></svg>