sekolah_adiwiyata/resources/views/galeri.blade.php

87 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@extends('layouts.app')
@section('content')
<section id="section4" class="container mx-auto p-12 md:py-12">
<div class="flex justify-between mb-15">
<h4 class="text-lg md:text-2xl font-extrabold text-black">Galeri Adiwiyata</h4>
</div>
<div class="flex flex-row gap-10">
<div class="grid grid-rows-1 md:grid-cols-3 lg:grid-cols-4 gap-5">
@foreach($kegiatan as $dataKeg)
<?php
$images = json_decode($dataKeg->image);
?>
<div class="relative group w-full h-50 overflow-hidden rounded-lg shadow-[10px_10px_10px_0px_rgba(0,0,0,0.25)]">
<img src="{{ asset($images[0]) }}" class="w-full h-full object-cover" alt="Galeri">
<div class="absolute inset-0 bg-success bg-opacity-50 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col justify-center p-4 gap-3">
<h4 class="mb-5 font-bold text-white w-50">{{ substr($dataKeg->judul,0,35) }}...</h4>
{{-- <p class="text-white text-sm font-normal">1 Agustus 2025</p> --}}
{{-- <button class="rounded-md bg-gray-950/5 px-2.5 py-1.5 text-sm font-semibold text-gray-900 hover:bg-gray-950/10">Open dialog</button> --}}
<a href="#" data-url="{{$dataKeg->image}}" data-judul="{{$dataKeg->judul}}" class="btnmodal p-2 text-black text-sm bg-white opacity-50 rounded-[10px] mx-auto md:mx-0 text-center flex flex-row justify-between gap-3 w-40 ">
<span>Lihat Detail</span> <x-lucide-arrow-right width="20" class="text-black text-right"/>
</a>
</div>
</div>
@endforeach
</div>
</div>
</section>
<div id="myModal" class="fixed inset-0 z-50 hidden bg-black/50 flex items-center justify-center">
<div class="bg-white rounded-lg shadow-lg w-1/2 p-6 relative">
<div id="carousel" class="relative w-full flex transition-transform duration-500">
<img id="image" src="" alt="" class="w-full rounded">
<!-- tombol navigasi -->
<button id="prev" class="absolute left-0 top-1/2 transform -translate-y-1/2 bg-gray-800 text-white px-3 py-1 rounded"></button>
<button id="next" class="absolute right-0 top-1/2 transform -translate-y-1/2 bg-gray-800 text-white px-3 py-1 rounded"></button>
</div>
<div class="flex justify-end space-x-2 mt-1">
<button onclick="closeModal()" class="bg-gray-300 text-gray-700 px-4 py-2 cursor-pointer rounded">Tutup</button>
</div>
</div>
</div>
@endsection
@section('js')
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script>
let slides = [];
let currentIndex = 0;
$('.btnmodal').on('click', function(e){
e.preventDefault();
$('#myModal').removeClass('hidden');
$('#judul').html($(this).data('judul'));
// ambil data-images dan parse JSON
slides = $(this).data('url');
if (!Array.isArray(slides)) {
slides = JSON.parse(slides);
}
console.log(slides);
currentIndex = 0;
$('#image').attr('src', "{{ asset('/') }}"+slides[currentIndex]);
});
// tombol navigasi
$('#next').on('click', function(){
if(slides.length > 0){
currentIndex = (currentIndex + 1) % slides.length;
$('#image').attr('src', "{{ asset('/') }}"+slides[currentIndex]);
}
});
$('#prev').on('click', function(){
if(slides.length > 0){
currentIndex = (currentIndex - 1 + slides.length) % slides.length;
$('#image').attr('src', "{{ asset('/') }}"+slides[currentIndex]);
}
});
function closeModal(){
$('#myModal').addClass('hidden');
}
</script>
@endsection