Skip to content

Commit f9d8b59

Browse files
committed
Added loader
1 parent 5611d59 commit f9d8b59

File tree

1 file changed

+71
-16
lines changed

1 file changed

+71
-16
lines changed

components/Search/index.vue

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@
5050
@focus="focusedButton = true"
5151
@blur="focusedButton = false"
5252
@click="onSearch">
53-
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
54-
width="30" height="30"
55-
viewBox="0 0 172 172"
56-
style=" fill:#000000;"><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g fill="#ffffff"><path d="M74.53333,17.2c-31.59642,0 -57.33333,25.73692 -57.33333,57.33333c0,31.59642 25.73692,57.33333 57.33333,57.33333c13.73998,0 26.35834,-4.87915 36.24766,-12.97839l34.23203,34.23203c1.43802,1.49778 3.5734,2.10113 5.5826,1.57735c2.0092,-0.52378 3.57826,-2.09284 4.10204,-4.10204c0.52378,-2.0092 -0.07957,-4.14458 -1.57735,-5.5826l-34.23203,-34.23203c8.09924,-9.88932 12.97839,-22.50768 12.97839,-36.24766c0,-31.59642 -25.73692,-57.33333 -57.33333,-57.33333zM74.53333,28.66667c25.39937,0 45.86667,20.4673 45.86667,45.86667c0,25.39937 -20.46729,45.86667 -45.86667,45.86667c-25.39937,0 -45.86667,-20.46729 -45.86667,-45.86667c0,-25.39937 20.4673,-45.86667 45.86667,-45.86667z"></path></g></g>
57-
</svg>
53+
<template v-if="isLoading">
54+
<div class="loader" />
55+
</template>
56+
<template v-else>
57+
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
58+
width="30" height="30"
59+
viewBox="0 0 172 172"
60+
style=" fill:#000000;"><g fill="none" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><g fill="#ffffff"><path d="M74.53333,17.2c-31.59642,0 -57.33333,25.73692 -57.33333,57.33333c0,31.59642 25.73692,57.33333 57.33333,57.33333c13.73998,0 26.35834,-4.87915 36.24766,-12.97839l34.23203,34.23203c1.43802,1.49778 3.5734,2.10113 5.5826,1.57735c2.0092,-0.52378 3.57826,-2.09284 4.10204,-4.10204c0.52378,-2.0092 -0.07957,-4.14458 -1.57735,-5.5826l-34.23203,-34.23203c8.09924,-9.88932 12.97839,-22.50768 12.97839,-36.24766c0,-31.59642 -25.73692,-57.33333 -57.33333,-57.33333zM74.53333,28.66667c25.39937,0 45.86667,20.4673 45.86667,45.86667c0,25.39937 -20.46729,45.86667 -45.86667,45.86667c-25.39937,0 -45.86667,-20.46729 -45.86667,-45.86667c0,-25.39937 20.4673,-45.86667 45.86667,-45.86667z"></path></g></g>
61+
</svg>
62+
</template>
5863
</button>
5964
</div>
6065
<ul ref="dropdown" class="dropdown-menu">
@@ -120,7 +125,8 @@ export default {
120125
hasSelected: false,
121126
focusedInput: false,
122127
focusedSelect: false,
123-
focusedButton: false
128+
focusedButton: false,
129+
isLoading: false
124130
}
125131
},
126132
methods: {
@@ -137,7 +143,7 @@ export default {
137143
if (this.isProvinceFocus) {
138144
this.$refs.provinces.focus()
139145
this.locationId = ""
140-
""}
146+
}
141147
})
142148
this.$gtag('event', 'enter', {
143149
event_category: 'input',
@@ -190,16 +196,18 @@ export default {
190196
},
191197
onSearch() {
192198
if (this.locationId) {
193-
this.$store
194-
.dispatch('getOverviewByCountry', this.locationId)
195-
.then(_ => {
196-
this.$emit('search')
197-
this.$gtag('event', 'click', {
198-
event_category: 'search',
199-
event_label: 'search click',
200-
value: this.locationId
199+
this.isLoading = true
200+
this.$store
201+
.dispatch('getOverviewByCountry', this.locationId)
202+
.then(_ => {
203+
this.$emit('search')
204+
this.$gtag('event', 'click', {
205+
event_category: 'search',
206+
event_label: 'search click',
207+
value: this.locationId
208+
})
209+
this.isLoading = false
201210
})
202-
})
203211
}
204212
},
205213
onSelectFocus(e) {
@@ -410,5 +418,52 @@ export default {
410418
}
411419
}
412420
}
421+
422+
.loader {
423+
position: relative;
424+
border-radius: 50%;
425+
margin: 0;
426+
width: 24px;
427+
height: 24px;
428+
font-size: 10px;
429+
background: #ffffff;
430+
background: linear-gradient(to right, #ffffff 10%, rgba(255, 255, 255, 0) 42%);
431+
animation: loader 1.4s infinite linear;
432+
transform: translateZ(0);
433+
434+
&:before {
435+
content: '';
436+
position: absolute;
437+
top: 0;
438+
left: 0;
439+
border-radius: 100% 0 0 0;
440+
width: 50%;
441+
height: 50%;
442+
background: #ffffff;
443+
}
444+
445+
&:after {
446+
content: '';
447+
position: absolute;
448+
top: 0;
449+
left: 0;
450+
bottom: 0;
451+
right: 0;
452+
border-radius: 50%;
453+
margin: auto;
454+
width: 75%;
455+
height: 75%;
456+
background: #3232ff;
457+
}
458+
}
459+
}
460+
461+
@keyframes loader {
462+
0% {
463+
transform: rotate(0deg);
464+
}
465+
100% {
466+
transform: rotate(360deg);
467+
}
413468
}
414469
</style>

0 commit comments

Comments
 (0)