<template>
  <div v-if="!isMobile" class="product-images">
    <div
      v-for="image in currentVariantImages?.slice(0, 5)"
      :key="image?.id"
    >
      <img width="100%" :src="image?.src" :alt="image?.src">
    </div>
  </div>

  <Swiper
    v-if="isMobile"
    :pagination="true"
    :loop="true"
    :modules="modules"
    class="mySwiper"
  >
    <SwiperSlide
      v-for="image in currentVariantImages?.slice(0, 5)"
      :key="image?.id"
    >
      <img width="100%" :src="image?.src" :alt="image?.src">
    </SwiperSlide>
  </Swiper>
</template>

<script setup lang="ts">
import { useMediaQuery } from '@vueuse/core'
import { Pagination } from 'swiper/modules'
import { Swiper, SwiperSlide } from 'swiper/vue'
import { useCurrentProduct } from '~/composables'
import 'swiper/css'
import 'swiper/css/pagination'

const isMobile = useMediaQuery('(max-width: 1280px)')
const modules = [Pagination]
const { currentVariantImages } = useCurrentProduct()
</script>

<style lang="scss">
.product-images {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
</style>
