From e8b53f0b1b46bcb84500cf81782b5ccc379e43fe Mon Sep 17 00:00:00 2001 From: consultoria-as Date: Wed, 1 Apr 2026 20:27:25 +0000 Subject: [PATCH] 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) --- pos/static/js/app-init.js | 25 +++++++++++++++++++++++++ pos/static/js/sidebar.js | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/pos/static/js/app-init.js b/pos/static/js/app-init.js index 39a7f70..abad2f6 100644 --- a/pos/static/js/app-init.js +++ b/pos/static/js/app-init.js @@ -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, diff --git a/pos/static/js/sidebar.js b/pos/static/js/sidebar.js index bb29643..6f8df08 100644 --- a/pos/static/js/sidebar.js +++ b/pos/static/js/sidebar.js @@ -36,12 +36,18 @@ + ''; }).join(''); + var currentTheme = localStorage.getItem('pos_theme') || 'industrial'; + var sidebarHtml = '' + '
' + ' ' + '
Nexus POS
' + '
' + '' + + '
' + + ' ' + + ' ' + + '
' + '