-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
91 lines (84 loc) · 2.85 KB
/
Copy pathscript.js
File metadata and controls
91 lines (84 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Origami Linux Single Page Interactions
(function () {
const html = document.documentElement;
const themeBtn = document.getElementById("themeBtn");
const navToggle = document.querySelector(".nav-toggle");
const navLinks = document.getElementById("nav-links");
const yearEl = document.getElementById("year");
yearEl.textContent = new Date().getFullYear();
// Theme toggle with localStorage persistence
const stored = localStorage.getItem("origami-theme");
if (stored) html.setAttribute("data-theme", stored);
function updateThemeIcon() {
themeBtn.textContent =
html.getAttribute("data-theme") === "dark" ? "🌙" : "☀️";
}
updateThemeIcon();
themeBtn.addEventListener("click", () => {
const current = html.getAttribute("data-theme");
const next = current === "dark" ? "light" : "dark";
html.setAttribute("data-theme", next);
localStorage.setItem("origami-theme", next);
updateThemeIcon();
});
// Mobile nav
navToggle?.addEventListener("click", () => {
const expanded = navToggle.getAttribute("aria-expanded") === "true";
navToggle.setAttribute("aria-expanded", String(!expanded));
navLinks.classList.toggle("open");
});
navLinks?.addEventListener("click", (e) => {
if (e.target.tagName === "A" && navLinks.classList.contains("open")) {
navLinks.classList.remove("open");
navToggle.setAttribute("aria-expanded", "false");
}
});
// Smooth scroll for internal links
document.querySelectorAll('a[href^="#"]').forEach((a) => {
a.addEventListener("click", (e) => {
const id = a.getAttribute("href").slice(1);
const target = document.getElementById(id);
if (target) {
e.preventDefault();
target.scrollIntoView({ behavior: "smooth", block: "start" });
history.replaceState(null, "", "#" + id);
}
});
});
// Back to top button
document
.querySelectorAll('[data-scroll="#top"], .back-top')
.forEach((btn) => {
btn.addEventListener("click", (e) => {
e.preventDefault();
window.scrollTo({ top: 0, behavior: "smooth" });
});
});
// Scroll reveal for cards & principles
const observer = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
entry.target.classList.add("revealed");
observer.unobserve(entry.target);
}
}
},
{ threshold: 0.12 },
);
document
.querySelectorAll(".card, .principles article, .panel h3")
.forEach((el) => {
el.classList.add("reveal");
observer.observe(el);
});
// Subtle hero ASCII shimmer
const ascii = document.querySelector(".ascii");
if (ascii) {
let tick = 0;
setInterval(() => {
tick += 1;
ascii.style.filter = `drop-shadow(0 0 ${3 + (Math.sin(tick / 15) + 1) * 2}px rgba(63,220,151,0.45))`;
}, 180);
}
})();