ff-webpage/components/Header.vue

82 lines
2.6 KiB
Vue
Raw Normal View History

2024-11-01 13:15:09 +00:00
<template>
<div class="sticky top-0 h-fit">
2024-11-05 13:41:48 +00:00
<div
primary
class="h-24 min-h-fit w-full px-4 md:px-12 py-2.5 justify-between items-center gap-5 flex overflow-hidden"
>
2024-11-01 13:15:09 +00:00
<NuxtLink to="/">
2024-11-05 13:41:48 +00:00
<img class="h-16 w-fit min-w-fit" :src="baseUrl + navbar.logo.url" />
2024-11-01 13:15:09 +00:00
</NuxtLink>
2024-11-05 13:41:48 +00:00
<div class="md:hidden">
<svg
v-if="!open"
viewBox="0 0 24 24"
class="h-10 w-10 cursor-pointer fill-none stroke-2 stroke-white"
@click="open = !open"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
</svg>
<svg
v-else
viewBox="0 0 24 24"
class="h-10 w-10 cursor-pointer fill-none stroke-2 stroke-white"
@click="open = !open"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</div>
<div
class="w-fit max-w-full p-2.5 justify-center items-center gap-7 flex flex-col md:flex-row md:flex-wrap"
:class="open ? 'max-md:absolute top-24 left-0 max-md:w-full bg-primary' : 'max-md:hidden'"
>
2024-11-01 13:15:09 +00:00
<NuxtLink
primary-link
v-for="link in navbar.navbar_items"
:key="link.id"
:to="`/${link.URL}/${link.default_active_child ?? ''}`"
2024-11-01 13:15:09 +00:00
:class="link.URL == params?.[0] ? 'active' : ''"
>
{{ link.name }}
</NuxtLink>
</div>
</div>
<div
v-if="navbar_sub_items && navbar_sub_items?.length != 0"
2024-11-01 13:15:09 +00:00
primary
2024-11-05 13:41:48 +00:00
class="h-fit min-h-fit w-full px-4 md:px-12 border-t-2 border-white justify-center items-center gap-5 flex flex-row max-md:flex-wrap"
2024-11-01 13:15:09 +00:00
>
<NuxtLink
primary-sublink
v-for="sublink in navbar_sub_items"
:key="sublink.id"
:to="`/${params?.[0]}/${sublink.URL}`"
:class="sublink.URL == params?.[1] && !params[2] ? 'active' : ''"
2024-11-05 13:41:48 +00:00
class="w-fit"
2024-11-01 13:15:09 +00:00
>
{{ sublink.name }}
</NuxtLink>
</div>
</div>
</template>
<script setup lang="ts">
import type Global from "../types/single/global";
const {
params: { slug: params },
} = useRoute();
2024-11-05 17:31:12 +00:00
const runtimeConfig = useRuntimeConfig();
const baseUrl = runtimeConfig.public.strapi.url;
2024-11-01 13:15:09 +00:00
const { findOne } = useStrapi();
const { data: global } = await useAsyncData("global", () => findOne<Global>("global"));
const { navbar } = global.value?.data ?? ({} as Global);
2024-11-01 13:15:09 +00:00
2024-11-05 13:41:48 +00:00
const open = ref(false);
2024-11-01 13:15:09 +00:00
const navbar_sub_items = computed(() => {
return navbar.navbar_items.find((ni) => ni.URL == params?.[0])?.navbar_sub_items;
});
</script>