2019-11-30 04:55:32 +00:00
|
|
|
<template>
|
2020-05-21 01:44:44 +00:00
|
|
|
<div class="networks">
|
|
|
|
<form
|
|
|
|
class="search"
|
2020-06-27 00:57:30 +00:00
|
|
|
@submit.prevent="searchEntities"
|
2020-05-21 01:44:44 +00:00
|
|
|
>
|
|
|
|
<input
|
|
|
|
v-model="query"
|
2020-06-28 01:58:16 +00:00
|
|
|
:placeholder="`Find ${channelCount} channels in ${entities.length} networks`"
|
2020-05-21 01:44:44 +00:00
|
|
|
class="query"
|
2020-06-27 00:57:30 +00:00
|
|
|
@input="searchEntities"
|
2020-05-21 01:44:44 +00:00
|
|
|
>
|
2020-01-22 21:25:58 +00:00
|
|
|
|
2020-05-21 01:44:44 +00:00
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
class="search-button"
|
|
|
|
><Icon icon="search" /></button>
|
|
|
|
</form>
|
2020-02-15 00:10:32 +00:00
|
|
|
|
2020-05-21 01:44:44 +00:00
|
|
|
<div
|
|
|
|
v-if="query.length"
|
2020-06-27 00:57:30 +00:00
|
|
|
class="entity-tiles"
|
2020-05-21 01:44:44 +00:00
|
|
|
>
|
2020-06-27 00:57:30 +00:00
|
|
|
<Entity
|
|
|
|
v-for="entity in searchResults"
|
|
|
|
:key="`${entity.type}-tile-${entity.slug}`"
|
|
|
|
:entity="entity"
|
2020-05-21 01:44:44 +00:00
|
|
|
/>
|
2020-02-15 00:10:32 +00:00
|
|
|
|
2020-05-21 01:44:44 +00:00
|
|
|
<span v-if="searchResults.length === 0">No results for "{{ query }}"</span>
|
|
|
|
</div>
|
2020-02-15 00:10:32 +00:00
|
|
|
|
2020-05-21 01:44:44 +00:00
|
|
|
<div
|
|
|
|
v-if="query.length === 0"
|
2020-06-27 00:57:30 +00:00
|
|
|
class="entity-tiles"
|
2020-05-21 01:44:44 +00:00
|
|
|
>
|
2020-06-27 00:57:30 +00:00
|
|
|
<Entity
|
2020-06-28 01:58:16 +00:00
|
|
|
v-for="entity in entities"
|
|
|
|
:key="`entity-tile-${entity.slug}`"
|
|
|
|
:entity="entity"
|
2020-05-21 01:44:44 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-11-30 04:55:32 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-06-27 22:15:13 +00:00
|
|
|
import Entity from '../entities/tile.vue';
|
2020-02-15 00:10:32 +00:00
|
|
|
|
2020-06-27 00:57:30 +00:00
|
|
|
async function searchEntities() {
|
|
|
|
this.searchResults = await this.$store.dispatch('searchEntities', {
|
2020-05-21 01:44:44 +00:00
|
|
|
query: this.query,
|
2020-06-27 00:57:30 +00:00
|
|
|
limit: 50,
|
2020-05-21 01:44:44 +00:00
|
|
|
});
|
2020-02-15 00:10:32 +00:00
|
|
|
}
|
2019-11-30 04:55:32 +00:00
|
|
|
|
|
|
|
async function mounted() {
|
2020-06-28 01:58:16 +00:00
|
|
|
this.entities = await this.$store.dispatch('fetchEntities', {
|
2020-06-27 22:15:13 +00:00
|
|
|
type: 'network',
|
2020-07-02 02:04:28 +00:00
|
|
|
entitySlugs: [],
|
2020-06-27 22:15:13 +00:00
|
|
|
});
|
2020-06-28 01:58:16 +00:00
|
|
|
|
2020-05-21 01:44:44 +00:00
|
|
|
this.pageTitle = 'Networks';
|
2019-11-30 04:55:32 +00:00
|
|
|
}
|
|
|
|
|
2020-06-28 01:58:16 +00:00
|
|
|
function channelCount() {
|
|
|
|
return this.entities.reduce((acc, entity) => acc + entity.childrenTotal, 0);
|
2020-01-22 21:25:58 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
export default {
|
2020-05-21 01:44:44 +00:00
|
|
|
components: {
|
2020-06-27 00:57:30 +00:00
|
|
|
Entity,
|
2020-05-21 01:44:44 +00:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
query: '',
|
|
|
|
pageTitle: null,
|
2020-06-28 01:58:16 +00:00
|
|
|
entities: [],
|
2020-05-21 01:44:44 +00:00
|
|
|
searchResults: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2020-06-28 01:58:16 +00:00
|
|
|
channelCount,
|
2020-05-21 01:44:44 +00:00
|
|
|
},
|
|
|
|
mounted,
|
|
|
|
methods: {
|
2020-06-27 00:57:30 +00:00
|
|
|
searchEntities,
|
2020-05-21 01:44:44 +00:00
|
|
|
},
|
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 {
|
2020-03-23 00:43:49 +00:00
|
|
|
color: var(--text);
|
|
|
|
background: var(--background);
|
2020-02-15 00:10:32 +00:00
|
|
|
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-03-25 02:42:46 +00:00
|
|
|
box-shadow: 0 0 3px var(--darken-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 {
|
2020-03-23 00:43:49 +00:00
|
|
|
box-shadow: 0 0 3px var(--primary);
|
2020-01-22 21:25:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 00:10:32 +00:00
|
|
|
.search-button {
|
|
|
|
padding: 1rem;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
|
|
|
|
.icon {
|
2020-03-23 00:43:49 +00:00
|
|
|
fill: var(--shadow);
|
2020-02-15 00:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.icon {
|
2020-03-23 00:43:49 +00:00
|
|
|
fill: var(--primary);
|
2020-02-15 00:10:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-27 00:57:30 +00:00
|
|
|
.entity-tiles {
|
2019-11-30 04:55:32 +00:00
|
|
|
display: grid;
|
2020-07-02 02:04:28 +00:00
|
|
|
grid-template-columns: repeat(auto-fill, 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
|
|
|
|
2020-07-02 23:28:22 +00:00
|
|
|
@media(max-width: $breakpoint0) {
|
|
|
|
.entity-tiles {
|
2020-01-06 04:19:38 +00:00
|
|
|
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
|
|
|
}
|
|
|
|
}
|
2019-11-30 04:55:32 +00:00
|
|
|
</style>
|