CviLux_fe/src/components/navbar/Navbar.vue

150 lines
3.5 KiB
Vue

<script setup>
import { onMounted, ref } from "vue";
import NavbarItem from "./NavbarItem.vue";
import NavbarBuilding from "./NavbarBuilding.vue";
import Logo from "@/assets/img/logo.svg";
import useGetCookie from "@/hooks/useGetCookie";
import AlarmDrawer from "@/components/alarm/AlarmDrawer.vue";
import NavbarLang from "./NavbarLang.vue";
import { twMerge } from "tailwind-merge";
const user = ref("");
const menuShow = ref(true);
onMounted(() => {
const name = useGetCookie("niagara_userid");
if (name) {
user.value = name;
}
});
const toggleMenu = () => {
menuShow.value = !menuShow.value;
};
const src = import.meta.env.MODE === "production" ? "./logo.svg" : Logo;
</script>
<template>
<header class="navbar bg-dark text-light-info w-full relative z-50">
<div class="navbar-start">
<div tabindex="0" role="button" class="btn btn-ghost lg:hidden" @click="toggleMenu">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h8m-8 6h16"
/>
</svg>
</div>
<router-link
to="/dashboard"
class="rounded-lg pl-4 text-2xl font-bold text-white flex items-center"
>
<img :src="src" alt="logo" class="w-8 me-1" />
CviLux Group
</router-link>
<NavbarBuilding />
</div>
<div
:class="
twMerge(
'navbar-center flex absolute lg:relative top-full bg-dark',
menuShow ? 'block' : 'hidden'
)
"
>
<NavbarItem />
</div>
<div class="navbar-end mr-4">
<ul class="menu-box">
<li>
<NavbarLang />
</li>
<li>
<AlarmDrawer />
</li>
<li>
<div class="dropdown dropdown-bottom dropdown-end">
<button
tabindex="0"
type="link"
class="flex flex-col justify-center items-center btn-group"
>
<font-awesome-icon
:icon="['fas', 'user-circle']"
size="2x"
class="text-white w-10 m-auto"
/>
<span class="text-white"> {{ user || "webUser" }}</span>
</button>
<ul
tabindex="0"
class="dropdown-content translate-y-2 z-[100] menu py-3 shadow rounded w-32 bg-[#4c625e] border text-center"
>
<li class="text-white">
<router-link
to="logout"
type="link"
class="flex flex-col justify-center items-center"
>{{ $t("sign_out") }}</router-link
>
</li>
</ul>
</div>
</li>
</ul>
</div>
</header>
</template>
<style lang="css">
.sub-drawer {
@apply bg-dark bg-opacity-90 shadow-xl !important;
}
/**menu**/
.menu-box {
@apply flex flex-wrap justify-center ;
position: relative;
z-index: 0;
}
.menu-box .btn-group {
background: transparent;
width: 95px;
}
.menu-box > li {
position: relative;
}
.menu-box > li:not(:last-child)::after {
content: "";
position: absolute;
top: 20px;
bottom: 0;
left: 84px;
right: 0px;
display: block;
width: 25px;
height: 2px;
background-color: #93c0dc;
z-index: 0;
}
.menu-box .btn-group span {
color: #fff;
display: block;
margin-top: 0px;
}
</style>