Browse Source

Refactor ProductCard component for improved readability and styling consistency

- Simplified template structure by removing unnecessary line breaks and indentation.
- Enhanced badge and discount badge styles for better visual appeal.
- Updated class names for consistency and improved hover effects on buttons.
- Maintained functionality while improving code clarity and maintainability.
main
Bastian Masanek 2 months ago
parent
commit
9150af3ac2
  1. 51
      app/components/Product/ProductCard.vue

51
app/components/Product/ProductCard.vue

@ -48,49 +48,35 @@ const formattedPrice = computed(() => {
</script> </script>
<template> <template>
<div <div :class="cn(
:class=" 'group relative flex flex-col overflow-hidden rounded-2xl bg-white/10 backdrop-blur-lg border border-white/20 shadow-glass transition-all duration-300 hover:scale-[1.02] hover:shadow-2xl hover:border-white/30',
cn( props.class,
'group relative flex flex-col overflow-hidden rounded-2xl bg-white/10 backdrop-blur-lg border border-white/20 shadow-glass transition-all duration-300 hover:scale-[1.02] hover:shadow-2xl hover:border-white/30', )
props.class, ">
)
"
>
<!-- Badge (optional) --> <!-- Badge (optional) -->
<div <div v-if="badge"
v-if="badge" class="absolute left-4 top-4 z-10 rounded-xl bg-experimenta-primary px-3 py-1 text-xs font-bold uppercase tracking-wider text-white shadow-lg">
class="absolute left-4 top-4 z-10 rounded-full bg-experimenta-primary px-3 py-1 text-xs font-bold uppercase tracking-wider text-white shadow-lg"
>
{{ badge }} {{ badge }}
</div> </div>
<!-- Discount Badge (optional) --> <!-- Discount Badge (optional) -->
<div <div v-if="discountPercentage"
v-if="discountPercentage" class="absolute right-4 top-4 z-10 flex h-12 w-12 items-center justify-center rounded-full bg-red text-white shadow-lg -rotate-12">
class="absolute right-4 top-4 z-10 flex h-12 w-12 items-center justify-center rounded-full bg-red text-white shadow-lg" <span class="text-sm font-bold">-{{ discountPercentage }}%</span>
>
<span class="text-xs font-bold">-{{ discountPercentage }}%</span>
</div> </div>
<!-- Product Image --> <!-- Product Image -->
<div class="relative aspect-[16/9] w-full overflow-hidden bg-purple-dark"> <div class="relative aspect-[16/9] w-full overflow-hidden bg-purple-dark">
<img <img :src="image" :alt="title"
:src="image" class="h-full w-full object-cover transition-transform duration-500 group-hover:scale-110" />
:alt="title"
class="h-full w-full object-cover transition-transform duration-500 group-hover:scale-110"
/>
<!-- Gradient overlay for better text readability --> <!-- Gradient overlay for better text readability -->
<div <div class="absolute inset-0 bg-gradient-to-t from-purple-darkest/80 via-transparent to-transparent" />
class="absolute inset-0 bg-gradient-to-t from-purple-darkest/80 via-transparent to-transparent"
/>
</div> </div>
<!-- Card Content --> <!-- Card Content -->
<div class="flex flex-1 flex-col space-y-3 p-5"> <div class="flex flex-1 flex-col space-y-3 p-5">
<!-- Title --> <!-- Title -->
<h3 <h3 class="text-xl font-bold leading-tight text-white transition-colors group-hover:text-experimenta-accent">
class="text-xl font-bold leading-tight text-white transition-colors group-hover:text-experimenta-accent"
>
{{ title }} {{ title }}
</h3> </h3>
@ -110,14 +96,11 @@ const formattedPrice = computed(() => {
</div> </div>
<!-- CTA Button --> <!-- CTA Button -->
<NuxtLink <NuxtLink :to="productId ? `/produkte/${productId}` : '#'"
:to="productId ? `/produkte/${productId}` : '#'" class="group/btn relative overflow-hidden rounded-xl bg-gradient-button bg-size-300 bg-left px-6 py-3 font-bold text-white shadow-lg transition-all duration-300 hover:bg-right hover:shadow-2xl active:scale-95">
class="group/btn relative overflow-hidden rounded-xl bg-gradient-button bg-size-300 bg-left px-6 py-3 font-bold text-white shadow-lg transition-all duration-300 hover:bg-right hover:shadow-2xl active:scale-95"
>
<span class="relative z-10">Details</span> <span class="relative z-10">Details</span>
<div <div
class="absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent opacity-0 transition-opacity duration-300 group-hover/btn:opacity-100" class="absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent opacity-0 transition-opacity duration-300 group-hover/btn:opacity-100" />
/>
</NuxtLink> </NuxtLink>
</div> </div>
</div> </div>

Loading…
Cancel
Save