<template>
  <LayoutNavigation />

  <AboutBanner />
  <CommonMenuScroll :menus="menus" class="mb-6" />
  <div v-if="shouldShowStickyMenu" id="sticky-menu">
    <CommonStickyMenu
      :shouldShowStickyMenu="shouldShowStickyMenu"
      :squaresData="squaresData"
    />
  </div>
  <AboutHistoire />
  <AboutValeurs />
  <AboutLogiciels />
  <AboutAgenda />
  <AboutChronologie />
  <AboutEquipe />
  <AboutFAQ />
  <LayoutFooterPrefooter />
  <LayoutFooter id="layout-footer" />
</template>

<script setup>
import { ref, onMounted } from "vue";

const menus = ref([
  { id: "Qui-sommes-nous", label: "Qui sommes-nous", element: null },
  { id: "valeurs", label: "Nos valeurs", element: null },
  { id: "software", label: "Nos logiciels", element: null },
  { id: "agenda", label: "L'agenda opentalent", element: null },
  { id: "story", label: "Notre Histoire", element: null },
  { id: "team", label: "Notre équipe", element: null },
  { id: "faq", label: "Aide", element: null },
]).value;
const shouldShowStickyMenu = ref(true);
const squaresData = [
  {
    id: 1,
    bgColor: "green-square",
    iconClass: "fa-regular fa-comments icon",
    text: "Nous contacter",
    url: "/nous-contacter",
  },
  {
    id: 4,
    bgColor: "darkblue-square",
    iconClass: "fa-solid fa-phone icon",
    text: "Nous Appeler",
  },
];

onMounted(() => {
  const stickyMenu = document.getElementById("sticky-menu");
  const footer = document.getElementById("layout-footer");

  const observer = new IntersectionObserver(
    ([entry]) => {
      shouldShowStickyMenu.value = !entry.isIntersecting;
    },
    {
      root: null,
      threshold: 0,
    }
  );

  observer.observe(footer);
});
</script>

<style scoped>
#sticky-menu {
  position: sticky;
  top: 20rem;
  z-index: 10;
  margin-bottom: -32rem;
  float: right;
}

@media (max-width: 1800px) {
  #sticky-menu {
    top: 16rem;
    margin-bottom: -28rem;
  }
}
</style>
