You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
66 lines
2.0 KiB
<script setup lang="ts">
|
|
import { ShoppingCart } from 'lucide-vue-next'
|
|
import { Badge } from '@/components/ui/badge'
|
|
|
|
const { itemCount, total } = useCart()
|
|
const { open } = useCartUI()
|
|
|
|
const hasItems = computed(() => itemCount.value > 0)
|
|
|
|
// Format total price in German locale (EUR)
|
|
const formattedTotal = computed(() => {
|
|
return new Intl.NumberFormat('de-DE', {
|
|
style: 'currency',
|
|
currency: 'EUR',
|
|
}).format(total.value)
|
|
})
|
|
|
|
// Handle button click to open cart sidebar
|
|
function handleClick(e: Event) {
|
|
e.preventDefault()
|
|
open()
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<!-- Desktop cart button (visible only on lg and up) -->
|
|
<button
|
|
@click="handleClick"
|
|
class="hidden lg:flex items-center gap-2 rounded-lg px-4 py-2 transition-all hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-experimenta-accent focus:ring-offset-2 focus:ring-offset-transparent"
|
|
aria-label="Warenkorb öffnen"
|
|
>
|
|
<!-- Cart icon with item count badge -->
|
|
<div class="relative inline-flex">
|
|
<ShoppingCart class="h-6 w-6 text-white" />
|
|
|
|
<!-- Item count badge -->
|
|
<Transition
|
|
enter-active-class="transition-all duration-200 ease-out"
|
|
enter-from-class="scale-0 opacity-0"
|
|
enter-to-class="scale-100 opacity-100"
|
|
leave-active-class="transition-all duration-150 ease-in"
|
|
leave-from-class="scale-100 opacity-100"
|
|
leave-to-class="scale-0 opacity-0"
|
|
>
|
|
<Badge
|
|
v-if="hasItems"
|
|
class="absolute -top-2 -right-2 h-5 min-w-[20px] px-1 flex items-center justify-center bg-red-500 text-white text-xs font-bold border-2 border-white"
|
|
>
|
|
{{ itemCount > 99 ? '99+' : itemCount }}
|
|
</Badge>
|
|
</Transition>
|
|
</div>
|
|
|
|
<!-- Total price (desktop only) -->
|
|
<span class="text-sm font-semibold text-white">
|
|
{{ formattedTotal }}
|
|
</span>
|
|
|
|
<!-- Pulse animation when items are added -->
|
|
<span
|
|
v-if="hasItems"
|
|
class="absolute inset-0 rounded-lg bg-experimenta-accent/20 animate-pulse opacity-50"
|
|
aria-hidden="true"
|
|
/>
|
|
</button>
|
|
</template>
|
|
|