@innertia-solutions/ui 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Nav/Tabs.vue +39 -0
- package/nuxt.config.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useRoute } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
interface Tab {
|
|
5
|
+
label: string
|
|
6
|
+
to: string
|
|
7
|
+
icon?: any
|
|
8
|
+
exact?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
tabs: Tab[]
|
|
13
|
+
activeClass?: string
|
|
14
|
+
}>(), {
|
|
15
|
+
activeClass: 'bg-white dark:bg-slate-800 text-blue-600 dark:text-blue-400 shadow-sm',
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const route = useRoute()
|
|
19
|
+
|
|
20
|
+
const isActive = (tab: Tab) =>
|
|
21
|
+
tab.exact ? route.path === tab.to : route.path.startsWith(tab.to)
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<div class="flex items-center gap-x-1 p-1 bg-slate-100 dark:bg-slate-900/50 rounded-xl w-fit border border-slate-200 dark:border-slate-700">
|
|
26
|
+
<NuxtLink
|
|
27
|
+
v-for="tab in tabs"
|
|
28
|
+
:key="tab.to"
|
|
29
|
+
:to="tab.to"
|
|
30
|
+
class="flex items-center gap-x-2 px-4 py-2 text-xs font-bold rounded-lg transition-all"
|
|
31
|
+
:class="isActive(tab)
|
|
32
|
+
? activeClass
|
|
33
|
+
: 'text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200'"
|
|
34
|
+
>
|
|
35
|
+
<component :is="tab.icon" v-if="tab.icon" class="size-4" />
|
|
36
|
+
{{ tab.label }}
|
|
37
|
+
</NuxtLink>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
package/nuxt.config.ts
CHANGED