mirror of
https://github.com/ducky-labs/blog.git
synced 2026-02-04 07:11:00 +00:00
Init commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
(()=>{const e=document.getElementById("mode"),t=e=>{e==="dark"?(localStorage.setItem("theme","light"),initTheme("light")):e==="light"&&(localStorage.setItem("theme","dark"),initTheme("dark"))};e.addEventListener("click",()=>t(getThemeState()));const n=document.getElementById("menu-trigger");n.addEventListener("change",function(){const e=document.querySelector(".wrapper");this.checked?e.classList.add("blurry"):e.classList.remove("blurry")})})();const gttButton=document.getElementById("totop");window.onscroll=()=>{document.body.scrollTop>300||document.documentElement.scrollTop>300?(gttButton.style.visibility="visible",gttButton.style.opacity="1"):(gttButton.style.visibility="hidden",gttButton.style.opacity="0")}
|
||||
@@ -0,0 +1 @@
|
||||
const body=document.body,config=body.getAttribute("data-theme"),getThemeState=()=>{const t=localStorage.getItem("theme");if(t)return t;let e;switch(config){case"dark":e="dark";break;case"light":e="light";break;case"auto":default:e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";break}return e},initTheme=e=>{e==="dark"?(document.documentElement.classList.add("dark"),document.documentElement.classList.remove("light")):e==="light"&&(document.documentElement.classList.remove("dark"),document.documentElement.classList.add("light"))};initTheme(getThemeState()),setTimeout(()=>body.classList.remove("notransition"),75)
|
||||
Reference in New Issue
Block a user