24
24
<input
25
25
class =" first-name form-field"
26
26
type =" text"
27
- :placeholder =" firstName .placeholder"
27
+ :placeholder =" firstNameField .placeholder"
28
28
required =" true" />
29
29
<input
30
30
class =" last-name form-field"
31
31
type =" text"
32
- :placeholder =" lastName .placeholder"
32
+ :placeholder =" lastNameField .placeholder"
33
33
required =" true" />
34
34
</div >
35
35
36
36
<input
37
37
class =" email form-field"
38
38
type =" email"
39
- :placeholder =" email .placeholder"
39
+ :placeholder =" emailField .placeholder"
40
40
required =" true" />
41
41
42
42
<input
43
43
class =" org form-field"
44
- :placeholder =" org .placeholder"
44
+ :placeholder =" orgField .placeholder"
45
45
type =" text"
46
46
required =" true" />
47
47
48
48
<ZeroDropdown class =" country form-field" :display-selected =" true" >
49
- <template #toggle-button =" { togglePanel } " >
49
+ <template #toggle-button =" { togglePanel , selected } " >
50
50
<div class =" toggle-button" @click =" togglePanel" >
51
- <p class =" toggle-button-label" >
52
- Country
51
+ <p v-if =" selected" class =" toggle-button-label" >
52
+ {{ selected.label }}
53
+ </p >
54
+ <p v-else class =" toggle-button-label" >
55
+ Select an option
53
56
</p >
54
57
</div >
55
58
</template >
56
- <template #dropdown-panel >
59
+ <template #dropdown-panel = " { setSelected , closePanel } " >
57
60
<div class =" dropdown-panel" >
58
61
<div
59
- v-for =" option in country .options"
62
+ v-for =" option in countryField .options"
60
63
:key =" option.code"
61
- class =" country-option" >
62
- <p class =" country-label" v-html =" option.label" />
64
+ class =" options" >
65
+ <p
66
+ class =" option-label"
67
+ @click =" selectOption(setSelected, closePanel, option, 'country')"
68
+ v-html =" option.label" />
63
69
</div >
64
70
</div >
65
71
</template >
66
72
</ZeroDropdown >
67
73
68
74
<ZeroDropdown class =" familiarity" :display-selected =" true" >
69
- <template #toggle-button =" { togglePanel } " >
70
- <h3 class =" dropdown-label" v-html =" familiarity .label" />
75
+ <template #toggle-button =" { togglePanel , selected } " >
76
+ <h3 class =" dropdown-label" v-html =" familiarityField .label" />
71
77
<div class =" toggle-button form-field" @click =" togglePanel" >
72
- <p class =" toggle-button-label" >
78
+ <p v-if =" selected" class =" toggle-button-label" >
79
+ {{ selected }}
80
+ </p >
81
+ <p v-else class =" toggle-button-label" >
73
82
Select an option
74
83
</p >
75
84
</div >
76
85
</template >
77
- <template #dropdown-panel >
86
+ <template #dropdown-panel = " { setSelected , closePanel } " >
78
87
<div class =" dropdown-panel" >
79
88
<div
80
- v-for =" (option, index) in familiarity .options"
89
+ v-for =" (option, index) in familiarityField .options"
81
90
:key =" index"
82
- class =" country-option" >
83
- <p class =" country-label" v-html =" option" />
91
+ class =" options" >
92
+ <p
93
+ class =" option-label"
94
+ @click =" selectOption(setSelected, closePanel, option, 'familiarity')"
95
+ v-html =" option" />
84
96
</div >
85
97
</div >
86
98
</template >
@@ -102,6 +114,15 @@ const props = defineProps({
102
114
}
103
115
})
104
116
117
+ // ======================================================================== Data
118
+ const firstName = ref (false )
119
+ const lastName = ref (false )
120
+ const email = ref (false )
121
+ const org = ref (false )
122
+ const country = ref (false )
123
+ const filecoinFamiliarity = ref (false )
124
+
125
+
105
126
// ==================================================================== Computed
106
127
const title = computed (() => { return props .signupCard .title })
107
128
@@ -114,19 +135,36 @@ const cardStyles = computed(() => {
114
135
return null
115
136
})
116
137
117
- const firstName = computed (() => { return props .signupCard .signup_form .first_name })
138
+ const firstNameField = computed (() => { return props .signupCard .signup_form .first_name })
118
139
119
- const lastName = computed (() => { return props .signupCard .signup_form .last_name })
140
+ const lastNameField = computed (() => { return props .signupCard .signup_form .last_name })
120
141
121
- const email = computed (() => { return props .signupCard .signup_form .email })
142
+ const emailField = computed (() => { return props .signupCard .signup_form .email })
122
143
123
- const org = computed (() => { return props .signupCard .signup_form .org })
144
+ const orgField = computed (() => { return props .signupCard .signup_form .org })
124
145
125
- const country = computed (() => { return props .signupCard .signup_form .country })
126
-
127
- const familiarity = computed (() => { return props .signupCard .signup_form .filecoin_familiarity })
146
+ const countryField = computed (() => { return props .signupCard .signup_form .country })
128
147
148
+ const familiarityField = computed (() => { return props .signupCard .signup_form .filecoin_familiarity })
129
149
150
+ // ===================================================================== Methdos
151
+ /**
152
+ * @method selectOption
153
+ */
154
+ const selectOption = (setSelected , closePanel , option , field ) => {
155
+ if (option) {
156
+ setSelected (option)
157
+ closePanel ()
158
+ switch (field) {
159
+ case ' country' :
160
+ country .value = option
161
+ break
162
+ case ' familiarity' :
163
+ filecoinFamiliarity .value = option
164
+ break
165
+ }
166
+ }
167
+ }
130
168
</script >
131
169
132
170
<style lang="scss" scoped>
@@ -165,4 +203,8 @@ const familiarity = computed(() => { return props.signupCard.signup_form.filecoi
165
203
}
166
204
}
167
205
206
+ .option-label {
207
+ cursor : pointer ;
208
+ }
209
+
168
210
</style >
0 commit comments