Skip to content

Commit fbece01

Browse files
committed
docs(useGroupModel): Demos separated for readability
1 parent 7bece74 commit fbece01

File tree

4 files changed

+88
-44
lines changed

4 files changed

+88
-44
lines changed

packages/documentation/docs/demos/composables/useGroupModel/DemoUseGroupModelBasic.vue

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ const { options, select, value } = useGroupModel<string>({
77
options: ['apple', 'banana', 'orange', 'watermelon'],
88
multi: isMultiEnabled,
99
})
10-
11-
const { options: countOptions, select: countSelect, value: countValue } = useGroupModel({ options: 3 })
12-
13-
const { options: objOptions, select: objSelect } = useGroupModel({
14-
options: [
15-
{ title: 'Home', icon: 'i-bx-home' },
16-
{ title: 'Categories', icon: 'i-bx-category' },
17-
{ title: 'Cart', icon: 'i-bx-basket' },
18-
{ title: 'Profile', icon: 'i-bx-user-circle' },
19-
],
20-
})
2110
</script>
2211

2312
<template>
@@ -42,37 +31,5 @@ const { options: objOptions, select: objSelect } = useGroupModel({
4231
? value ? [...value].join(', ') : String(value)
4332
: String(value)
4433
}}</small>
45-
46-
<hr class="!my-12 block">
47-
48-
<div class="flex flex-wrap gap-8 mb-4">
49-
<ABtn
50-
v-for="option in countOptions"
51-
:key="option.value"
52-
:variant="option.isSelected ? 'fill' : 'light'"
53-
@click="countSelect(option.value)"
54-
>
55-
Index: {{ option.value }}
56-
</ABtn>
57-
</div>
58-
<small>Selected: {{ String(countValue) }}</small>
59-
60-
<hr class="!my-12 block">
61-
62-
<div class="flex flex-wrap gap-6 mb-4">
63-
<div
64-
v-for="option in objOptions"
65-
:key="option.value"
66-
class="flex flex-col gap-1 items-center cursor-pointer"
67-
:class="option.isSelected && 'text-primary'"
68-
@click="objSelect(option.value)"
69-
>
70-
<i
71-
:class="option.value.icon"
72-
class="text-lg"
73-
/>
74-
<span>{{ option.value.title }}</span>
75-
</div>
76-
</div>
7734
</div>
7835
</template>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script lang="ts" setup>
2+
import { useGroupModel } from 'anu-vue'
3+
const { options, select, value } = useGroupModel({
4+
options: 3,
5+
})
6+
</script>
7+
8+
<template>
9+
<div class="flex flex-wrap gap-8 mb-4">
10+
<ABtn
11+
v-for="option in options"
12+
:key="option.value"
13+
:variant="option.isSelected ? 'fill' : 'light'"
14+
@click="select(option.value)"
15+
>
16+
Index: {{ option.value }}
17+
</ABtn>
18+
</div>
19+
<small>Selected: {{ String(value) }}</small>
20+
</template>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script lang="ts" setup>
2+
import { useGroupModel } from 'anu-vue'
3+
4+
const { options, select, value } = useGroupModel({
5+
options: [
6+
{ title: 'Home', icon: 'i-bx-home' },
7+
{ title: 'Categories', icon: 'i-bx-category' },
8+
{ title: 'Cart', icon: 'i-bx-basket' },
9+
{ title: 'Profile', icon: 'i-bx-user-circle' },
10+
],
11+
})
12+
</script>
13+
14+
<template>
15+
<div class="flex flex-wrap gap-6 mb-4">
16+
<div
17+
v-for="option in options"
18+
:key="option.value.title"
19+
class="flex flex-col gap-1 items-center cursor-pointer"
20+
:class="option.isSelected && 'text-primary'"
21+
@click="select(option.value)"
22+
>
23+
<i
24+
:class="option.value.icon"
25+
class="text-lg"
26+
/>
27+
<span>{{ option.value.title }}</span>
28+
</div>
29+
</div>
30+
<small>Selected: {{ JSON.stringify(value) }}</small>
31+
</template>

packages/documentation/docs/guide/composables/useGroupModel.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,47 @@
77

88
`useGroupModel` allows you to create `v-model` like binding for a group.
99

10+
You can use `multi` property to enable selecting multiple values from options.
11+
1012
<DemoUseGroupModelBasic />
1113

1214
<template #code>
1315

14-
<<< @/demos/composables/useGroupModel/DemoUseGroupModelBasic.vue
16+
<<< @/demos/composables/useGroupModel/DemoUseGroupModelBasic.vue{6-9}
17+
18+
</template>
19+
20+
</Demo>
21+
22+
<!-- 👉 Indexed -->
23+
<Demo>
24+
25+
## Indexed
26+
27+
You can also create options without predefined value. Pass any positive number to `options` property and it will create index based options.
28+
29+
<DemoUseGroupModelIndexed />
30+
31+
<template #code>
32+
33+
<<< @/demos/composables/useGroupModel/DemoUseGroupModelIndexed.vue{4}
34+
35+
</template>
36+
37+
</Demo>
38+
39+
<!-- 👉 Object -->
40+
<Demo>
41+
42+
## Object
43+
44+
description
45+
46+
<DemoUseGroupModelObject />
47+
48+
<template #code>
49+
50+
<<< @/demos/composables/useGroupModel/DemoUseGroupModelObject.vue{4-11}
1551

1652
</template>
1753

0 commit comments

Comments
 (0)