fix: puzzle sidebar integrates into layout instead of overlapping waveform
- Puzzle panel now shifts canvas and waveform viewer right (340px) instead of overlapping them, using body class toggle and CSS transitions - Canvas resize accounts for sidebar width - Progress (completed/unlocked levels, custom components) persists in localStorage - Level cards refresh on each panel open to reflect current progress Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
44
js/levels.js
44
js/levels.js
@@ -127,13 +127,39 @@ export const LEVELS = [
|
||||
}
|
||||
];
|
||||
|
||||
// Progress tracking
|
||||
export const progress = {
|
||||
unlockedLevels: ['buffer'],
|
||||
completedLevels: [],
|
||||
currentLevel: null,
|
||||
customComponents: {} // { name -> component definition }
|
||||
};
|
||||
// Progress tracking — load from localStorage if available
|
||||
function loadProgress() {
|
||||
try {
|
||||
const saved = localStorage.getItem('logiclab_progress');
|
||||
if (saved) {
|
||||
const parsed = JSON.parse(saved);
|
||||
return {
|
||||
unlockedLevels: parsed.unlockedLevels || ['buffer'],
|
||||
completedLevels: parsed.completedLevels || [],
|
||||
currentLevel: null,
|
||||
customComponents: parsed.customComponents || {}
|
||||
};
|
||||
}
|
||||
} catch (e) { /* ignore parse errors */ }
|
||||
return {
|
||||
unlockedLevels: ['buffer'],
|
||||
completedLevels: [],
|
||||
currentLevel: null,
|
||||
customComponents: {}
|
||||
};
|
||||
}
|
||||
|
||||
function saveProgress() {
|
||||
try {
|
||||
localStorage.setItem('logiclab_progress', JSON.stringify({
|
||||
unlockedLevels: progress.unlockedLevels,
|
||||
completedLevels: progress.completedLevels,
|
||||
customComponents: progress.customComponents
|
||||
}));
|
||||
} catch (e) { /* ignore storage errors */ }
|
||||
}
|
||||
|
||||
export const progress = loadProgress();
|
||||
|
||||
/**
|
||||
* Get all available levels for display
|
||||
@@ -259,6 +285,8 @@ export function completeLevel(levelId) {
|
||||
progress.unlockedLevels.push(nextId);
|
||||
}
|
||||
}
|
||||
|
||||
saveProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,6 +298,7 @@ export function registerComponent(name, gateTypes, connections) {
|
||||
gateTypes,
|
||||
connections
|
||||
};
|
||||
saveProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,4 +323,5 @@ export function resetProgress() {
|
||||
progress.completedLevels = [];
|
||||
progress.currentLevel = null;
|
||||
progress.customComponents = {};
|
||||
saveProgress();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user