Skip to content

Commit 7774029

Browse files
committed
add tooltip for radio's options label
1 parent 83f75ed commit 7774029

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/Demo.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ div
1818
v-tooltip="option.tooltip"
1919
style="width: 16px; height: 16px; margin-left: 5px;"
2020
)
21+
template(
22+
v-for="option, index in option.options"
23+
:key="smallOption.id"
24+
v-slot:[`radioTooltip_${index}`]
25+
)
26+
img(
27+
src="./assets/icons/question.svg"
28+
v-if="option.tooltip"
29+
v-tooltip="option.tooltip"
30+
style="width: 16px; height: 16px; margin-left: 5px;"
31+
)
2132

2233
pre {{ data }}
2334
</template>

src/VField.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ component(
55
)
66
template(#tooltip)
77
slot(name="tooltip")
8+
template(
9+
v-for="option, index in option.options"
10+
:key="index"
11+
v-slot:[`radioTooltip_${index}`]
12+
)
13+
slot(
14+
:name="`radioTooltip_${index}`"
15+
)
816
template(
917
v-for="slot, index in option.slots",
1018
:key="index",

src/components/Radio/Radio.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
extends ../Base/InputBase.pug
33
block input
44
.vfield__radio-wrapper
5-
.vfield__check(v-for="option in options")
5+
.vfield__check(v-for="option, index in options")
66
input.vfield__check-input(
77
type='radio'
88
:name='name'
@@ -14,6 +14,9 @@ block input
1414
label.vfield__check-label(
1515
:for="`${group ? group + '-' : ''}${name}-${option.value}`"
1616
) {{option.label}}
17+
slot(
18+
:name="`radioTooltip_${index}`"
19+
)
1720
</template>
1821
<script lang="ts" setup>
1922
import { useLocalValue, useFieldId, useFieldClass } from '@/utilities/hooks';

0 commit comments

Comments
 (0)