<!-- Carrousel des logos clients -->

<template>
  <LayoutContainer>
    <!-- Titre -->
    <v-row justify="center">
      <h2 class="text-center">
        <slot name="title">
          Plus de <span class="alt-color">5000 structures</span> nous font confiance
        </slot>
      </h2>
    </v-row>

    <v-container>
      <v-row>
        <!-- Fléche de gauche -->
        <v-btn
          icon="fas fa-chevron-left"
          @click="goToPrevious"
        />

        <!-- Carrousel -->
        <Carousel
          ref="carousel"
          class="elevation-4 mb-12"
          :items-to-show="4"
          :items-to-scroll="2"
        >
          <Slide v-for="(item, index) in items" :key="index">
            <div>
              <v-img :src="item.src" alt="Card image cap" />
            </div>
          </Slide>
        </Carousel>

        <!-- Fléche de droite -->
        <v-btn
          icon="fas fa-chevron-right"
          @click="goToNext"
        />
      </v-row>
    </v-container>
  </LayoutContainer>
</template>

<script setup lang="ts">
import { Carousel, Slide } from "vue3-carousel";
import { PropType } from "@vue/runtime-core";

const carousel: Ref<typeof Carousel | null> = ref(null);

const props = defineProps({
  items: {
    type: Array as PropType<Array<{ src: string }>>,
    required: true
  }
});

const goToPrevious = () => {
  carousel.value!.prev();
};

const goToNext = () => {
  carousel.value!.next();
};
</script>

<style scoped lang="scss">
.v-row {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1300px;
  margin-right: auto;
  margin-left: auto;
}

h2 {
  margin-bottom: 2rem;
  font-style: normal;
  text-align: center;
  font-weight: 600;
  font-size: 42px;
  line-height: 42px;
  color: var(--on-primary-color);
  width: 50%;
}

.alt-color {
  color: var(--on-primary-color-alt);
}

.v-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 60px;
  height: 60px;
  background-color: transparent;
  color: var(--on-primary-color);
  border: 2px solid var(--on-primary-color);
  cursor: pointer;
  margin-right: 1rem;
  margin-top: 1rem;
  border-radius: 0;
}

.carousel {
  background-color: white;
  margin-top: 2rem;
  border-radius: 20px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: #071b1f;
}

.v-img {
  height: 10rem;
  width: 10rem;
  margin: 2rem auto;
}
</style>
