blob: f2ebb89ac12463b9bbec1e1bb477d275667c79e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { useStore, TabId } from '../store';
import { toRefs } from 'vue';
import { noop } from 'lodash-es';
import { get, set } from '@vueuse/core';
const props = defineProps<{
tab: TabId;
name: String,
disabled?: Boolean
}>()
const store = useStore()
const { activeTab } = storeToRefs(store)
const { name, disabled, tab } = toRefs(props)
//const isActive = (tab: TabId, activeTab: TabId) => isEqual(activeTab, tab);
const setActiveTab = (tab: TabId) => get(disabled) ? noop() : set(activeTab, tab)
</script>
<template>
<li>
<a href="/" @click.prevent="setActiveTab(tab)" class="lia group" :class="{ 'pointer-events-none disabled':disabled }">
<svg class="w-5 h-5 text-gray-500 transition duration-75 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white"
aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 22 21">
<slot name="icon" />
</svg>
<span class="ms-3">{{ name }}</span>
</a>
</li>
</template>
<style lang="scss">
.lia{
@apply flex items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-gray-100 dark:hover:bg-gray-700;
&.disabled{
@apply opacity-50;
}
}
</style>
|