inicio
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
// ============================================================
|
||||
// AMOR & ROMA — comportamiento compartido (todas las páginas)
|
||||
// ============================================================
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
/* ---------- Tema claro / oscuro ---------- */
|
||||
const root = document.documentElement;
|
||||
const stored = localStorage.getItem("ar-theme");
|
||||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
const initial = stored || (prefersDark ? "dark" : "light");
|
||||
root.setAttribute("data-theme", initial);
|
||||
|
||||
document.querySelectorAll("[data-theme-toggle]").forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const current = root.getAttribute("data-theme");
|
||||
const next = current === "dark" ? "light" : "dark";
|
||||
root.setAttribute("data-theme", next);
|
||||
localStorage.setItem("ar-theme", next);
|
||||
});
|
||||
});
|
||||
|
||||
/* ---------- Menú móvil ---------- */
|
||||
const navToggle = document.querySelector("[data-nav-toggle]");
|
||||
const mobileMenu = document.querySelector("[data-mobile-menu]");
|
||||
if (navToggle && mobileMenu) {
|
||||
navToggle.addEventListener("click", () => {
|
||||
mobileMenu.classList.toggle("open");
|
||||
const expanded = mobileMenu.classList.contains("open");
|
||||
navToggle.setAttribute("aria-expanded", String(expanded));
|
||||
});
|
||||
mobileMenu.querySelectorAll("a").forEach((a) =>
|
||||
a.addEventListener("click", () => mobileMenu.classList.remove("open"))
|
||||
);
|
||||
}
|
||||
|
||||
/* ---------- Año dinámico en footer ---------- */
|
||||
document.querySelectorAll("[data-year]").forEach((el) => {
|
||||
el.textContent = new Date().getFullYear();
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user