Selaa lähdekoodia

:recycle: adding form components for a better survey

tags/0.0.1
toj 4 vuotta sitten
vanhempi
commit
4bfed90894

+ 53
- 0
frontend/src/components/form/button-choice.vue Näytä tiedosto

@@ -0,0 +1,53 @@
1
+<template lang="pug">
2
+.form--step.button-choice
3
+    header
4
+        p selections {{selected}}
5
+    main(:class="{ 'f-row': opts.length > 2, 'f-col': opts.length <= 2 }")
6
+        button(v-for="op in opts" :class="isSelected(op)" @click="selectOption(op)") {{ op }}
7
+</template>
8
+
9
+<script setup>
10
+import { defineProps, defineEmits, ref } from 'vue'
11
+
12
+const emit = defineEmits(['selected'])
13
+
14
+const props = defineProps({
15
+    opts: {
16
+        required: true,
17
+        type: Array,
18
+        default: () => ['up', 'down'],
19
+        // default: () => ['up', 'left', 'right', 'down'],
20
+    },
21
+})
22
+
23
+const selected = ref([])
24
+
25
+const isSelected = val => {
26
+    return selected.value.includes(val) ? 'selected' : ''
27
+}
28
+
29
+const selectOption = optionVal => {
30
+    if (!selected.value.includes(optionVal)) {
31
+        selected.value.push(optionVal)
32
+    } else {
33
+        selected.value = selected.value.filter(val => val != optionVal)
34
+    }
35
+    emit('selected', selected.value)
36
+}
37
+</script>
38
+
39
+<style lang="postcss">
40
+// prettier-ignore
41
+@import '@/sss/theme.sss'
42
+
43
+.button-choice
44
+    color: white
45
+    main
46
+        flex-wrap: wrap
47
+        button
48
+            padding: 1em
49
+            border: 2px teal solid
50
+            border-radius: 4px
51
+            &.selected
52
+                border: 2px teal dotted
53
+</style>

+ 60
- 0
frontend/src/components/form/button-multi.vue Näytä tiedosto

@@ -0,0 +1,60 @@
1
+<template lang="pug">
2
+.form--step.button-multi
3
+    header.f-row
4
+        p {{selected.length}} | {{selected.length == opts.length}}
5
+        p
6
+            span(v-for="sel in selected") {{ sel }}&nbsp;
7
+
8
+    main.f-col(v-for="(op, i) in opts" :class="[{ 'selected': selected.length == i }, `step-${i}`, 'step']")
9
+        button(v-for="val in op" @click="selectOption(i, val)") {{ val }}
10
+    main(v-if="opts.length == selected.length").selected
11
+        button(@click="next") next
12
+</template>
13
+
14
+<script setup>
15
+import { defineProps, defineEmits, ref } from 'vue'
16
+
17
+const emit = defineEmits(['selected', 'next'])
18
+
19
+const props = defineProps({
20
+    opts: {
21
+        required: true,
22
+        type: Array,
23
+        default: () => [
24
+            ['up', 'down'],
25
+            ['left', 'right'],
26
+        ],
27
+    },
28
+})
29
+
30
+const selected = ref([])
31
+
32
+const selectOption = (step, optionVal) => {
33
+    selected.value[step] = optionVal
34
+    emit('selected', selected.value)
35
+}
36
+
37
+const next = () => {
38
+    emit('next', selected.value)
39
+    selected.value = []
40
+}
41
+</script>
42
+
43
+<style lang="postcss">
44
+// prettier-ignore
45
+@import '@/sss/theme.sss'
46
+
47
+.button-multi
48
+    color: white
49
+.step
50
+    flex-wrap: wrap
51
+    display: none
52
+    &.selected
53
+        display: block
54
+    button
55
+        padding: 1em
56
+        border: 2px teal solid
57
+        border-radius: 4px
58
+        &.selected
59
+            border: 2px teal dotted
60
+</style>

