From be847a814dd9e0bfb378ec5b4b322cbf28486a20 Mon Sep 17 00:00:00 2001 From: Gemini Date: Thu, 14 May 2026 20:02:51 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Artikel=20Grid-Ansicht=20optimiert=20(H?= =?UTF-8?q?=C3=B6he,=20Farben,=20Kategorien=20ohne=20Filter)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/articles.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/articles.php b/src/articles.php index b2b4cd5..8ae263c 100644 --- a/src/articles.php +++ b/src/articles.php @@ -229,7 +229,7 @@ $conn->close(); border: 1px solid #eee; border-radius: 8px; padding: 6px; text-align: center; background: #fff; display: flex; flex-direction: column; transition: transform 0.1s, box-shadow 0.1s; - height: 200px; + height: 250px; position: relative; } .lager-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.05); } @@ -361,7 +361,7 @@ document.addEventListener('DOMContentLoaded', function () { if (sortedCategories.length === 0) { tableHTML = 'Keine Artikel gefunden.'; - gridHTML = '
Keine Artikel gefunden.
'; + gridHTML = '
Keine Artikel gefunden.
'; } else { sortedCategories.forEach(catName => { const items = groupedArticles[catName]; @@ -369,12 +369,16 @@ document.addEventListener('DOMContentLoaded', function () { const isCollapsed = collapsedCategories.has(catName) && !isSearching; const count = items.reduce((acc, item) => acc + 1 + item.children.length, 0); - tableHTML += ` + tableHTML += ` - ${catName} + ${catName} ${count} `; + + gridHTML += `
+ ${catName} ${count} +
`; if (!isCollapsed) { items.forEach(article => { @@ -395,6 +399,15 @@ document.addEventListener('DOMContentLoaded', function () { initializeInteractivity(); } + function getColorForCategory(categoryName) { + let hash = 0; + for (let i = 0; i < categoryName.length; i++) { + hash = categoryName.charCodeAt(i) + ((hash << 5) - hash); + } + const hue = Math.abs(hash % 360); + return `hsl(${hue}, 60%, 85%)`; + } + function generateCardHTML(article) { const imagePath = article.image_url ? article.image_url : 'assets/images/keinbild.png'; const productLink = article.product_url ? `` : ''; @@ -413,6 +426,8 @@ document.addEventListener('DOMContentLoaded', function () { } const metaText = [article.manufacturer_name, article.product_designation].filter(Boolean).join(' - '); + const catName = article.category_name || 'Ohne Kat.'; + const catColor = getColorForCategory(catName); return `
@@ -425,7 +440,7 @@ document.addEventListener('DOMContentLoaded', function () {
${article.name}
${metaText}
${new Intl.NumberFormat('de-DE').format(article.weight_grams)} g | ${quantityBadge}
-
${article.category_name || 'Ohne Kat.'}
+
${catName}
${productLink} ${actionButtons}