2019-04-08 20:06:22 +00:00
|
|
|
<template>
|
2019-09-14 21:19:10 +00:00
|
|
|
<form @submit.prevent="formSubmit" :class="formClasses" class="flex text-teal-100 text-lg w-full">
|
2019-08-21 21:22:16 +00:00
|
|
|
<div v-if="dropdown" @click="dropdown = false" class="fixed z-20 inset-0"></div>
|
2019-04-10 20:05:52 +00:00
|
|
|
<div class="relative w-full">
|
2019-04-16 13:34:38 +00:00
|
|
|
<input
|
2019-08-23 14:48:16 +00:00
|
|
|
v-model="summoner"
|
2019-04-16 13:34:38 +00:00
|
|
|
type="text"
|
2019-11-16 16:50:14 +00:00
|
|
|
:class="[inputClasses]"
|
2019-11-17 15:10:27 +00:00
|
|
|
class="w-full rounded-lg outline-none pl-6 pr-32 font-bold focus:bg-blue-1000"
|
2019-09-03 17:56:41 +00:00
|
|
|
/>
|
2019-11-16 16:50:14 +00:00
|
|
|
<div class="absolute right-0 z-30 vertical-center flex items-center h-full mr-12">
|
2019-04-16 13:34:38 +00:00
|
|
|
<div
|
2019-04-08 20:06:22 +00:00
|
|
|
@click="dropdown = !dropdown"
|
2019-11-17 15:10:27 +00:00
|
|
|
:class="{'border-teal-200': dropdown}"
|
|
|
|
|
class="border-2 border-transparent cursor-pointer flex items-center px-2 py-1 rounded transition-all transition-fast ease-in-quad ease-out-quad hover:text-white"
|
2019-04-08 20:06:22 +00:00
|
|
|
>
|
2019-08-21 23:09:17 +00:00
|
|
|
<span class="selected font-bold select-none">{{ selectedRegion }}</span>
|
2019-12-21 16:56:31 +00:00
|
|
|
<svg class="ml-1 -mr-1 w-4 h-4">
|
|
|
|
|
<use xlink:href="#caret-down" />
|
2019-10-21 14:02:45 +00:00
|
|
|
</svg>
|
2019-04-08 20:06:22 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-04-16 12:28:42 +00:00
|
|
|
<transition
|
|
|
|
|
enter-active-class="transition-all transition-fastest ease-out-quad"
|
|
|
|
|
leave-active-class="transition-all transition-faster ease-in-quad"
|
2019-11-16 16:50:14 +00:00
|
|
|
enter-class="opacity-0 scale-90"
|
2019-04-16 12:28:42 +00:00
|
|
|
enter-to-class="opacity-100 scale-100"
|
|
|
|
|
leave-class="opacity-100 scale-100"
|
2019-11-16 16:50:14 +00:00
|
|
|
leave-to-class="opacity-0 scale-90"
|
2019-04-16 12:28:42 +00:00
|
|
|
>
|
2019-04-10 20:05:52 +00:00
|
|
|
<div
|
2019-11-17 15:10:27 +00:00
|
|
|
v-show="dropdown"
|
2019-11-16 16:50:14 +00:00
|
|
|
:class="[dropdownClasses]"
|
|
|
|
|
class="absolute right-0 z-30 text-white rounded-b shadow cursor-pointer"
|
2019-04-08 20:06:22 +00:00
|
|
|
>
|
2019-04-16 13:34:38 +00:00
|
|
|
<div
|
|
|
|
|
v-for="(region, index) in regions"
|
2019-04-10 20:05:52 +00:00
|
|
|
:key="region"
|
|
|
|
|
@click="selectedRegion = region"
|
|
|
|
|
:class="classRegions(index)"
|
2019-11-17 15:10:27 +00:00
|
|
|
class="relative pr-2 pl-5 py-1 text-xs text-right bg-blue-1000 hover:bg-blue-800"
|
2019-05-16 13:10:00 +00:00
|
|
|
>
|
2019-10-21 14:02:45 +00:00
|
|
|
<svg
|
2019-05-16 13:10:00 +00:00
|
|
|
v-if="region === selectedRegion"
|
2019-10-21 14:02:45 +00:00
|
|
|
class="absolute vertical-center offsetIcon w-3 h-3 fill-current"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 512 512"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
2019-05-16 13:10:00 +00:00
|
|
|
{{ region }}
|
|
|
|
|
</div>
|
2019-04-08 20:06:22 +00:00
|
|
|
</div>
|
2019-04-10 20:05:52 +00:00
|
|
|
</transition>
|
2019-11-16 16:50:14 +00:00
|
|
|
<button
|
|
|
|
|
:class="[btnClasses]"
|
2019-11-17 15:10:27 +00:00
|
|
|
class="absolute right-0 z-30 h-full hover:text-teal-200"
|
2019-11-16 16:50:14 +00:00
|
|
|
type="submit"
|
2019-10-21 14:02:45 +00:00
|
|
|
>
|
2019-11-16 16:50:14 +00:00
|
|
|
<svg
|
2019-11-17 15:10:27 +00:00
|
|
|
class="absolute vertical-center horizontal-center w-4 h-4 fill-current"
|
2019-11-16 16:50:14 +00:00
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
viewBox="0 0 512 512"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
|
|
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2019-04-08 20:06:22 +00:00
|
|
|
</form>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
2019-09-14 21:19:10 +00:00
|
|
|
props: {
|
|
|
|
|
size: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'xl'
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-04-08 20:06:22 +00:00
|
|
|
data() {
|
|
|
|
|
return {
|
2019-04-18 12:33:49 +00:00
|
|
|
summoner: '',
|
2019-04-08 20:06:22 +00:00
|
|
|
dropdown: false,
|
2019-04-16 13:34:38 +00:00
|
|
|
regions: [
|
2019-04-18 12:33:49 +00:00
|
|
|
'BR',
|
|
|
|
|
'EUNE',
|
|
|
|
|
'EUW',
|
|
|
|
|
'JP',
|
|
|
|
|
'KR',
|
|
|
|
|
'LAN',
|
|
|
|
|
'LAS',
|
|
|
|
|
'NA',
|
|
|
|
|
'OCE',
|
|
|
|
|
'TR',
|
|
|
|
|
'RU'
|
2019-04-16 13:34:38 +00:00
|
|
|
],
|
2019-04-18 12:33:49 +00:00
|
|
|
selectedRegion: 'EUW'
|
2019-08-23 14:48:16 +00:00
|
|
|
}
|
2019-04-08 20:06:22 +00:00
|
|
|
},
|
2019-09-14 21:19:10 +00:00
|
|
|
computed: {
|
|
|
|
|
btnClasses() {
|
|
|
|
|
return {
|
2019-11-16 16:50:14 +00:00
|
|
|
'w-8 mr-3': this.size === 'small',
|
|
|
|
|
'w-12': this.size === 'xl'
|
2019-09-14 21:19:10 +00:00
|
|
|
}
|
|
|
|
|
},
|
2019-11-16 16:50:14 +00:00
|
|
|
formClasses() {
|
2019-09-14 21:19:10 +00:00
|
|
|
return {
|
2019-11-16 16:50:14 +00:00
|
|
|
'max-w-md': this.size === 'small',
|
2019-09-14 21:19:10 +00:00
|
|
|
}
|
|
|
|
|
},
|
2019-11-16 16:50:14 +00:00
|
|
|
inputClasses() {
|
2019-09-14 21:19:10 +00:00
|
|
|
return {
|
2019-11-16 16:50:14 +00:00
|
|
|
'py-2 px-1': this.size === 'small',
|
2019-11-17 15:10:27 +00:00
|
|
|
'py-4 px-2': this.size === 'xl',
|
|
|
|
|
'input-color': !this.dropdown,
|
|
|
|
|
'bg-blue-1000': this.dropdown
|
2019-09-14 21:19:10 +00:00
|
|
|
}
|
|
|
|
|
},
|
2019-11-16 16:50:14 +00:00
|
|
|
dropdownClasses() {
|
2019-09-14 21:19:10 +00:00
|
|
|
return {
|
2019-11-16 16:50:14 +00:00
|
|
|
'offsetDropDown': this.size === 'small',
|
|
|
|
|
'offsetDropDownXl': this.size === 'xl'
|
2019-09-14 21:19:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-04-08 20:06:22 +00:00
|
|
|
methods: {
|
|
|
|
|
classRegions(index) {
|
|
|
|
|
return {
|
2019-04-18 12:33:49 +00:00
|
|
|
'rounded-b': index === this.regions.length - 1
|
2019-08-23 14:48:16 +00:00
|
|
|
}
|
2019-04-08 20:06:22 +00:00
|
|
|
},
|
|
|
|
|
formSubmit() {
|
2019-09-03 17:56:41 +00:00
|
|
|
const search = this.summoner.split(' ').join('')
|
|
|
|
|
if (search.length) {
|
|
|
|
|
this.$emit('formSubmit', search, this.selectedRegion.toLowerCase())
|
2019-08-22 22:50:00 +00:00
|
|
|
}
|
2019-04-08 20:06:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-08-23 14:48:16 +00:00
|
|
|
}
|
2019-04-08 20:06:22 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2019-04-16 13:34:38 +00:00
|
|
|
.offsetDropDown {
|
2019-11-16 16:50:14 +00:00
|
|
|
top: 43px;
|
|
|
|
|
right: 48px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.offsetDropDownXl {
|
|
|
|
|
top: 58px;
|
|
|
|
|
right: 50px;
|
2019-04-16 13:34:38 +00:00
|
|
|
}
|
2019-05-16 13:10:00 +00:00
|
|
|
|
|
|
|
|
.offsetIcon {
|
|
|
|
|
left: 4px;
|
|
|
|
|
}
|
2019-04-08 20:06:22 +00:00
|
|
|
</style>
|