This repository was archived by the owner on Nov 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathComponentProps.vue
77 lines (75 loc) · 1.68 KB
/
ComponentProps.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
<section class="configSection" v-if="radioProps.length || checkboxProps.length">
<m-layout-grid>
<m-layout-grid-inner>
<m-layout-grid-cell :span="12">
<m-typo-headline :level="5">Props</m-typo-headline>
</m-layout-grid-cell>
<m-layout-grid-cell :span="6">
<m-layout-grid-inner>
<m-layout-grid-cell
:span="12"
v-for="item of radioProps"
v-if="radioProps"
:key="item.prop">
<m-form-field>
<m-radio
v-model="radioPicked"
:value="item.prop"
:id="item.prop + '-' +_uid"
:checked="item.value"
:name="_uid.toString()"/>
<label :for="item.prop + '-' +_uid">{{ item.prop }}</label>
</m-form-field>
</m-layout-grid-cell>
</m-layout-grid-inner>
</m-layout-grid-cell>
<m-layout-grid-cell :span="6">
<m-layout-grid-inner>
<m-layout-grid-cell
:span="12"
v-for="item of checkboxProps"
v-if="checkboxProps"
:key="item.prop">
<m-form-field>
<m-checkbox
v-model="item.value"
:id="item.prop + '-' +_uid"
:disabled="item.disabled"/>
<label :for="item.prop + '-' +_uid">{{ item.prop }}</label>
</m-form-field>
</m-layout-grid-cell>
</m-layout-grid-inner>
</m-layout-grid-cell>
</m-layout-grid-inner>
</m-layout-grid>
</section>
</template>
<script>
export default {
props: {
radioProps: {
type: Array
},
checkboxProps: {
type: Array
}
},
data () {
return {
radioPicked: ''
}
},
watch: {
radioPicked () {
this.radioProps.map(n => n.prop === this.radioPicked ? n.value = true : n.value = false)
}
}
}
</script>
<style>
.configSection {
margin: 24px;
padding: 24px;
}
</style>