feat: polish spectra lab editorial details

This commit is contained in:
Chen Gu
2026-04-23 12:18:35 +08:00
parent 969f0738c4
commit 516528ed73
4 changed files with 140 additions and 6 deletions

38
app.js
View File

@@ -4,12 +4,41 @@ const workItems = document.querySelectorAll('.work-item');
const workIndex = document.getElementById('workIndex');
const workTitle = document.getElementById('workTitle');
const workCopy = document.getElementById('workCopy');
const stageCard = document.querySelector('.stage-card');
const revealBlocks = document.querySelectorAll('.reveal');
const storedMode = window.localStorage.getItem('spectra-mode');
if (storedMode === 'light') {
document.body.classList.add('light-mode');
}
function applyMode() {
const isLight = document.body.classList.contains('light-mode');
modeToggle.textContent = isLight ? 'Dark Mode' : 'Light Mode';
modeLabel.textContent = isLight ? 'Editorial Light' : 'Editorial Dark';
window.localStorage.setItem('spectra-mode', isLight ? 'light' : 'dark');
}
function updateWorkStage(item) {
workItems.forEach((button) => {
button.classList.remove('is-active');
button.setAttribute('aria-selected', 'false');
});
item.classList.add('is-active');
item.setAttribute('aria-selected', 'true');
stageCard?.classList.remove('is-refreshing');
requestAnimationFrame(() => {
stageCard?.classList.add('is-refreshing');
window.setTimeout(() => {
stageCard?.classList.remove('is-refreshing');
}, 340);
});
workIndex.textContent = item.dataset.index || '';
workTitle.textContent = item.dataset.title || '';
workCopy.textContent = item.dataset.copy || '';
}
modeToggle?.addEventListener('click', () => {
@@ -19,11 +48,7 @@ modeToggle?.addEventListener('click', () => {
workItems.forEach((item) => {
item.addEventListener('click', () => {
workItems.forEach((button) => button.classList.remove('is-active'));
item.classList.add('is-active');
workIndex.textContent = item.dataset.index || '';
workTitle.textContent = item.dataset.title || '';
workCopy.textContent = item.dataset.copy || '';
updateWorkStage(item);
});
});
@@ -40,4 +65,7 @@ const observer = new IntersectionObserver(
);
revealBlocks.forEach((block) => observer.observe(block));
if (workItems[0]) {
updateWorkStage(workItems[0]);
}
applyMode();