mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 18:47:51 +00:00
54 lines
1.6 KiB
Vue
54 lines
1.6 KiB
Vue
<script setup>
|
|
import { useMapGetter } from 'dashboard/composables/store.js';
|
|
import Icon from 'next/icon/Icon.vue';
|
|
|
|
const props = defineProps({
|
|
to: { type: [Object, String], default: '' },
|
|
label: { type: String, default: '' },
|
|
icon: { type: [String, Object], default: '' },
|
|
expandable: { type: Boolean, default: false },
|
|
isExpanded: { type: Boolean, default: false },
|
|
isActive: { type: Boolean, default: false },
|
|
hasActiveChild: { type: Boolean, default: false },
|
|
getterKeys: { type: Object, default: () => ({}) },
|
|
});
|
|
|
|
const emit = defineEmits(['toggle']);
|
|
|
|
const showBadge = useMapGetter(props.getterKeys.badge);
|
|
</script>
|
|
|
|
<template>
|
|
<component
|
|
:is="to ? 'router-link' : 'div'"
|
|
class="flex items-center gap-2 px-2 py-1.5 rounded-lg h-8"
|
|
role="button"
|
|
draggable="false"
|
|
:to="to"
|
|
:title="label"
|
|
:class="{
|
|
'text-n-blue-text bg-n-alpha-2 font-medium': isActive && !hasActiveChild,
|
|
'text-n-slate-12 font-medium': hasActiveChild,
|
|
'text-n-slate-11 hover:bg-n-alpha-2': !isActive && !hasActiveChild,
|
|
}"
|
|
@click.stop="emit('toggle')"
|
|
>
|
|
<div v-if="icon" class="relative flex items-center gap-2">
|
|
<Icon v-if="icon" :icon="icon" class="size-4" />
|
|
<span
|
|
v-if="showBadge"
|
|
class="size-2 -top-px ltr:-right-px rtl:-left-px bg-n-brand absolute rounded-full border border-n-solid-2"
|
|
/>
|
|
</div>
|
|
<span class="text-sm font-medium leading-5 flex-grow">
|
|
{{ label }}
|
|
</span>
|
|
<span
|
|
v-if="expandable"
|
|
v-show="isExpanded"
|
|
class="i-lucide-chevron-up size-3"
|
|
@click.stop="emit('toggle')"
|
|
/>
|
|
</component>
|
|
</template>
|