Skip to content

Commit 6bd1392

Browse files
committed
fix: update ButtonGroup to use modelValue for v-model binding
1 parent 0dd5ca5 commit 6bd1392

3 files changed

Lines changed: 18 additions & 30 deletions

File tree

adminforth/documentation/docs/tutorial/03-Customization/15-afcl.md

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const activeButton = ref('')
5353

5454
...
5555

56-
<ButtonGroup v-model:activeButton="activeButton">
56+
<ButtonGroup v-model="activeButton">
5757
<template #button:Profile>
5858
<div class="flex px-4 py-2">
5959
<IconUserCircleSolid class="w-5 h-5 me-2"/>
@@ -66,18 +66,6 @@ const activeButton = ref('')
6666
Board
6767
</div>
6868
</template>
69-
<template #button:Lock>
70-
<div class="flex px-4 py-2">
71-
<IconShieldOutline class="w-5 h-5 me-2"/>
72-
Passkeys
73-
</div>
74-
</template>
75-
<template #button:Security>
76-
<div class="flex px-4 py-2">
77-
<IconLockSolid class="w-5 h-5 me-2"/>
78-
Security
79-
</div>
80-
</template>
8169
</ButtonGroup>
8270
```
8371

@@ -95,19 +83,19 @@ const activeButton = ref('')
9583

9684
...
9785

98-
<ButtonGroup :solidColor="true">
99-
<template #button:Profile>
100-
<div class="flex px-4 py-2">
101-
<IconPlusOutline class="w-5 h-5 me-2"/>
102-
Add passkey
103-
</div>
104-
</template>
105-
<template #button:Dashboard @click="console.log('Dashboard clicked')">
106-
<div class="flex px-2">
107-
<IconCaretDownSolid class="w-5 h-5"/>
108-
</div>
109-
</template>
110-
</ButtonGroup>
86+
<ButtonGroup :solidColor="true">
87+
<template #button:Profile>
88+
<div class="flex px-4 py-2" @click="console.log("Add passkey got clicked")">
89+
<IconPlusOutline class="w-5 h-5 me-2"/>
90+
<p>{{ addPasskeyMode === 'platform' ? 'Add Local Passkey' : 'Add External Passkey' }}</p>
91+
</div>
92+
</template>
93+
<template #button:Dropdown>
94+
<div id="dropdown-button" class="flex px-2 py-2" @click="console.log("Dropdown got clicked")">
95+
<IconCaretDownSolid class="w-5 h-5"/>
96+
</div>
97+
</template>
98+
</ButtonGroup>
11199

112100
```
113101

-4.58 KB
Loading

adminforth/spa/src/afcl/ButtonGroup.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
const activeButton = ref('');
2828
const slotProps = reactive<Record<string, any>>({});
2929
const isInitFinished = ref(false);
30-
const emits = defineEmits([
31-
'update:activeButton',
32-
]);
30+
31+
const emits = defineEmits(['update:modelValue']);
3332
3433
const props = defineProps<{
3534
solidColor?: boolean;
35+
modelValue?: string;
3636
}>();
3737
3838
onMounted(() => {
@@ -68,7 +68,7 @@
6868
function setActiveButton(button: string) {
6969
if (buttons.value.includes(button)) {
7070
activeButton.value = button;
71-
emits('update:activeButton', button);
71+
emits('update:modelValue', button);
7272
}
7373
}
7474

0 commit comments

Comments
 (0)