Skip to content

Commit 5611d59

Browse files
committed
Fix stack form styling / tab
1 parent 504c6fc commit 5611d59

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

components/Search/index.vue

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="search" :class="{
44
'is-open': openSuggestion,
55
'has-selected': hasSelected,
6-
'has-province': hasSelected && provinces.length && provinces[0].province
6+
'has-province': isProvinceFocus
77
}">
88
<div class="search-container">
99
<div class="countries-wrapper" :class="{ 'is-focused': focusedInput }">
@@ -23,8 +23,9 @@
2323
<div class="provinces-wrapper" :class="{ 'is-focused': focusedSelect }">
2424
<select
2525
ref="provinces"
26-
:tabindex="focusedSelect ? '0' : '-1'"
27-
@focus="focusedSelect = true"
26+
v-model="locationId"
27+
:tabindex="locationId ? '-1' : '0'"
28+
@focus="onSelectFocus"
2829
@blur="focusedSelect = false"
2930
@change="onChange">
3031
<option
@@ -42,10 +43,10 @@
4243
<button
4344
ref="search"
4445
:class="{
45-
'is-disabled': !hasSelected,
46+
'is-disabled': !hasSelected || !locationId,
4647
'is-focused': focusedButton
4748
}"
48-
:disabled="!hasSelected"
49+
:disabled="!hasSelected || !locationId"
4950
@focus="focusedButton = true"
5051
@blur="focusedButton = false"
5152
@click="onSearch">
@@ -61,8 +62,7 @@
6162
v-for="(suggestion, index) in matches"
6263
:key="index"
6364
v-bind:class="{ 'is-active': isActive(index) }"
64-
@click="suggestionClick(index)"
65-
>
65+
@click="suggestionClick(index)">
6666
<span>{{ suggestion }}</span>
6767
</li>
6868
</ul>
@@ -105,7 +105,7 @@ export default {
105105
)
106106
},
107107
isProvinceFocus() {
108-
return this.$refs.provinces && this.hasSelected && this.provinces.length && this.provinces[0].province
108+
return this.hasSelected && this.provinces.length && this.provinces[0].province
109109
}
110110
},
111111
data() {
@@ -133,12 +133,17 @@ export default {
133133
this.tempValue = this.country
134134
this.open = false
135135
this.hasSelected = true
136+
this.$nextTick(_ => {
137+
if (this.isProvinceFocus) {
138+
this.$refs.provinces.focus()
139+
this.locationId = ""
140+
""}
141+
})
136142
this.$gtag('event', 'enter', {
137143
event_category: 'input',
138144
event_label: 'input enter',
139145
value: this.country
140146
})
141-
if (this.isProvinceFocus) this.$refs.provinces.focus()
142147
}
143148
},
144149
up() {
@@ -173,14 +178,18 @@ export default {
173178
this.tempValue = this.country
174179
this.open = false
175180
this.hasSelected = true
176-
if (this.isProvinceFocus) this.$refs.provinces.focus()
181+
if (this.isProvinceFocus) {
182+
this.locationId = ""
183+
this.$refs.provinces.focus()
184+
}
177185
this.$gtag('event', 'click', {
178186
event_category: 'select',
179187
event_label: 'select click',
180188
value: this.country
181189
})
182190
},
183191
onSearch() {
192+
if (this.locationId) {
184193
this.$store
185194
.dispatch('getOverviewByCountry', this.locationId)
186195
.then(_ => {
@@ -191,8 +200,10 @@ export default {
191200
value: this.locationId
192201
})
193202
})
203+
}
194204
},
195205
onSelectFocus(e) {
206+
this.focusedSelect = true
196207
if (e.target.value) {
197208
this.locationId = e.target.value
198209
this.$gtag('event', 'focus', {
@@ -244,49 +255,46 @@ export default {
244255
&.has-province {
245256
246257
.dropdown-menu {
247-
transform: translateY(calc(-100% - 104px));
258+
transform: translateY(calc(-100% - 100px));
248259
}
249260
}
250261
251262
.dropdown-menu {
252-
transform: translateY(calc(-100% - 54px));
263+
transform: translateY(calc(-100% - 48px));
253264
}
254265
}
255266
256-
.countries-wrapper {
257-
border-radius: 0 0 4px 4px;
258-
}
259-
260267
.dropdown-menu {
261268
display: block;
262269
}
263270
}
264271
265272
&.has-selected {
266-
267-
button {
268-
border-radius: 0 0 4px 4px;
269-
}
270273
271274
.countries-wrapper {
272-
border-radius: 4px 4px 0 0;
275+
border-radius: 4px 4px 0 0;
273276
transform: translateY(calc(100% + 2px));
274277
}
275278
276279
.provinces-wrapper {
277-
border-radius: 4px 4px 0 0;
278280
box-shadow: none;
279-
transform: translateY(3px);
281+
transform: translateY(2px);
282+
}
283+
284+
button {
285+
border-radius: 0 0 4px 4px;
280286
}
281287
}
282288
283289
&.has-province {
284290
285291
.countries-wrapper {
292+
border-radius: 4px 4px 0 0;
286293
transform: translateY(2px);
287294
}
288295
289296
.provinces-wrapper {
297+
border-radius: 4px 4px 0 0;
290298
box-shadow: 0px 6px 2px -1px rgba(0, 0, 0, 0.2);
291299
transform: translateY(0);
292300
}
@@ -317,6 +325,7 @@ export default {
317325
transition: 0.6s cubic-bezier(0.83, 0, 0.17, 1);
318326
}
319327
328+
&:hover,
320329
&.is-focused {
321330
background-color: #1919ff;
322331
@@ -329,6 +338,15 @@ export default {
329338
opacity: 0.2;
330339
box-shadow: none;
331340
cursor: not-allowed;
341+
342+
&:hover,
343+
&.is-focused {
344+
background-color: #3232ff;
345+
346+
svg {
347+
transform: scale(1);
348+
}
349+
}
332350
}
333351
}
334352
@@ -362,15 +380,11 @@ export default {
362380
363381
.countries-wrapper {
364382
box-shadow: 0px 6px 2px -1px rgba(0, 0, 0, 0.2);
365-
transform: translateY(calc(200% + 2px));
366-
367-
@media only screen and (min-width: 768px) {
368-
transform: translateY(calc(200% + 3px));
369-
}
383+
transform: translateY(calc(200%));
370384
}
371385
372386
.provinces-wrapper {
373-
transform: translateY(calc(100% - 1px));
387+
transform: translateY(calc(100%));
374388
z-index: 8;
375389
}
376390

0 commit comments

Comments
 (0)