fix(pos): tema consistente en todas las paginas + theme bar ocultada

- app-init.js: aplica tema guardado en localStorage, oculta theme-bars
  que tapaban contenido (position:fixed), sobrescribe setTheme() de
  cada pagina para usar version persistente
- sidebar.js: toggle de tema (sol/luna) integrado en el sidebar
- Tema se mantiene al navegar entre paginas

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 20:27:25 +00:00
parent 76c9c2d2db
commit e8b53f0b1b
2 changed files with 45 additions and 0 deletions

View File

@@ -127,6 +127,31 @@
});
});
// ─── Theme management ───
// Persist theme in localStorage, apply on load
var savedTheme = localStorage.getItem('pos_theme') || 'industrial';
document.documentElement.setAttribute('data-theme', savedTheme);
// Hide all theme bars (they overlap content with position:fixed)
document.querySelectorAll('.theme-bar').forEach(function(bar) {
bar.style.display = 'none';
});
// Expose theme toggle function (global)
window.posSetTheme = function(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('pos_theme', theme);
};
// Override any page-level setTheme functions so they use our persistent version
window.setTheme = window.posSetTheme;
// Also prevent any DOMContentLoaded theme switchers from overriding
// by re-applying our saved theme after a tick
setTimeout(function() {
document.documentElement.setAttribute('data-theme', savedTheme);
}, 100);
// ─── Expose globally ───
window.POS_USER = {
name: name,