Skip to content

Commit a6c7d35

Browse files
committed
chore: update VerticalTabs component to use setActiveTab method and emit active tab changes
1 parent 64a6f8f commit a6c7d35

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

adminforth/spa/src/afcl/VerticalTabs.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<li v-for="tab in tabs" :key="`${tab}-tab-controll`">
55
<a
66
href="#"
7-
@click="activeTab = tab"
8-
class="inline-flex items-center rounded-lg w-full"
7+
@click="setActiveTab(tab)"
8+
class="inline-flex items-center px-4 py-3 rounded-lg w-full"
99
:class="tab === activeTab ? 'text-lightVerticalTabsTextActive bg-lightVerticalTabsBackgroundActive active dark:bg-darkVerticalTabsBackgroundActive dark:text-darkVerticalTabsTextActive' : 'text-lightVerticalTabsText dark:text-darkVerticalTabsText hover:text-lightVerticalTabsTextHover bg-lightVerticalTabsBackground hover:bg-lightVerticalTabsBackgroundHover dark:bg-darkVerticalTabsBackground dark:hover:bg-darkVerticalTabsBackgroundHover dark:hover:darkVerticalTabsTextHover'"
1010
aria-current="page"
1111
>
@@ -20,7 +20,7 @@
2020
</template>
2121

2222
<script setup lang="ts">
23-
import { onMounted, useSlots, ref, type Ref } from 'vue';
23+
import { onMounted, useSlots, ref, type Ref } from 'vue';
2424
const tabs : Ref<string[]> = ref([]);
2525
const activeTab = ref('');
2626
const props = defineProps({
@@ -52,6 +52,7 @@
5252
function setActiveTab(tab: string) {
5353
if (tabs.value.includes(tab)) {
5454
activeTab.value = tab;
55+
emites('update:activeTab', tab);
5556
}
5657
}
5758
</script>

adminforth/spa/src/views/SettingsView.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474
<div v-if="!coreStore?.config?.settingPages || coreStore?.config?.settingPages.length === 0">
7575
<p>No setting pages configured or still loading...</p>
7676
</div>
77-
<VerticalTabs v-else ref="VerticalTabsRef">
77+
<VerticalTabs v-else ref="VerticalTabsRef" @update:active-tab="setURL({slug: $event, pageLabel: ''})">
7878
<template v-for="(c,i) in coreStore?.config?.settingPages" :key="`tab:${settingPageSlotName(c,i)}`" v-slot:['tab:'+settingPageSlotName(c,i)]>
79-
<div class="flex items-center justify-center whitespace-nowrap px-8 py-3 gap-2" @click="setURL(c)">
79+
<div class="flex items-center justify-center whitespace-nowrap w-full px-4 gap-2" @click="setURL(c)">
8080
<component v-if="c.icon" :is="getIcon(c.icon)" class="w-5 h-5 group-hover:text-lightSidebarIconsHover transition duration-75 dark:group-hover:text-darkSidebarIconsHover dark:text-darkSidebarIcons" ></component>
8181
{{ c.pageLabel }}
8282
</div>
@@ -199,10 +199,8 @@ function slugifyString(str: string): string {
199199
}
200200
201201
function setURL(item: {
202-
icon?: string | undefined;
203202
pageLabel: string;
204203
slug?: string | undefined;
205-
component?: string | undefined;
206204
}) {
207205
const slug = item?.slug;
208206
if (slug) {

0 commit comments

Comments
 (0)