ابنِ معرض صور مع lightbox.
المكون
@php
new class extends Livewire\Component {
public array $images = [];
public ?int $activeIndex = null;
public function open(int $index): void
{
$this->activeIndex = $index;
}
public function close(): void
{
$this->activeIndex = null;
}
public function next(): void
{
$this->activeIndex = ($this->activeIndex + 1) % count($this->images);
}
public function prev(): void
{
$this->activeIndex = ($this->activeIndex - 1 + count($this->images)) % count($this->images);
}
}
@endphp