2019-11-30 04:55:32 +00:00
|
|
|
<template>
|
|
|
|
<div class="networks">
|
2020-02-15 00:10:32 +00:00
|
|
|
<form
|
2020-01-22 21:25:58 +00:00
|
|
|
class="search"
|
2020-02-15 00:10:32 +00:00
|
|
|
@submit.prevent="searchSites"
|
2020-01-22 21:25:58 +00:00
|
|
|
>
|
2020-02-15 00:10:32 +00:00
|
|
|
<input
|
|
|
|
v-model="query"
|
|
|
|
:placeholder="`Find ${siteCount} sites in ${networks.length} networks`"
|
|
|
|
class="query"
|
|
|
|
@input="searchSites"
|
|
|
|
>
|
2020-01-22 21:25:58 +00:00
|
|
|
|
2020-02-15 00:10:32 +00:00
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
class="search-button"
|
|
|
|
><Icon icon="search" /></button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-if="query.length"
|
|
|
|
class="network-tiles"
|
|
|
|
>
|
|
|
|
<Site
|
|
|
|
v-for="site in searchResults"
|
|
|
|
:key="`site-tile-${site.slug}`"
|
|
|
|
:site="site"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<span v-if="searchResults.length === 0">No results for "{{ query }}"</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-if="query.length === 0"
|
|
|
|
class="network-tiles"
|
|
|
|
>
|
2020-01-22 21:25:58 +00:00
|
|
|
<Network
|
|
|
|
v-for="network in networks"
|
|
|
|
:key="`network-tile-${network.slug}`"
|
|
|
|
:network="network"
|
|
|
|
/>
|
|
|
|
</div>
|
2019-11-30 04:55:32 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Network from '../tile/network.vue';
|
2020-02-15 00:10:32 +00:00
|
|
|
import Site from '../tile/site.vue';
|
|
|
|
|
|
|
|
async function searchSites() {
|
|
|
|
this.searchResults = await this.$store.dispatch('searchSites', {
|
|
|
|
query: this.query,
|
|
|
|
limit: 20,
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(this.searchResults);
|
|
|
|
}
|
2019-11-30 04:55:32 +00:00
|
|
|
|
|
|
|
async function mounted() {
|
|
|
|
this.networks = await this.$store.dispatch('fetchNetworks');
|
2020-01-30 23:12:58 +00:00
|
|
|
this.pageTitle = 'Networks';
|
2019-11-30 04:55:32 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 21:25:58 +00:00
|
|
|
function siteCount() {
|
|
|
|
return this.networks.map(network => network.sites).flat().length;
|
|
|
|
}
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Network,
|
2020-02-15 00:10:32 +00:00
|
|
|
Site,
|
2019-11-30 04:55:32 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-02-15 00:10:32 +00:00
|
|
|
query: '',
|
2020-01-30 23:12:58 +00:00
|
|
|
pageTitle: null,
|
2020-02-15 00:10:32 +00:00
|
|
|
networks: [],
|
|
|
|
searchResults: [],
|
2019-11-30 04:55:32 +00:00
|
|
|
};
|
|
|
|
},
|
2020-01-22 21:25:58 +00:00
|
|
|
computed: {
|
|
|
|
siteCount,
|
|
|
|
},
|
2019-11-30 04:55:32 +00:00
|
|
|
mounted,
|
2020-02-15 00:10:32 +00:00
|
|
|
methods: {
|
|
|
|
searchSites,
|
|
|
|
},
|
2019-11-30 04:55:32 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-01-06 04:19:38 +00:00
|
|
|
@import 'theme';
|
|
|
|
|
2020-01-31 01:01:30 +00:00
|
|
|
.networks {
|
|
|
|
padding: 0 1rem;
|
|
|
|
}
|
|
|
|
|
2020-01-22 21:25:58 +00:00
|
|
|
.search {
|
2020-02-15 00:10:32 +00:00
|
|
|
display: flex;
|
2020-01-31 01:01:30 +00:00
|
|
|
width: 100%;
|
|
|
|
max-width: 40rem;
|
2020-02-15 00:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.query {
|
|
|
|
flex-grow: 1;
|
2020-01-22 21:25:58 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 1rem;
|
|
|
|
border: none;
|
2020-01-31 01:01:30 +00:00
|
|
|
box-sizing: border-box;
|
2020-01-22 21:25:58 +00:00
|
|
|
box-shadow: 0 0 3px $shadow-weak;
|
2020-01-31 01:01:30 +00:00
|
|
|
margin: 1rem 0;
|
2020-01-22 21:25:58 +00:00
|
|
|
font-size: 1rem;
|
|
|
|
outline: none;
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
box-shadow: 0 0 3px $primary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 00:10:32 +00:00
|
|
|
.search-button {
|
|
|
|
padding: 1rem;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: $shadow;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
fill: $primary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-22 21:25:58 +00:00
|
|
|
.network-tiles {
|
2019-11-30 04:55:32 +00:00
|
|
|
display: grid;
|
2019-12-04 20:58:08 +00:00
|
|
|
grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
|
2019-11-30 04:55:32 +00:00
|
|
|
grid-gap: 1rem;
|
2020-01-31 01:01:30 +00:00
|
|
|
padding: 1rem 0;
|
2019-11-30 04:55:32 +00:00
|
|
|
}
|
2020-01-06 04:19:38 +00:00
|
|
|
|
|
|
|
@media(max-width: $breakpoint) {
|
|
|
|
.networks {
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
|
|
|
}
|
|
|
|
}
|
2019-11-30 04:55:32 +00:00
|
|
|
</style>
|