mirror of
https://github.com/tchartron/blow
synced 2024-11-27 14:50:56 +00:00
update
This commit is contained in:
parent
7cd769bfa5
commit
7add21a127
2 changed files with 9 additions and 3 deletions
|
@ -2,11 +2,17 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
// ---------------- Selected Navbar Link -------------------------
|
// ---------------- Selected Navbar Link -------------------------
|
||||||
let navbar_links = document.querySelector('.nav-links').children;
|
let navbar_links = document.querySelector('.nav-links').children;
|
||||||
let current_location = window.location.href;
|
let current_location = window.location.href;
|
||||||
let selected_navbar_link = [...navbar_links].find((item) => {
|
let selected_navbar_link = [...navbar_links].filter((item) => {
|
||||||
return (item.href === current_location)
|
return (item.href === current_location)
|
||||||
})
|
})
|
||||||
if (typeof selected_navbar_link !== 'undefined') {
|
if (typeof selected_navbar_link !== 'undefined') {
|
||||||
selected_navbar_link.className = "bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium"
|
if (Array.isArray(selected_navbar_link)) {
|
||||||
|
for (let element of selected_navbar_link) {
|
||||||
|
element.className = "bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selected_navbar_link.className = "bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------- Switch Theme -------------------------
|
// ---------------- Switch Theme -------------------------
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
function switchTheme(){"dark"==([...document.documentElement.classList].includes("dark")?"dark":"light")?(localStorage.theme="light",document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden"),document.getElementById("dark").classList.remove("hidden")):(localStorage.theme="dark",document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden"),document.getElementById("light").classList.remove("hidden"))}function toggleSidebar(){let e=document.getElementById("sidebar");[...e.classList].includes("translate-x-0")?(document.body.style.removeProperty("overflow"),e.classList.remove("translate-x-0"),e.classList.add("-translate-x-full")):(document.body.style.setProperty("overflow","hidden"),e.classList.remove("-translate-x-full"),e.classList.add("translate-x-0"))}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelector(".nav-links").children;let t=window.location.href,d=[...e].find(e=>e.href===t);void 0!==d&&(d.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium"),"dark"===localStorage.theme||!("theme"in localStorage)&&window.matchMedia("(prefers-color-scheme: dark)").matches?(document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden")):(document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden")),document.getElementById("switch-theme").addEventListener("click",switchTheme),document.getElementById("toggle-sidebar").addEventListener("click",toggleSidebar)});
|
function switchTheme(){"dark"==([...document.documentElement.classList].includes("dark")?"dark":"light")?(localStorage.theme="light",document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden"),document.getElementById("dark").classList.remove("hidden")):(localStorage.theme="dark",document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden"),document.getElementById("light").classList.remove("hidden"))}function toggleSidebar(){let e=document.getElementById("sidebar");[...e.classList].includes("translate-x-0")?(document.body.style.removeProperty("overflow"),e.classList.remove("translate-x-0"),e.classList.add("-translate-x-full")):(document.body.style.setProperty("overflow","hidden"),e.classList.remove("-translate-x-full"),e.classList.add("translate-x-0"))}document.addEventListener("DOMContentLoaded",function(){var e=document.querySelector(".nav-links").children;let t=window.location.href,d=[...e].filter(e=>e.href===t);if(void 0!==d)if(Array.isArray(d))for(var a of d)a.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium";else d.className="bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium";"dark"===localStorage.theme||!("theme"in localStorage)&&window.matchMedia("(prefers-color-scheme: dark)").matches?(document.documentElement.classList.add("dark"),document.getElementById("dark").classList.add("hidden")):(document.documentElement.classList.remove("dark"),document.getElementById("light").classList.add("hidden")),document.getElementById("switch-theme").addEventListener("click",switchTheme),document.getElementById("toggle-sidebar").addEventListener("click",toggleSidebar)});
|
Loading…
Reference in a new issue