91 lines
2.6 KiB
Plaintext
91 lines
2.6 KiB
Plaintext
---
|
|
import { Image } from "astro:assets";
|
|
import "swiper/css";
|
|
import "swiper/css/navigation";
|
|
import "swiper/css/pagination";
|
|
import { Icon } from "astro-icon/components";
|
|
|
|
const isHebrew = Astro.currentLocale === "he";
|
|
const { images, class: className } = Astro.props;
|
|
---
|
|
|
|
<div class="bg-white">
|
|
<div class="mx-auto">
|
|
<div class="swiper lg:h-200 md:h-150 h-62">
|
|
<div class="swiper-wrapper">
|
|
{
|
|
images.map((image) => (
|
|
<div class="swiper-slide h-full">
|
|
<div class="flex! h-full flex-col items-center justify-center relative">
|
|
{image.text && (
|
|
<div class="uppercase lg:text-9xl md:text-5xl text-4xl text-white text-shadow-lg absolute font-secondary">
|
|
{image.text}
|
|
</div>
|
|
)}
|
|
<img
|
|
class="w-full h-full object-cover object-center"
|
|
src={image.image}
|
|
alt={image.text}
|
|
/>
|
|
{image.text_alt && (
|
|
<div class="text-sm text-white px-4 py-2 italic bg-black/50 absolute bottom-2 right-2 rounded">
|
|
{image.text_alt}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
))
|
|
}
|
|
</div>
|
|
|
|
<!-- If we need pagination -->
|
|
<div class="swiper-pagination z-50"></div>
|
|
|
|
<!-- If we need navigation buttons -->
|
|
<div class="swiper-button-prev">
|
|
{isHebrew && <Icon name="ph:arrow-circle-right-thin" class="text-white" />}
|
|
{!isHebrew && <Icon name="ph:arrow-circle-left-thin" class="text-white" />}
|
|
</div>
|
|
<div class="swiper-button-next">
|
|
{isHebrew && <Icon name="ph:arrow-circle-left-thin" class="text-white" />}
|
|
{!isHebrew && <Icon name="ph:arrow-circle-right-thin" class="text-white" />}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
import Swiper from "swiper";
|
|
import { Navigation, Pagination, Scrollbar } from "swiper/modules";
|
|
|
|
// Re-initialize after every page swap via View Transitions
|
|
document.addEventListener("astro:after-swap", init);
|
|
|
|
function init() {
|
|
const swiper = new Swiper(".swiper", {
|
|
// Optional parameters
|
|
modules: [Navigation, Pagination, Scrollbar],
|
|
loop: true,
|
|
|
|
// If we need pagination
|
|
pagination: {
|
|
el: ".swiper-pagination",
|
|
},
|
|
|
|
// Navigation arrows
|
|
navigation: {
|
|
nextEl: ".swiper-button-next",
|
|
prevEl: ".swiper-button-prev",
|
|
},
|
|
|
|
// And if we need scrollbar
|
|
scrollbar: {
|
|
el: ".swiper-scrollbar",
|
|
},
|
|
});
|
|
}
|
|
|
|
// Initialize on the first page load
|
|
init();
|
|
</script>
|