1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-18 08:38:45 +09:00
cherrypick/src/client/components/ui/radios.vue

59 lines
923 B
Vue
Raw Normal View History

2020-11-14 12:16:28 +09:00
<script lang="ts">
2020-11-14 12:50:24 +09:00
import { defineComponent, h } from 'vue';
2020-11-14 12:16:28 +09:00
import MkRadio from '@/components/ui/radio.vue';
export default defineComponent({
components: {
MkRadio
},
props: {
defs: {
required: true
},
modelValue: {
required: false
},
},
data() {
return {
value: this.modelValue,
}
},
watch: {
value() {
this.$emit('update:modelValue', this.value);
}
2020-11-14 12:50:24 +09:00
},
render() {
const label = this.$slots.desc();
const options = this.$slots.default();
return h('div', {
class: 'novjtcto'
}, [
h('div', label),
...options.map(option => h(MkRadio, {
key: option.props.value,
value: option.props.value,
modelValue: this.value,
'onUpdate:modelValue': value => this.value = value,
}, option.children))
]);
2020-11-14 12:16:28 +09:00
}
});
</script>
2020-11-18 12:09:14 +09:00
<style lang="scss">
2020-11-14 12:16:28 +09:00
.novjtcto {
margin: 32px 0;
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
}
</style>