file: create client directory with files

This commit is contained in:
Leon Xu committed 2022-01-08 16:48:25 -08:00
1 parent 19b420d351
commit 353dbbd0a5
25 files changed
+21178

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
<template>
<div class="h-full w-full flex items-center justify-center">
<span
class="
block
w-[60px]
h-[60px]
border-[5px] border-solid border-transparent border-t-black
rounded-full
animate-spin
"
>
</span>
</div>
</template>
<script>
export default {
name: "loadingSpinner",
};
</script>
+37
View File
@@ -0,0 +1,37 @@
<template>
<div
class="
h-screen
absolute
w-full
z-10
flex
justify-center
items-start
pt-[125px]
bg-black/50
"
>
<div
class="flex flex-col bg-white w-[80%] sm:w-[450px] px-6 py-4 rounded-md"
>
<h1 class="text-lg mb-1">Error: {{ this.geoErrorMsg }}</h1>
<p class="text-sm mb-4">
To take advantage of this applications features, please ensure location
services are enabled
</p>
<button
@click="$emit('closeGeoError')"
class="self-start py-2 px-4 bg-red-500 text-white rounded-md text-sm"
>
Close
</button>
</div>
</div>
</template>
<script>
export default {
props: ["geoErrorMsg"],
};
</script>
+59
View File
@@ -0,0 +1,59 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
+154
View File
@@ -0,0 +1,154 @@
<template>
<div
class="
w-full
md:w-auto
absolute
md:top-[40px] md:left-[60px]
z-[2]
flex
gap-4
px-6
py-8
md:px-0 md:py-0
bg-transparent
"
>
<!-- Search -->
<div class="relative flex-1 md:min-w-[350px]">
<!-- Search Input -->
<input
class="
pl-9
pr-4
py-3
text-[14px]
focus:outline-none
w-full
shadow-md
rounded-md
"
type="text"
placeholder="Start your search..."
v-model="searchQuery"
@input="search"
@focus="$emit('toggleSearchResults')"
/>
<!-- Search Icon -->
<div class="absolute top-0 left-[8px] h-full flex items-center">
<i class="fas fa-search"></i>
</div>
<!-- Search Results -->
<div class="absolute mt-[8px] w-full">
<!-- Search Queries -->
<div
v-if="searchQuery && searchResults"
class="h-[200px] overflow-scroll bg-white rounded-md"
>
<!-- Loading Spinner -->
<BaseLoader v-if="!searchData" />
<!-- Display Results -->
<div v-else>
<div
class="
px-4
py-2
flex
gap-x-2
cursor-pointer
hover:bg-slate-600 hover:text-white
"
v-for="(result, index) in searchData"
:key="index"
@click="selectResult(result)"
>
<i class="fas fa-map-marker-alt"></i>
<p class="text-[12px]">{{ result.place_name_en }}</p>
</div>
</div>
</div>
<!-- Selected Search Result -->
<div
v-if="selectedResult"
class="mt-[8px] px-4 py-3 bg-white rounded-md"
>
<i
@click="removeResult"
class="flex justify-end far fa-times-circle"
></i>
<h1 class="text-lg">{{ selectedResult.text }}</h1>
<p class="text-xs mb-1">
{{ selectedResult.properties.address }}, {{ selectedResult.city }},
{{ selectedResult.state }}
</p>
<p class="text-xs">{{ selectedResult.properties.category }}</p>
</div>
</div>
</div>
<!-- Geolocation -->
<div
class="px-4 bg-white flex items-center shadow-md rounded-md min-h-[45px]"
@click="$emit('getGeolocation')"
:class="{ 'bg-slate-600': coords }"
>
<i
class="fas fa-location-arrow 'text-slate-600' text-[18px]"
:class="{ 'text-white': coords, 'animate-pulse': fetchCoords }"
></i>
</div>
</div>
</template>
<script>
import { ref } from "vue";
import axios from "axios";
import BaseLoader from "./BaseLoader.vue";
export default {
props: ["fetchCoords", "coords", "searchResults"],
components: { BaseLoader },
setup(props, { emit }) {
const searchQuery = ref(null);
const searchData = ref(null);
const queryTimeout = ref(null);
const selectedResult = ref(null);
const search = () => {
clearTimeout(queryTimeout.value);
// reset data on a new search
searchData.value = null;
queryTimeout.value = setTimeout(async () => {
// Only make search, if there is value in query input
if (searchQuery.value !== "") {
const params = new URLSearchParams({
fuzzyMatch: true,
language: "en",
limit: 10,
proximity: props.coords
? `${props.coords.lng},${props.coords.lat}`
: "0,0",
});
const data = await axios.get(
`api/search/${searchQuery.value}?${params}`
);
searchData.value = data.data.features;
}
}, 750);
};
const selectResult = (result) => {
selectedResult.value = result;
emit("plotResult", result.geometry);
};
const removeResult = () => {
selectedResult.value = null;
emit("removeResult");
};
return {
searchQuery,
search,
searchData,
selectResult,
selectedResult,
removeResult,
};
},
};
</script>