diff --git a/assets/css/style.css b/assets/css/style.css index 981b768..7db8409 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -5686,3 +5686,60 @@ html.has-scroll-progress::-webkit-scrollbar { display: none; } @media print { .scroll-progress { display: none; } } + +/* ---- Lumishop: Kategorien links, Suche und Gegenstaende rechts ---- */ +.shop-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.25rem; align-items: start; } +.shop-layout-single { grid-template-columns: minmax(0, 1fr); } +.shop-layout > .panel { margin-bottom: 0; } +.shop-layout + .panel { margin-top: 1.25rem; } + +.shop-categories { position: sticky; top: 1rem; padding: 1rem 0.75rem; } +.shop-categories h2 { display: flex; align-items: center; gap: 0.45rem; margin: 0 0.5rem 0.75rem; font-size: 1.05rem; } +.shop-categories h2 .icon { width: 18px; height: 18px; color: var(--gold); } +.shop-category-list { display: flex; flex-direction: column; gap: 0.2rem; } +.shop-category { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.6rem; + width: 100%; + padding: 0.55rem 0.7rem; + border: 0; + border-left: 3px solid transparent; + border-radius: 8px; + background: transparent; + color: var(--text); + font-size: 0.93rem; + font-weight: 500; + text-align: left; + cursor: pointer; +} +.shop-category:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); } +.shop-category.active { background: rgba(201, 162, 39, 0.14); border-left-color: var(--gold); color: var(--gold); font-weight: 600; } +.shop-category > span:first-child { min-width: 0; overflow-wrap: anywhere; } +.shop-category-count { + flex-shrink: 0; + min-width: 1.8rem; + padding: 0.05rem 0.45rem; + border-radius: 999px; + background: rgba(255, 255, 255, 0.08); + color: var(--text-muted); + font-size: 0.78rem; + font-weight: 600; + text-align: center; +} +.shop-category.active .shop-category-count { background: var(--gold); color: #1a1a1a; } + +.shop-searchbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1.1rem; } +.shop-searchbar .search-field { flex: 1 1 260px; } + +@media (max-width: 860px) { + .shop-layout { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; } + .shop-categories { position: static; padding: 0.75rem; } + .shop-categories h2 { display: none; } + /* Auf dem Handy: Kategorien als waagerecht scrollbare Leiste */ + .shop-category-list { flex-direction: row; overflow-x: auto; gap: 0.4rem; scrollbar-width: none; } + .shop-category-list::-webkit-scrollbar { display: none; } + .shop-category { width: auto; flex-shrink: 0; border-left: 0; border: 1px solid var(--border); border-radius: 999px; padding: 0.4rem 0.8rem; } + .shop-category.active { border-color: var(--gold); } +} diff --git a/assets/js/shop.js b/assets/js/shop.js index 4c5b875..622b34b 100644 --- a/assets/js/shop.js +++ b/assets/js/shop.js @@ -67,9 +67,11 @@ if (search && grid) { var category = document.getElementById('shop-category'); var noMatch = document.getElementById('shop-no-match'); + var count = document.getElementById('shop-count'); + var total = grid.querySelectorAll('.shop-card').length; + var cat = ''; var filter = function () { var term = search.value.trim().toLowerCase(); - var cat = category ? category.value : ''; var visible = 0; grid.querySelectorAll('.shop-card').forEach(function (card) { var show = (term === '' || card.dataset.name.indexOf(term) !== -1) @@ -78,9 +80,27 @@ if (show) visible++; }); if (noMatch) noMatch.hidden = visible > 0; + if (count) { + count.textContent = visible === total + ? total + (total === 1 ? ' Gegenstand' : ' Gegenstände') + : visible + ' von ' + total; + } }; search.addEventListener('input', filter); - if (category) category.addEventListener('change', filter); + // Kategorien im Kasten links: Klick waehlt aus (und markiert den Eintrag) + if (category) { + category.addEventListener('click', function (event) { + var button = event.target.closest('.shop-category'); + if (!button) return; + cat = button.dataset.value; + category.querySelectorAll('.shop-category').forEach(function (b) { + var on = b === button; + b.classList.toggle('active', on); + b.setAttribute('aria-pressed', String(on)); + }); + filter(); + }); + } } // ---- Antraege: Grund abfragen (Ablehnen / Stornieren) ---- diff --git a/shop.php b/shop.php index 6f56eaa..28d4174 100644 --- a/shop.php +++ b/shop.php @@ -11,13 +11,18 @@ $reservedPoints = shop_reserved_points($userId); $spendable = max(0, $balance - $reservedPoints); $items = shop_items(true); +// Kategorien fuer den Kasten links: Name und Anzahl der Gegenstaende (0 = ohne Kategorie) $categories = []; +$categoryCounts = []; foreach ($items as $item) { - if ($item['category_id'] !== null) { - $categories[(int) $item['category_id']] = (string) $item['category_name']; + $categoryId = (int) ($item['category_id'] ?? 0); + if ($categoryId > 0) { + $categories[$categoryId] = (string) $item['category_name']; } + $categoryCounts[$categoryId] = ($categoryCounts[$categoryId] ?? 0) + 1; } -$hasUncategorized = (bool) array_filter($items, static fn (array $i): bool => $i['category_id'] === null); +$hasUncategorized = !empty($categoryCounts[0]); +$showCategoryList = count($categories) + ($hasUncategorized ? 1 : 0) > 1; // Eigene Antraege $perPage = 10; @@ -57,20 +62,34 @@ include __DIR__ . '/includes/header.php'; -
Kein Gegenstand passt zur Suche.