feat: replace raw image path input with interactive visual gallery and multi-image manager in admin and shop

This commit is contained in:
2026-11-01 16:24:12 +01:00
parent c06701673a
commit 4994d4a8ef
9 changed files with 724 additions and 29 deletions
+96 -13
View File
@@ -55,22 +55,105 @@
<!-- Linkerkant: Productgalerij & Specificaties -->
<div class="lg:col-span-6 space-y-4 sm:space-y-6">
<div class="rounded-3xl bg-white border border-slate-100 overflow-hidden shadow-sm">
<div class="relative h-72 sm:h-96 md:h-112 bg-slate-100 flex items-center justify-center overflow-hidden">
<img
src="{{ $product->image_url }}"
alt="{{ $product->name }}"
class="w-full h-full object-cover object-center"
>
<div class="absolute top-3 left-3 flex flex-col gap-1.5">
@if($product->is_featured)
<span class="px-3 py-1 rounded-full bg-gradient-to-r from-rose-500 to-amber-500 text-white font-heading text-xs font-black shadow-sm flex items-center space-x-1">
<span>🔥</span>
<span>Populair</span>
</span>
@php
$gallery = [];
if (!empty($product->image_url)) {
$gallery[] = $product->image_url;
}
if (!empty($product->gallery_images) && is_array($product->gallery_images)) {
foreach ($product->gallery_images as $gImg) {
if (!empty($gImg) && !in_array($gImg, $gallery, true)) {
$gallery[] = $gImg;
}
}
}
if (empty($gallery)) {
$gallery[] = '/images/products/crystal-dragon.jpg';
}
@endphp
<!-- Productgalerij met interactieve fotokiezer -->
<div class="space-y-3"
x-data="{
activeImage: '{{ $gallery[0] }}',
images: {{ json_encode($gallery, JSON_UNESCAPED_SLASHES) }},
currentIndex: 0,
nextImage() {
this.currentIndex = (this.currentIndex + 1) % this.images.length;
this.activeImage = this.images[this.currentIndex];
},
prevImage() {
this.currentIndex = (this.currentIndex - 1 + this.images.length) % this.images.length;
this.activeImage = this.images[this.currentIndex];
},
selectImage(idx) {
this.currentIndex = idx;
this.activeImage = this.images[idx];
}
}">
<div class="rounded-3xl bg-white border border-slate-100 overflow-hidden shadow-sm relative group">
<div class="relative h-72 sm:h-96 md:h-112 bg-slate-100 flex items-center justify-center overflow-hidden">
<img
:src="activeImage"
alt="{{ $product->name }}"
class="w-full h-full object-cover object-center transition-all duration-300"
>
<div class="absolute top-3 left-3 flex flex-col gap-1.5 z-10">
@if($product->is_featured)
<span class="px-3 py-1 rounded-full bg-gradient-to-r from-rose-500 to-amber-500 text-white font-heading text-xs font-black shadow-sm flex items-center space-x-1">
<span>🔥</span>
<span>Populair</span>
</span>
@endif
</div>
<!-- Foto Counter Badge -->
@if(count($gallery) > 1)
<div class="absolute bottom-3 right-3 z-10">
<span class="px-2.5 py-1 rounded-full bg-slate-900/80 backdrop-blur-md text-white font-mono text-[11px] font-bold shadow-sm">
<span x-text="currentIndex + 1"></span> / {{ count($gallery) }}
</span>
</div>
<!-- Vorige / Volgende Pijlen -->
<button
type="button"
@click="prevImage"
class="absolute left-3 top-1/2 -translate-y-1/2 w-9 h-9 rounded-full bg-white/90 hover:bg-white text-slate-800 shadow-md flex items-center justify-center transition opacity-0 group-hover:opacity-100 focus:opacity-100 z-10"
aria-label="Vorige foto"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M15 19l-7-7 7-7"/></svg>
</button>
<button
type="button"
@click="nextImage"
class="absolute right-3 top-1/2 -translate-y-1/2 w-9 h-9 rounded-full bg-white/90 hover:bg-white text-slate-800 shadow-md flex items-center justify-center transition opacity-0 group-hover:opacity-100 focus:opacity-100 z-10"
aria-label="Volgende foto"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M9 5l7 7-7 7"/></svg>
</button>
@endif
</div>
</div>
<!-- Thumbnails Strip (indien meerdere foto's) -->
@if(count($gallery) > 1)
<div class="flex items-center space-x-2.5 overflow-x-auto pb-2">
<template x-for="(img, idx) in images" :key="idx">
<button
type="button"
@click="selectImage(idx)"
class="relative w-16 h-16 sm:w-20 sm:h-20 rounded-2xl overflow-hidden shrink-0 border-2 transition-all duration-200 cursor-pointer"
:class="currentIndex === idx ? 'border-amber-400 ring-2 ring-amber-400/40 shadow-sm scale-105' : 'border-slate-200 opacity-60 hover:opacity-100 hover:border-slate-400'"
>
<img :src="img" alt="Thumbnail" class="w-full h-full object-cover">
</button>
</template>
</div>
@endif
</div>
<!-- Print Specificaties Card (Minder lomp, verfijnd) -->