+ 50
- 0
frontend/src/components/form/input-string.vue Näytä tiedosto

@@ -0,0 +1,50 @@
1
+<template lang="pug">
2
+.form--step.input-string
3
+    header
4
+        p input {{input}}
5
+    main.f-col
6
+        input(v-if="!multiline" v-model="input")
7
+        textarea(v-else cols="50" rows="8" v-model="input")
8
+        button(@click="next").w-full next
9
+</template>
10
+
11
+<script setup>
12
+import { defineProps, defineEmits, ref } from 'vue'
13
+
14
+const emit = defineEmits(['next'])
15
+
16
+const props = defineProps({
17
+    default: {
18
+        required: true,
19
+        type: Array,
20
+        default: () => 'start',
21
+    },
22
+    multiline: {
23
+        required: false,
24
+        type: Boolean,
25
+        default: true,
26
+    },
27
+})
28
+
29
+const input = ref(props.default)
30
+
31
+const next = () => {
32
+    emit('next', input.value)
33
+}
34
+</script>
35
+
36
+<style lang="postcss">
37
+// prettier-ignore
38
+@import '@/sss/theme.sss'
39
+
40
+.input-string
41
+    color: white
42
+    main
43
+        flex-wrap: wrap
44
+        button
45
+            padding: 1em
46
+            border: 2px teal solid
47
+            border-radius: 4px
48
+            &.selected
49
+                border: 2px teal dotted
50
+</style>

+ 139
- 5
frontend/src/views/Survey.vue Näytä tiedosto

@@ -1,17 +1,129 @@
1 1
 <template lang="pug">
2 2
 main.f-col.start.w-full
3
-    article.match
4
-        h1 Survey Page
5
-        SurveyForm(v-if="validSurvey && validSurvey.steps" :form="validSurvey.steps" :pid="pid")
3
+    ButtonMulti
4
+    //- ButtonChoice
5
+    //- InputString
6
+    article.match.w-full
7
+        ul.w-full
8
+            li(v-if="step == 0")
9
+                header
10
+                    p step 1
11
+                section
12
+                    input(v-model="name")
13
+                footer
14
+                    button(@click="step++").w-full next
15
+            
16
+            li(v-if="step == 1")
17
+                header
18
+                    p step 1
19
+                section
20
+                    p 
21
+                        span(v-if="name") {{ name }}  
22
+                        span(v-else) ______________
23
+                        span .  
24
+                        span Let's get started on you profile while we verify your account.
25
+                footer.f-row
26
+                    button(@click="step--").w-full back
27
+                    button(@click="step++").w-full next
28
+            
29
+            li(v-if="step == 2")
30
+                header
31
+                    p step 2
32
+                section
33
+                    p
34
+                        span What are you looking for 
35
+                        span {{ name }}
36
+                        span ?
37
+                footer.f-col.w-full
38
+                    button(@click="saveNext('position')") a position
39
+                    button(@click="saveNext('cadidate')") a candidate
40
+            
41
+            li(v-if="step == 3")
42
+                header
43
+                    p step 3
44
+                section
45
+                    p
46
+                        span {{ seeking }} 
47
+                        span . 
48
+                        span You're in the right place. How would you like to use siimee?
49
+                section
50
+                    p
51
+                        span i am 
52
+                        select
53
+                            option actively searching
54
+                            option networking
55
+                            option exploring
56
+                footer.f-row
57
+                    button(@click="step--").w-full back
58
+                    button(@click="step++").w-full next
59
+            
60
+            li(v-if="step == 4")
61
+                header
62
+                    p step 4
63
+                section
64
+                    p
65
+                        span i am 
66
+                        span(v-if="role") a {{ role }}. 
67
+                        span(v-else) ______________. 
68
+                section
69
+                    p
70
+                        span(v-if="location") Looking for a {{ location }}, 
71
+                        span(v-else) Looking for a ______________, 
72
+                        span(v-if="experience") {{ experience }}&nbsp;
73
+                        span(v-else) ______________ 
74
+                        span(v-if="position") {{ position }}ing role. 
75
+                        span(v-else) ______________ role. 
76
+                
77
+                footer(v-if="!role").f-row
78
+                    button(@click="role = 'recruiter'") a recruiter
79
+                    button(@click="role = 'hiring_manager'") a hiring manager
80
+                footer.f-row(v-else-if="!location")
81
+                    button(@click="location = 'remote'") remote
82
+                    button(@click="location = 'in_person'") in person
83
+                footer.f-row(v-else-if="location == 'in_person' && zipcode.length > 5")
84
+                    input(v-model="zipcode")
85
+                footer.f-row(v-else-if="!experience")
86
+                    button(@click="experience = 'junior'") junior
87
+                    button(@click="experience = 'mid-level'") mid-level
88
+                    button(@click="experience = 'senior'") senior
89
+                    button(@click="experience = 'staff'") staff
90
+                footer.f-row(v-else-if="!position")
91
+                    button(@click="position = 'engineer'") engineering
92
+                footer.f-row(v-else)
93
+                    button(@click="step++").w-full next
94
+
95
+            li(v-if="step == 5")
96
+                header
97
+                    p step 5
98
+                section
99
+                    SurveyForm(v-if="validSurvey && validSurvey.steps" :form="validSurvey.steps" :pid="pid")
100
+                footer.f-row
101
+                    button(@click="step--").w-full back
102
+                    button(@click="step=0").w-full save
103
+        //- SurveyForm(v-if="validSurvey && validSurvey.steps" :form="validSurvey.steps" :pid="pid")
6 104
     MainNav(:pid="pid" @show-sidebar="$emit('show-sidebar')")
