fix(ui): center header title on tablet + add skeleton loader to spesa stat card

Header title centering:
- .header-content: remove max-width:600px, use position:relative + justify-content:center
- .header-title: position:absolute; left:50%; transform:translateX(-50%)
  so the title is always at the exact center of the header regardless of
  screen width or how many action buttons are on the right
- Added max-width:calc(100% - 200px) to prevent overlap with action buttons
  on narrow screens

Spesa skeleton preloader:
- index.html: add stat-loading class to stat-spesa (was missing, other 3 had it)
- app.js showPage('dashboard'): add 'spesa' to the skeleton init array
- app.js loadShoppingCount(): remove stat-loading class after data loads
  (like loadDashboard() does for the other 3 locations)
This commit is contained in:
dadaloop82
2026-05-04 05:26:38 +00:00
parent c6e3d13e8c
commit 6756b16ecb
3 changed files with 22 additions and 8 deletions
+8 -4
View File
@@ -2231,7 +2231,7 @@ function showPage(pageId, param = null) {
switch(pageId) {
case 'dashboard':
// Show skeleton on stat-cards while data loads
['dispensa', 'frigo', 'freezer'].forEach(loc => {
['dispensa', 'frigo', 'freezer', 'spesa'].forEach(loc => {
const el = document.getElementById(`stat-${loc}`);
if (el) { el.textContent = '…'; el.classList.add('stat-loading'); }
});
@@ -8314,13 +8314,17 @@ async function addSmartToBring() {
async function loadShoppingCount() {
try {
const data = await api('bring_list');
const el = document.getElementById('stat-spesa');
if (data.success && data.purchase) {
document.getElementById('stat-spesa').textContent = data.purchase.length;
el.textContent = data.purchase.length;
} else {
document.getElementById('stat-spesa').textContent = '-';
el.textContent = '-';
}
el.classList.remove('stat-loading');
} catch {
document.getElementById('stat-spesa').textContent = '-';
const el = document.getElementById('stat-spesa');
el.textContent = '-';
el.classList.remove('stat-loading');
}
// Smart urgency badge: use cached data if fresh (< 2 min), else fetch
if (smartShoppingItems.length > 0 && (Date.now() - _smartShoppingLastFetch) < 2 * 60 * 1000) {