diff --git a/js/views/Pantry.js b/js/views/Pantry.js index a81cfee..3dd88d3 100644 --- a/js/views/Pantry.js +++ b/js/views/Pantry.js @@ -554,9 +554,10 @@ function classifyIngredients(searchQuery) { name: def.name, qty: getPantryTotal(id, pantry), unit: def.pantryUnit, + icon: CATEGORY_ICONS[def.category] || 'fa-jar', }; }) - .sort((a, b) => a.name.localeCompare(b.name, 'pl')); + .sort((a, b) => a.name.length - b.name.length); return { shortfalls, sufficient, notPlanned }; } @@ -564,49 +565,53 @@ function classifyIngredients(searchQuery) { /* ══════════════════════ TILE RENDERING ══════════════════════ */ function shortfallTileHtml(item) { - const dayCtx = formatDayContext(item.days); + const clamp = item.name.length > 25 ? ' min-w-0' : ''; return ` - `; } function sufficientTileHtml(item) { - const dayCtx = formatDayContext(item.days); + const clamp = item.name.length > 25 ? ' min-w-0' : ''; return ` - `; } function notPlannedChipHtml(item) { const hasStock = item.qty > 0; + const clamp = item.name.length > 25 ? ' min-w-0' : ''; return ` - `; } @@ -640,16 +645,18 @@ function renderBoard() { if (shortfalls.length > 0) { html += `
`; html += sectionHeaderHtml('fa-exclamation', '#2f2f2d', SHORTFALL_ACCENT, 'Potrzebne', '#7B756D', shortfalls.length); - html += shortfalls.map(shortfallTileHtml).join(''); - html += `
`; + html += `
`; + html += shortfalls.sort((a, b) => a.name.length - b.name.length).map(shortfallTileHtml).join(''); + html += `
`; } // Section 2: W spiżarni (sufficient) if (sufficient.length > 0) { html += `
`; html += sectionHeaderHtml('fa-check', '#1a2e22', '#6ee7b7', 'W spiżarni', '#7B756D', sufficient.length); - html += sufficient.map(sufficientTileHtml).join(''); - html += `
`; + html += `
`; + html += sufficient.sort((a, b) => a.name.length - b.name.length).map(sufficientTileHtml).join(''); + html += `
`; } // Section 3: Poza planem