Skip to content

Commit 90fd7bb

Browse files
committed
docs(VBadge): improved usage example
1 parent b207522 commit 90fd7bb

File tree

1 file changed

+95
-22
lines changed

1 file changed

+95
-22
lines changed

packages/docs/src/examples/v-badge/usage.vue

Lines changed: 95 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,74 @@
55
:name="name"
66
:options="options"
77
>
8-
<div class="text-center">
9-
<v-badge v-bind="props">
10-
<v-icon
11-
icon="$vuetify"
12-
size="x-large"
13-
></v-icon>
8+
<div class="d-flex ga-12 justify-center">
9+
<v-badge v-bind="props" color="warning" dot>
10+
<v-icon icon="mdi-bell"></v-icon>
11+
</v-badge>
12+
13+
<v-badge v-bind="props" color="error" content="1">
14+
<v-icon icon="mdi-cog"></v-icon>
15+
</v-badge>
16+
17+
<v-badge v-bind="props" color="success" content="25">
18+
<v-icon icon="mdi-calendar"></v-icon>
19+
</v-badge>
20+
21+
<v-badge v-bind="props" color="primary" content="99+">
22+
<v-icon icon="mdi-cart"></v-icon>
1423
</v-badge>
1524
</div>
1625

1726
<template v-slot:configuration>
18-
<v-checkbox v-model="dot" label="Dot"></v-checkbox>
19-
20-
<v-slider
21-
v-model="content"
22-
label="Value"
23-
max="100"
24-
min="0"
25-
step="1"
26-
></v-slider>
27+
<v-checkbox
28+
v-model="bordered"
29+
label="Bordered"
30+
hide-details
31+
></v-checkbox>
32+
33+
<div v-if="model !== inline">
34+
<h5 class="pl-2">Location</h5>
35+
<v-radio-group
36+
v-model="location"
37+
class="pa-1 mb-2"
38+
density="compact"
39+
hide-details
40+
>
41+
<div class="d-flex">
42+
<v-radio value="top left"></v-radio>
43+
<v-radio value="top center"></v-radio>
44+
<v-radio value="top right"></v-radio>
45+
</div>
46+
<div class="d-flex">
47+
<v-radio value="left center"></v-radio>
48+
<v-radio class="opacity-0" disabled></v-radio>
49+
<v-radio value="right center"></v-radio>
50+
</div>
51+
<div class="d-flex">
52+
<v-radio value="bottom left"></v-radio>
53+
<v-radio value="bottom center"></v-radio>
54+
<v-radio value="bottom right"></v-radio>
55+
</div>
56+
</v-radio-group>
57+
<v-slider
58+
v-if="location !== 'top center' && location !== 'bottom center'"
59+
v-model="offsetX"
60+
label="Offset (x)"
61+
max="20"
62+
min="-20"
63+
step="5"
64+
hide-details
65+
></v-slider>
66+
<v-slider
67+
v-if="location !== 'right center' && location !== 'left center'"
68+
v-model="offsetY"
69+
label="Offset (y)"
70+
max="20"
71+
min="-20"
72+
step="5"
73+
hide-details
74+
></v-slider>
75+
</div>
2776
</template>
2877
</ExamplesUsageExample>
2978
</template>
@@ -33,23 +82,47 @@
3382
const model = ref('default')
3483
const content = ref(0)
3584
const dot = ref(false)
85+
const bordered = ref(false)
3686
const options = ['floating', 'inline']
87+
const location = ref('top right')
88+
const offsetX = ref(0)
89+
const offsetY = ref(0)
3790
const props = computed(() => {
3891
return {
3992
content: content.value || undefined,
4093
dot: dot.value || undefined,
94+
bordered: bordered.value || undefined,
4195
floating: model.value === 'floating' || undefined,
4296
inline: model.value === 'inline' || undefined,
97+
location: location.value,
98+
'offset-x': offsetX.value || undefined,
99+
'offset-y': offsetY.value || undefined,
43100
}
44101
})
45102
46-
const slots = computed(() => {
47-
return `
48-
<v-icon icon="$vuetify" size="x-large"></v-icon>
49-
`
50-
})
51-
52103
const code = computed(() => {
53-
return `<${name}${propsToString(props.value)}>${slots.value}</${name}>`
104+
return `<div class="d-flex ga-12 justify-center">
105+
<v-badge${propsToString(props.value)} color="warning" dot>
106+
<v-icon icon="mdi-bell"></v-icon>
107+
</v-badge>
108+
109+
<v-badge${propsToString(props.value)} color="error" content="1">
110+
<v-icon icon="mdi-cog"></v-icon>
111+
</v-badge>
112+
113+
<v-badge${propsToString(props.value)} color="success" content="25">
114+
<v-icon icon="mdi-calendar"></v-icon>
115+
</v-badge>
116+
117+
<v-badge${propsToString(props.value)} color="primary" content="99+">
118+
<v-icon icon="mdi-cart"></v-icon>
119+
</v-badge>
120+
</div>`
54121
})
55122
</script>
123+
124+
<style scoped>
125+
::v-deep(.v-radio) {
126+
flex-grow: 0 !important;
127+
}
128+
</style>

0 commit comments

Comments
 (0)