7 105
 </template>
8 106
 
9 107
 <script>
10 108
 import SurveyForm from '../components/form.vue'
11 109
 import { fetchSurveyByProfileId } from '../services'
110
+import ButtonMulti from '../components/form/button-multi.vue'
111
+import ButtonChoice from '../components/form/button-choice.vue'
112
+import InputString from '../components/form/input-string.vue'
113
+
114
+const locations = ['remote', 'in_person']
115
+const roles = [
116
+    ['recruiter', 'hiring_manager'],
117
+    [
118
+        'junior_engineer',
119
+        'mid-level_engineer',
120
+        'senior_engineer',
121
+        'staff_engineer',
122
+    ],
123
+]
12 124
 
13 125
 export default {
14
-    components: { SurveyForm },
126
+    components: { SurveyForm, ButtonMulti, ButtonChoice, InputString },
15 127
     props: {
16 128
         pid: {
17 129
             type: Number,
@@ -21,8 +133,23 @@ export default {
21 133
     data() {
22 134
         return {
23 135
             validSurvey: null,
136
+            step: 0,
137
+            name: '',
138
+            seeking: '',
139
+            role: '',
140
+            experience: '',
141
+            position: '',
142
+            location: '',
143
+            zipcode: '',
24 144
         }
25 145
     },
146
+    methods: {
147
+        saveNext(val) {
148
+            console.log(val)
149
+            this.seeking = val
150
+            this.step++
151
+        },
152
+    },
26 153
     async created() {
27 154
         this.validSurvey = await fetchSurveyByProfileId(this.pid)
28 155
         console.log('survey for:', this.validSurvey)
@@ -42,7 +169,14 @@ article
42 169
     height: 100%
43 170
     width: 100%
44 171
     flex-direction: column
45
-
172
+    ul
173
+        height: 100%
174
+        list-style: none
175
+        button
176
+            padding: 1em
177
+        p
178
+            padding: 1em
179
+            color: white
46 180
 .form
47 181
     border: 1px solid #fff
48 182
     width: 100%

Loading…
Peruuta
Tallenna