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 = '' + '
' + '' + + '' + '