<!-- @format -->

<script lang="ts" setup>
import { ArrowDown } from '@element-plus/icons-vue'
import { useCommonStore } from '@/stores/modules/common'

const router = useRouter()
const commonStore = useCommonStore()
const { navigateTextColor } = storeToRefs(commonStore)

const catalogsVisible = ref<boolean>(false)
const resourceVisible = ref<boolean>(false)
const aboutVisible = ref<boolean>(false)

function toCategories() {
  router.push('/categories')
}
</script>

<template>
  <div class="flex gap-80px">
    <NuxtLink
      to="/solutions"
      class="!hover:text-#9B6CFF cursor-pointer"
      :style="{
        color: navigateTextColor,
      }"
    >
      Solutions
    </NuxtLink>
    <el-dropdown
      popper-class="custom-navigate-dropdown no-dropdown"
      @visible-change="(visible) => (catalogsVisible = visible)"
    >
      <span
        class="el-dropdown-link text-16px flex items-center"
        :class="[{ '!text-#9B6CFF': catalogsVisible }]"
        :style="{
          color: navigateTextColor,
        }"
        @click.stop="toCategories"
      >
        Catalogs
        <el-icon
          class="el-icon--right custom-arrow"
          :class="catalogsVisible ? 'custom-arrow-up' : 'custom-arrow-down'"
        >
          <ArrowDown class="text-14px" />
        </el-icon>
      </span>
    </el-dropdown>
    <el-dropdown
      popper-class="custom-navigate-dropdown "
      @visible-change="(visible) => (resourceVisible = visible)"
    >
      <span
        class="el-dropdown-link text-16px flex items-center"
        :class="[{ '!text-#9B6CFF': resourceVisible }]"
        :style="{
          color: navigateTextColor,
        }"
      >
        Resources
        <el-icon
          class="el-icon--right custom-arrow"
          :class="resourceVisible ? 'custom-arrow-up' : 'custom-arrow-down'"
        >
          <ArrowDown class="text-14px" />
        </el-icon>
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item>
            <NuxtLink to="/blog">
              Blog
            </NuxtLink>
          </el-dropdown-item>
          <el-dropdown-item>
            <NuxtLink to="/faq">
              FAQ
            </NuxtLink>
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
    <el-dropdown
      popper-class="custom-navigate-dropdown"
      @visible-change="(visible) => (aboutVisible = visible)"
    >
      <span
        class="el-dropdown-link text-16px flex items-center"
        :class="[{ '!text-#9B6CFF': aboutVisible }]"
        :style="{
          color: navigateTextColor,
        }"
      >
        About
        <el-icon
          class="el-icon--right custom-arrow"
          :class="aboutVisible ? 'custom-arrow-up' : 'custom-arrow-down'"
        >
          <ArrowDown class="text-14px" />
        </el-icon>
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item>
            <NuxtLink to="/about-us">
              About Us
            </NuxtLink>
          </el-dropdown-item>
          <el-dropdown-item>
            <NuxtLink to="/contact">
              Contact Us
            </NuxtLink>
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

<style lang="less" scoped>
.custom-arrow {
  transition: all 0.3s ease-in-out;
}
.custom-arrow-up {
  transform: rotate(180deg);
}
.custom-arrow-down {
  transform: rotate(0deg);
}
</style>

<style>
.custom-navigate-color {
  color: #fff;
}
</style>
