primevue-mirror/apps/showcase/layouts/AppMenuItem.vue

58 lines
2.2 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<li v-for="(menuitem, index) in menu" :key="`_root${index}`">
2024-06-11 12:21:12 +00:00
<button v-if="menuitem.children && root" v-styleclass="{ selector: '@next', enterFromClass: 'hidden', enterActiveClass: 'animate-slidedown', leaveToClass: 'hidden', leaveActiveClass: 'animate-slideup' }" type="button">
2023-09-09 23:25:16 +00:00
<span class="menu-icon">
2023-02-28 08:29:30 +00:00
<i :class="menuitem.icon"></i>
2023-09-09 23:25:16 +00:00
</span>
2023-02-28 08:29:30 +00:00
<span>{{ menuitem.name }}</span>
<i class="menu-toggle-icon pi pi-angle-down"></i>
</button>
<a v-if="menuitem.href" :href="menuitem.href" target="_blank" rel="noopener noreferrer">
2023-09-09 23:25:16 +00:00
<span v-if="menuitem.icon && root" class="menu-icon">
2023-02-28 08:29:30 +00:00
<i :class="menuitem.icon"></i>
2023-09-09 23:25:16 +00:00
</span>
<span>{{ menuitem.name }}</span>
2024-05-20 11:17:48 +00:00
<Tag v-if="menuitem.badge" :value="menuitem.badge"></Tag>
2023-02-28 08:29:30 +00:00
</a>
2024-05-30 13:30:44 +00:00
2023-12-20 17:23:55 +00:00
<PrimeVueNuxtLink v-if="menuitem.to" :to="menuitem.to" :class="{ 'router-link-active': menuitem.to === $route.fullPath }">
2023-09-09 23:25:16 +00:00
<span v-if="menuitem.icon && root" class="menu-icon">
2023-02-28 08:29:30 +00:00
<i :class="menuitem.icon"></i>
2023-09-09 23:25:16 +00:00
</span>
<span>{{ menuitem.name }}</span>
2024-02-04 22:21:29 +00:00
<Tag v-if="menuitem.badge" :value="menuitem.badge"></Tag>
</PrimeVueNuxtLink>
2023-02-28 08:29:30 +00:00
<span v-if="!root && menuitem.children" class="menu-child-category">{{ menuitem.name }}</span>
2024-05-20 11:17:48 +00:00
<div v-if="menuitem.children" :class="{ hidden: menuitem.children && root && isActiveRootmenuItem(menuitem) }">
2023-02-28 08:29:30 +00:00
<ol>
<AppMenuItem :root="false" :menu="menuitem.children"></AppMenuItem>
</ol>
</div>
</li>
</template>
<script>
export default {
props: {
root: {
type: Boolean,
default: true
},
menu: {
type: Object,
default: null
}
},
methods: {
isActiveRootmenuItem(menuitem) {
2023-12-25 10:59:01 +00:00
return (
2024-05-30 13:30:44 +00:00
menuitem.children &&
!menuitem.children.some((item) => item.to === `/${this.$router.currentRoute.value?.name?.replaceAll('-', '/')}` || (item.children && item.children.some((it) => it.to === `/${this.$router.currentRoute.value.name}`)))
2023-12-25 10:59:01 +00:00
);
2023-02-28 08:29:30 +00:00
}
}
};
</script>