Replaced alphabet index with search bar on actors page.

This commit is contained in:
DebaucheryLibrarian 2021-08-22 01:26:09 +02:00
parent b24973eb19
commit 0c19a026ef
7 changed files with 328 additions and 264 deletions

View File

@ -1,9 +1,13 @@
<template> <template>
<div class="actors"> <div
<nav ref="content"
ref="filter" class="actors"
class="filter"
> >
<nav
ref="filters"
class="filters"
>
<div class="filters-row">
<ul class="genders nolist"> <ul class="genders nolist">
<li class="gender"> <li class="gender">
<router-link <router-link
@ -45,23 +49,6 @@
</li> </li>
</ul> </ul>
<ul class="letters nolist">
<li
v-for="letterX in letters"
:key="letterX"
class="letter"
>
<router-link
:to="{ name: 'actors', params: { gender, letter: letterX, pageNumber: 1 } }"
:class="{ selected: letterX === letter }"
class="letter-link"
replace
>{{ letterX || 'All' }}</router-link>
</li>
</ul>
</nav>
<nav class="filter">
<ul class="nolist"> <ul class="nolist">
<li> <li>
<Tooltip class="filter boobs"> <Tooltip class="filter boobs">
@ -208,6 +195,9 @@
</Tooltip> </Tooltip>
</li> </li>
</ul> </ul>
</div>
<SearchBar :placeholder="`Search ${totalCount} actors`" />
</nav> </nav>
<div class="tiles"> <div class="tiles">
@ -236,10 +226,11 @@ import Actor from './tile.vue';
import Gender from './gender.vue'; import Gender from './gender.vue';
import Checkbox from '../form/checkbox.vue'; import Checkbox from '../form/checkbox.vue';
import RangeFilter from './filter-range.vue'; import RangeFilter from './filter-range.vue';
import SearchBar from '../search/bar.vue';
import Pagination from '../pagination/pagination.vue'; import Pagination from '../pagination/pagination.vue';
const toggleValues = [true, null, false]; const toggleValues = [true, null, false];
const boobSizes = 'ABCDEFGHZ'.split(''); const boobSizes = 'ABCDEFGHIJKZ'.split('');
function updateFilters() { function updateFilters() {
this.$router.push({ this.$router.push({
@ -269,6 +260,11 @@ function updateValue(prop, value, load = true) {
} }
async function fetchActors(scroll) { async function fetchActors(scroll) {
if (this.$route.query.query) {
await this.searchActors();
return;
}
const curatedGender = this.gender.replace('trans', 'transsexual'); const curatedGender = this.gender.replace('trans', 'transsexual');
const { actors, totalCount } = await this.$store.dispatch('fetchActors', { const { actors, totalCount } = await this.$store.dispatch('fetchActors', {
@ -288,7 +284,23 @@ async function fetchActors(scroll) {
this.totalCount = totalCount; this.totalCount = totalCount;
if (scroll) { if (scroll) {
this.$refs.filter?.scrollIntoView(); this.$refs.content.scrollTop = 0;
// this.$refs.filter?.scrollIntoView();
}
}
async function searchActors(scroll) {
const actors = await this.$store.dispatch('searchActors', {
query: this.$route.query.query,
limit: this.limit,
});
this.actors = actors;
this.totalCount = actors.length;
if (scroll) {
this.$refs.content.scrollTop = 0;
// this.$refs.filter?.scrollIntoView();
} }
} }
@ -320,6 +332,7 @@ export default {
Checkbox, Checkbox,
Gender, Gender,
RangeFilter, RangeFilter,
SearchBar,
Pagination, Pagination,
}, },
data() { data() {
@ -328,7 +341,6 @@ export default {
pageTitle: null, pageTitle: null,
totalCount: 0, totalCount: 0,
limit: 50, limit: 50,
letters: ['all'].concat(Array.from({ length: 26 }, (value, index) => String.fromCharCode(index + 97).toUpperCase())),
age: this.$route.query.age?.split(',') || [18, 100], age: this.$route.query.age?.split(',') || [18, 100],
ageRequired: !!this.$route.query.age, ageRequired: !!this.$route.query.age,
dob: this.$route.query.dob || dayjs().subtract(21, 'years').format('YYYY-MM-DD'), dob: this.$route.query.dob || dayjs().subtract(21, 'years').format('YYYY-MM-DD'),
@ -353,6 +365,7 @@ export default {
mounted, mounted,
methods: { methods: {
fetchActors, fetchActors,
searchActors,
updateFilters, updateFilters,
updateValue, updateValue,
}, },
@ -403,24 +416,34 @@ export default {
flex-grow: 1; flex-grow: 1;
} }
.filter { .search {
width: 0;
flex-grow: 1;
justify-content: flex-end;
box-sizing: border-box;
padding: 0 1rem;
}
.filters,
.filters-row {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 0 1rem;
margin: 0 0 1rem 0;
&:first-child {
margin: 1rem 0;
} }
.filters {
margin: 1rem 0 .5rem 0;
}
.filters-row,
.filter {
padding: 0 1rem;
} }
.genders { .genders {
display: flex; display: flex;
flex-shrink: 0; flex-shrink: 0;
padding: 0 .5rem 0 0; padding: 0 .5rem 0 0;
border-right: solid 1px var(--shadow-hint);
margin: 0 1rem 0 0;
} }
.letter, .letter,
@ -661,10 +684,27 @@ export default {
} }
} }
@media(max-width: $breakpoint-kilo) {
.filters {
flex-direction: column-reverse;
}
::v-deep(.search) {
width: 100%;
justify-content: center;
margin: 0 0 1rem 0;
}
}
@media(max-width: $breakpoint) { @media(max-width: $breakpoint) {
.genders { .filters-row {
flex-direction: column; flex-direction: column;
} }
.genders {
padding: 0;
margin: 0 0 1.5rem 0;
}
} }
@media(max-width: $breakpoint-micro) { @media(max-width: $breakpoint-micro) {
@ -672,4 +712,10 @@ export default {
grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
} }
} }
@media(max-width: $breakpoint-mini) {
.filter .icon {
display: none;
}
}
</style> </style>

View File

@ -1,34 +1,12 @@
<template> <template>
<div class="networks"> <div class="networks">
<form <div class="content-inner">
class="search" <SearchBar :placeholder="`Search ${channelCount} channels in ${entities.length} networks`" />
@submit.prevent="searchEntities"
>
<input
v-model="query"
:placeholder="`Search ${channelCount} channels in ${entities.length} networks`"
class="query"
@input="searchEntities"
>
<button <span
type="submit" v-if="done && entities.length === 0"
class="search-button" class="empty"
><Icon icon="search" /></button> >No results for "{{ $route.query.query }}"</span>
</form>
<div
v-if="query.length > 0"
class="entity-tiles"
>
<Entity
v-for="entity in searchResults"
:key="`${entity.type}-tile-${entity.slug}`"
:entity="entity"
/>
<span v-if="searchResults.length === 0">No results for "{{ query }}"</span>
</div>
<div <div
v-else v-else
@ -40,6 +18,7 @@
:entity="entity" :entity="entity"
/> />
</div> </div>
</div>
<Footer /> <Footer />
</div> </div>
@ -47,21 +26,39 @@
<script> <script>
import Entity from '../entities/tile.vue'; import Entity from '../entities/tile.vue';
import SearchBar from '../search/bar.vue';
async function searchEntities() { async function fetchEntities() {
this.searchResults = await this.$store.dispatch('searchEntities', { if (this.$route.query.query) {
query: this.query, await this.searchEntities();
limit: 50, return;
});
} }
async function mounted() { this.done = false;
this.entities = await this.$store.dispatch('fetchEntities', { this.entities = await this.$store.dispatch('fetchEntities', {
type: 'network', type: 'network',
entitySlugs: [], entitySlugs: [],
}); });
this.pageTitle = 'Networks'; this.done = true;
}
async function searchEntities() {
this.done = false;
this.entities = await this.$store.dispatch('searchEntities', {
query: this.$route.query.query,
limit: 20,
});
this.done = true;
}
async function mounted() {
this.pageTitle = 'Channels';
await this.fetchEntities();
} }
function channelCount() { function channelCount() {
@ -71,20 +68,24 @@ function channelCount() {
export default { export default {
components: { components: {
Entity, Entity,
SearchBar,
}, },
data() { data() {
return { return {
query: '', done: false,
pageTitle: null, pageTitle: null,
entities: [], entities: [],
searchResults: [],
}; };
}, },
computed: { computed: {
channelCount, channelCount,
}, },
watch: {
$route: fetchEntities,
},
mounted, mounted,
methods: { methods: {
fetchEntities,
searchEntities, searchEntities,
}, },
}; };
@ -94,6 +95,12 @@ export default {
@import 'theme'; @import 'theme';
.networks { .networks {
display: flex;
flex-direction: column;
flex-grow: 1;
}
.content-inner {
padding: 0 1rem; padding: 0 1rem;
} }
@ -112,6 +119,14 @@ export default {
} }
} }
.empty {
display: block;
margin: 1rem 0;
color: var(--shadow);
font-size: 1.25rem;
font-weight: bold;
}
@media(max-width: $breakpoint2) { @media(max-width: $breakpoint2) {
.entity-tiles { .entity-tiles {
grid-gap: .5rem; grid-gap: .5rem;

View File

@ -1,10 +1,7 @@
<template> <template>
<div class="movies"> <div class="movies">
<div class="content-inner"> <div class="content-inner">
<Search <SearchBar :placeholder="`Search ${totalCount} movies`" />
:search="searchMovies"
:placeholder="`Search ${totalCount} movies`"
/>
<div class="tiles"> <div class="tiles">
<MovieTile <MovieTile
@ -28,7 +25,7 @@
<script> <script>
import MovieTile from './movie-tile.vue'; import MovieTile from './movie-tile.vue';
import Search from '../search/bar.vue'; import SearchBar from '../search/bar.vue';
import Pagination from '../pagination/pagination.vue'; import Pagination from '../pagination/pagination.vue';
async function fetchMovies() { async function fetchMovies() {
@ -66,7 +63,7 @@ async function mounted() {
export default { export default {
components: { components: {
MovieTile, MovieTile,
Search, SearchBar,
Pagination, Pagination,
}, },
data() { data() {

View File

@ -44,10 +44,11 @@ export default {
.search { .search {
display: flex; display: flex;
width: 100%; width: 100%;
max-width: 40rem;
} }
.query { .query {
max-width: 40rem;
min-width: 10rem;
color: var(--text); color: var(--text);
background: var(--background); background: var(--background);
flex-grow: 1; flex-grow: 1;

View File

@ -1,5 +1,6 @@
$breakpoint-pico: 270px; $breakpoint-pico: 270px;
$breakpoint-nano: 320px; $breakpoint-nano: 320px;
$breakpoint-mini: 400px;
$breakpoint-micro: 540px; $breakpoint-micro: 540px;
$breakpoint-small: 620px; $breakpoint-small: 620px;
$breakpoint: 720px; $breakpoint: 720px;

View File

@ -1,5 +1,10 @@
import { graphql } from '../api'; import { graphql } from '../api';
import { releasesFragment, releaseFragment, releaseFields, movieFields } from '../fragments'; import {
releasesFragment,
releaseFragment,
releaseFields,
movieFields,
} from '../fragments';
import { curateRelease } from '../curate'; import { curateRelease } from '../curate';
import getDateRange from '../get-date-range'; import getDateRange from '../get-date-range';

View File

@ -176,7 +176,6 @@ const routes = [
params: { params: {
...from.params, ...from.params,
gender: 'all', gender: 'all',
letter: 'all',
tags: 'all', tags: 'all',
range: 'latest', range: 'latest',
pageNumber: 1, pageNumber: 1,
@ -184,7 +183,7 @@ const routes = [
}), }),
}, },
{ {
path: '/actors/:gender?/:letter?/:pageNumber', path: '/actors/:gender?/:pageNumber',
component: Actors, component: Actors,
name: 'actors', name: 'actors',
}, },