2023-12-15 16:17:33 +00:00
|
|
|
<script lang="ts" setup>
|
2023-10-31 14:38:43 +00:00
|
|
|
import { StyleService } from '@/Stores/style';
|
2023-03-03 15:54:28 +00:00
|
|
|
// import { Link } from '@inertiajs/vue3'
|
2023-10-31 14:38:43 +00:00
|
|
|
import { Link } from '@inertiajs/vue3';
|
|
|
|
import { computed } from 'vue';
|
2023-03-03 15:54:28 +00:00
|
|
|
import { stardust } from '@eidellev/adonis-stardust/client';
|
|
|
|
|
|
|
|
const props = defineProps({
|
2023-10-31 14:38:43 +00:00
|
|
|
href: {
|
|
|
|
type: String,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
routeName: {
|
|
|
|
type: String,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
param: {
|
|
|
|
type: Number,
|
|
|
|
},
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default: 'flex',
|
|
|
|
},
|
|
|
|
activeColor: {
|
|
|
|
type: String,
|
|
|
|
default: null,
|
|
|
|
},
|
|
|
|
isDesktopIconOnly: Boolean,
|
|
|
|
dropdown: Boolean,
|
|
|
|
active: Boolean,
|
2023-12-15 16:17:33 +00:00
|
|
|
underline: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
2023-10-31 14:38:43 +00:00
|
|
|
});
|
2023-03-03 15:54:28 +00:00
|
|
|
|
|
|
|
const is = computed(() => {
|
2023-10-31 14:38:43 +00:00
|
|
|
if (props.href) {
|
|
|
|
return 'a';
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
if (props.routeName) {
|
|
|
|
return Link;
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
return 'div';
|
|
|
|
});
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
const styleStore = StyleService();
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-12-15 16:17:33 +00:00
|
|
|
// const activeColor = props.activeColor ?? `${styleStore.navBarItemLabelActiveColorStyle} dark:text-slate-400`;
|
|
|
|
|
|
|
|
|
|
|
|
// const active = computed(() => {
|
|
|
|
// if (props.routeName && stardust.isCurrent(props.routeName)) {
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// });
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-12-15 16:17:33 +00:00
|
|
|
const activeClass = computed(() => {
|
|
|
|
if (props.routeName && stardust.isCurrent(props.routeName)) {
|
|
|
|
// console.log(props.item.route);
|
|
|
|
const activeCls = [
|
|
|
|
styleStore.navBarItemLabelActiveColorStyle,
|
|
|
|
'dark:text-slate-400'
|
|
|
|
];
|
|
|
|
|
|
|
|
if (props.underline) {
|
|
|
|
activeCls.push('app-menu-entry__active');
|
|
|
|
}
|
|
|
|
|
|
|
|
// return `${styleStore.navBarItemLabelActiveColorStyle} dark:text-slate-400 app-menu-entry__active`;
|
|
|
|
return activeCls;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// const activeClass = computed(
|
|
|
|
// // () => props.routeName && route().current(props.routeName) == true ? props.activeColor : null
|
|
|
|
// () => (props.routeName && stardust.isCurrent(props.routeName) ? props.activeColor : null),
|
|
|
|
// );
|
2023-03-03 15:54:28 +00:00
|
|
|
// const itemRoute = computed(() => (props.routeName ? stardust.route(props.routeName): ''));
|
|
|
|
|
|
|
|
const componentClass = computed(() => {
|
2023-10-31 14:38:43 +00:00
|
|
|
const base = [
|
|
|
|
props.type,
|
2023-12-15 16:17:33 +00:00
|
|
|
`${styleStore.navBarItemLabelStyle} dark:text-white dark:hover:text-slate-400 ${styleStore.navBarItemLabelHoverStyle}`,
|
|
|
|
// props.active
|
|
|
|
// ? activeColor
|
|
|
|
// : `${styleStore.navBarItemLabelStyle} dark:text-white dark:hover:text-slate-400 ${styleStore.navBarItemLabelHoverStyle}`,
|
2023-10-31 14:38:43 +00:00
|
|
|
];
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
if (props.type === 'block') {
|
|
|
|
base.push('lg:flex');
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
if (!props.dropdown) {
|
|
|
|
base.push('py-2', 'px-3');
|
|
|
|
} else {
|
|
|
|
base.push('p-0', 'lg:py-2', 'lg:px-3');
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
if (props.isDesktopIconOnly) {
|
|
|
|
base.push('lg:w-16', 'lg:justify-center');
|
|
|
|
}
|
2023-03-03 15:54:28 +00:00
|
|
|
|
2023-10-31 14:38:43 +00:00
|
|
|
return base;
|
|
|
|
});
|
2023-03-03 15:54:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-12-15 16:17:33 +00:00
|
|
|
<component :is="is" class="items-center grow-0 shrink-0 relative cursor-pointer" :class="[componentClass, activeClass]"
|
|
|
|
:href="routeName ? stardust.route(props.routeName, [props.param]) : href">
|
2023-10-31 14:38:43 +00:00
|
|
|
<slot />
|
|
|
|
</component>
|
2023-03-03 15:54:28 +00:00
|
|
|
</template>
|
2023-12-15 16:17:33 +00:00
|
|
|
|
|
|
|
<style lang="css" scoped>
|
|
|
|
.app-menu-entry__active {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.app-menu-entry__active::before {
|
|
|
|
content: "___";
|
|
|
|
position: absolute;
|
|
|
|
pointer-events: none;
|
|
|
|
/* border-bottom-color: var(--color-main-background); */
|
|
|
|
/* transform: translateX(-50%); */
|
|
|
|
width: 100%;
|
|
|
|
/* height: 5px; */
|
|
|
|
border-radius: 3px;
|
|
|
|
background-color: var(--color-primary-element-text);
|
|
|
|
/* left: 50%; */
|
|
|
|
bottom: 6px;
|
|
|
|
display: block;
|
|
|
|
transition: all 0.1s ease-in-out;
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
</style>
|