feat: implementar 12 mejoras, tests, docs y optimizaciones
- Fase A: license templates, search history, cost estimator - Fase B: import URL, bulk ZIP, batch download - Fase C: comparison mode, mesh validation, measurement tool - Fase D: cross-section clipping, overhang heatmap, layer animation - Refactor Pydantic/SQLAlchemy warnings - 24 tests pytest - README actualizado - WebP thumbnails, lazy loading, cache headers
This commit is contained in:
39
static/js/theme.js
Normal file
39
static/js/theme.js
Normal file
@@ -0,0 +1,39 @@
|
||||
(function() {
|
||||
const STORAGE_KEY = 'stl-repo-theme';
|
||||
|
||||
function getTheme() {
|
||||
return localStorage.getItem(STORAGE_KEY) || 'dark';
|
||||
}
|
||||
|
||||
function setTheme(theme) {
|
||||
localStorage.setItem(STORAGE_KEY, theme);
|
||||
applyTheme(theme);
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
const html = document.documentElement;
|
||||
if (theme === 'light') {
|
||||
html.classList.add('light-mode');
|
||||
} else {
|
||||
html.classList.remove('light-mode');
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent('themechange', { detail: theme }));
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
const current = getTheme();
|
||||
setTheme(current === 'dark' ? 'light' : 'dark');
|
||||
}
|
||||
|
||||
// Expose globally
|
||||
window.getTheme = getTheme;
|
||||
window.setTheme = setTheme;
|
||||
window.toggleTheme = toggleTheme;
|
||||
|
||||
// Apply on load
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
applyTheme(getTheme());
|
||||
const btn = document.getElementById('theme-toggle');
|
||||
if (btn) btn.addEventListener('click', toggleTheme);
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user