aktueller stand

This commit is contained in:
torbinus
2026-09-17 16:02:51 +02:00
parent 7e51514383
commit 065cb8b64f
295 changed files with 642342 additions and 1059 deletions
+125
View File
@@ -0,0 +1,125 @@
---
import { layers, type Layer } from "../lib/sections";
interface Props {
layer: Exclude<Layer, "site">;
loggedIn: boolean;
}
const { layer, loggedIn } = Astro.props;
const config = layers[layer];
const currentPath = Astro.url.pathname;
---
<!--
Die zweite Leiste.
Sie erscheint nur, wenn eine Ebene offen ist — Shop oder Automaten — und
ist das sichtbare Zeichen dafür: dunkel, direkt unter dem Hauptheader, mit
der Navigation dieser Ebene. Der Hauptheader darüber bleibt unverändert
stehen, ein Klick dort führt ohne Umweg zurück in den Hauptauftritt.
Warenkorb und Konto stehen hier statt oben, damit der Hauptheader so ruhig
bleibt wie auf place4bees.com.
-->
<div id="second-header" class="sticky top-[var(--header-h)] z-40 bg-brand-ink text-white/75">
<div class="honeycomb-bg-dark absolute inset-0 opacity-50" aria-hidden="true"></div>
<div class="relative mx-auto max-w-[84rem] px-[var(--gutter)]">
<div class="flex min-h-[3.25rem] flex-wrap items-center gap-x-6 gap-y-2 py-2">
<a href={config.homeHref} class="flex items-baseline gap-3 shrink-0">
<span class="font-display text-[1.35rem] leading-none tracking-[0.02em] text-white">
{config.label}
</span>
<span class="hidden text-[0.8125rem] text-white/50 sm:inline">{config.tagline}</span>
</a>
<nav aria-label={`${config.label} Navigation`} class="flex items-center gap-5 text-[0.9375rem]">
{config.nav.map((item) => {
const active = currentPath === item.href;
return (
<a
href={item.href}
aria-current={active ? "page" : undefined}
class:list={[
"transition-colors duration-200",
active ? "text-brand-primary" : "text-white/70 hover:text-white",
]}
>
{item.label}
</a>
);
})}
</nav>
{layer === "shop" && (
<div class="ml-auto flex items-center gap-4">
<a
href={loggedIn ? "/konto" : "/konto/anmelden"}
class="text-[0.9375rem] text-white/70 transition-colors hover:text-white"
>
{loggedIn ? "Mein Konto" : "Anmelden"}
</a>
<a
href="/warenkorb"
class="relative inline-flex items-center transition-transform duration-200 ease-out hover:-translate-y-0.5"
aria-label="Warenkorb"
>
<svg viewBox="0 0 24 24" class="h-7 w-7" aria-hidden="true">
<ellipse cx="12" cy="5.4" rx="6.4" ry="2.1" fill="#8a5a2b" />
<circle cx="12" cy="3.2" r="1.05" fill="#8a5a2b" />
<path d="M5.6 7 C5.6 7 5.1 15 6.6 19 C7.4 21 16.6 21 17.4 19 C18.9 15 18.4 7 18.4 7 Z" fill="#e0a94a" stroke="#a9722a" stroke-width="0.5" />
<rect x="5.8" y="7" width="12.4" height="2.1" rx="1" fill="#c6922f" />
<path d="M12 21 C12 21 13 22.4 12 23.2 C11 22.4 12 21 12 21 Z" fill="#c6922f" />
</svg>
<span
id="cart-badge"
style="display:none"
class="absolute -top-1.5 -right-2.5 inline-flex h-[1.15rem] min-w-[1.15rem] items-center justify-center rounded-full bg-brand-primary px-1 text-[0.6875rem] font-medium tabular-nums text-brand-ink ring-2 ring-brand-ink"
></span>
</a>
</div>
)}
</div>
</div>
</div>
<script>
import { getCart } from "../lib/cart";
import { getCartIdClient } from "../lib/cartCookie";
async function refreshCartBadge(animate = false) {
const badge = document.getElementById("cart-badge");
if (!badge) return;
const cartId = getCartIdClient();
if (!cartId) {
badge.style.display = "none";
return;
}
try {
const cart = await getCart(cartId);
const count = (cart.items ?? []).reduce((sum, item) => sum + item.quantity, 0);
if (count > 0) {
const changed = animate && badge.textContent !== String(count);
badge.textContent = String(count);
badge.style.display = "inline-flex";
if (changed) {
badge.classList.remove("badge-pop");
void badge.offsetWidth; // Reflow erzwingen, sonst startet die Animation nicht neu
badge.classList.add("badge-pop");
}
} else {
badge.style.display = "none";
}
} catch {
badge.style.display = "none";
}
}
// Beim Seitenaufbau still setzen, sonst poppt der Zähler bei jeder
// Navigation. Nur eine echte Warenkorbänderung darf ihn anspringen lassen.
document.addEventListener("astro:page-load", () => refreshCartBadge(false));
window.addEventListener("cart:updated", () => refreshCartBadge(true));
</script>