Added results button to compact filters.

This commit is contained in:
DebaucheryLibrarian 2024-01-07 02:35:24 +01:00
parent b835d8eddf
commit ffcb77ab45
5 changed files with 149 additions and 67 deletions

View File

@ -10,6 +10,7 @@
v-if="actor.avatar" v-if="actor.avatar"
:src="actor.avatar.isS3 ? `https://cdndev.traxxx.me/${actor.avatar.thumbnail}` : `/media/${actor.avatar.thumbnail}`" :src="actor.avatar.isS3 ? `https://cdndev.traxxx.me/${actor.avatar.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:style="{ 'background-image': actor.avatar.isS3 ? `url(https://cdndev.traxxx.me/${actor.avatar.lazy})` : `url(/media/${actor.avatar.lazy})` }" :style="{ 'background-image': actor.avatar.isS3 ? `url(https://cdndev.traxxx.me/${actor.avatar.lazy})` : `url(/media/${actor.avatar.lazy})` }"
loading="lazy"
class="avatar" class="avatar"
> >
</Link> </Link>

View File

@ -3,9 +3,9 @@
<RangeFilter <RangeFilter
label="bra size" label="bra size"
:min="0" :min="0"
:max="braSizes.length - 1" :max="cups.length - 1"
:value="filters.braSize" :value="filters.braSize"
:values="braSizes" :values="cups"
:disabled="!filters.braSizeRequired" :disabled="!filters.braSizeRequired"
@enable="(checked) => emit('update', 'braSizeRequired', checked, true)" @enable="(checked) => emit('update', 'braSizeRequired', checked, true)"
@input="(range) => emit('update', 'braSize', range, false)" @input="(range) => emit('update', 'braSize', range, false)"
@ -44,17 +44,31 @@
</template> </template>
<script setup> <script setup>
import { computed } from 'vue';
import RangeFilter from '#/components/filters/range.vue'; import RangeFilter from '#/components/filters/range.vue';
defineProps({ const props = defineProps({
filters: { filters: {
type: Object, type: Object,
default: null, default: null,
}, },
// cup range should probably not be used, because it becomes impossible to filter for larger values than the current results
cupRange: {
type: Array,
default: null,
},
}); });
function cupRangeToCups(cupA, cupB) {
const smallestCode = cupA.charCodeAt(0);
const biggestCode = cupB.charCodeAt(0);
return Array.from({ length: biggestCode - smallestCode + 1 }, (value, index) => String.fromCharCode(smallestCode + index));
}
const emit = defineEmits(['update']); const emit = defineEmits(['update']);
const braSizes = 'ABCDEFGHIJKZ'.split('');
const naturalBoobsValues = [true, undefined, false]; const naturalBoobsValues = [true, undefined, false];
const cups = computed(() => (props.cupRange ? cupRangeToCups(props.cupRange[0], props.cupRange[1]) : 'ABCDEFGHIJKZ'.split(''))); // add Z to allow for 'bigger than K' without wasting fidelity
</script> </script>

View File

@ -1,38 +1,93 @@
<template> <template>
<div class="filters-frame">
<div <div
v-show="showFilters"
class="filters-container" class="filters-container"
:class="{ 'compact-hide': !showFilters }" :class="{ show: showFiltersCompact }"
@click="toggleFilters(false)" @click="toggleFilters(false)"
> >
<div class="filters-sidebar">
<form <form
v-show="showFilters"
class="filters" class="filters"
@submit.prevent @submit.prevent
@click.stop @click.stop
> >
<slot /> <slot />
</form> </form>
<button
v-if="typeof results === 'number'"
class="button results"
>Show {{ results }} {{ results > 1 ? 'results' : 'result' }}</button>
</div>
<div
class="filters-toggle close"
:class="{ 'show-full': showFilters, 'show-compact': showFiltersCompact }"
@click.stop="toggleFilters(false)"
>
<Icon
icon="arrow-left3"
class="arrow"
/>
<Icon
icon="cross2"
class="cross"
/>
</div>
</div>
<div
class="filters-toggle open"
:class="{ 'show-full': !showFilters, 'show-compact': !showFiltersCompact }"
@click.stop="toggleFilters(true)"
><Icon icon="filter" /></div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
defineProps({
results: {
type: Number,
default: null,
},
});
// desktop defaults to open, compact defaults to closed
// we can't measure viewframe in SSR, so use separate toggles
const showFilters = ref(true); const showFilters = ref(true);
const showFiltersCompact = ref(false);
function toggleFilters(state) { function toggleFilters(state) {
showFilters.value = state ?? !showFilters.value; showFilters.value = state ?? !showFilters.value;
showFiltersCompact.value = state ?? !showFiltersCompact.value;
} }
</script> </script>
<style scoped> <style scoped>
.filters-container { .filters-frame {
position: relative; position: relative;
} }
.filters-container {
display: flex;
height: 100%;
}
.filters-sidebar {
height: 100%;
display: flex;
flex-direction: column;
}
.filters { .filters {
width: 17rem; width: 17rem;
flex-shrink: 0; flex-grow: 1;
position: relative;
box-sizing: border-box;
padding: .5rem 0; padding: .5rem 0;
background: var(--background); background: var(--background);
box-shadow: 0 0 3px var(--shadow-weak-30); box-shadow: 0 0 3px var(--shadow-weak-30);
@ -45,22 +100,30 @@ function toggleFilters(state) {
.filters-toggle { .filters-toggle {
min-width: 1.5rem; min-width: 1.5rem;
height: 2rem; height: 2rem;
display: flex; display: none;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 0 .25rem; padding: 0 .25rem;
border-radius: 0 .25rem .25rem 0; position: absolute;
top: .5rem;
right: -2rem;
border-radius: 0 .5rem .5rem 0;
background: var(--background); background: var(--background);
color: var(--shadow); color: var(--shadow);
font-weight: bold; font-weight: bold;
box-shadow: inset 0 0 3px var(--shadow-weak-30); box-shadow: inset 0 0 3px var(--shadow-weak-30);
&.show { &.open {
padding: 0 .5rem 0 1.25rem; left: 0;
right: auto;
.icon {
margin-left: .5rem;
} }
&.show-full {
display: flex;
}
&.close .cross {
display: none;
} }
.icon { .icon {
@ -76,8 +139,17 @@ function toggleFilters(state) {
} }
} }
.results {
display: none;
justify-content: center;
background: var(--primary);
color: var(--text-light);
border-radius: 0;
}
@media (max-width: 1200px) { @media (max-width: 1200px) {
.filters-container { .filters-container {
display: none;
height: 100%; height: 100%;
width: 100%; width: 100%;
position: fixed; position: fixed;
@ -85,15 +157,46 @@ function toggleFilters(state) {
left: 0; left: 0;
z-index: 1000; z-index: 1000;
background: var(--background-dim); background: var(--background-dim);
&.show {
display: flex;
}
} }
.filters { .filters {
height: 100%;
overflow-y: auto; overflow-y: auto;
} }
.filters-toggle {
&.show-full {
display: none;
}
&.show-compact {
display: flex;
&.close {
background: var(--grey-light-40);
position: relative;
right: 0;
}
}
&.close .cross {
display: flex;
}
&.close .arrow {
display: none;
}
}
.compact-hide { .compact-hide {
display: none; display: none;
} }
.results {
display: flex;
}
} }
</style> </style>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="page"> <div class="page">
<Filters> <Filters :results="total">
<div class="filter"> <div class="filter">
<input <input
v-model="q" v-model="q"
@ -23,6 +23,7 @@
<BoobsFilter <BoobsFilter
:filters="filters" :filters="filters"
:cup-range="cupRange"
@update="updateFilter" @update="updateFilter"
/> />
@ -48,29 +49,6 @@
<div class="actors-container"> <div class="actors-container">
<div class="actors-header"> <div class="actors-header">
<!--
<div
v-show="showFilters"
class="filters-toggle hide"
@click.stop="toggleFilters(hide)"
>
<Icon
icon="arrow-left3"
/>
</div>
<div
v-show="!showFilters"
class="filters-toggle show"
@click.stop="toggleFilters(true)"
>
Filters
<Icon
icon="arrow-right3"
/>
</div>
-->
<div class="meta"> <div class="meta">
<span class="count">{{ total }} results</span> <span class="count">{{ total }} results</span>
@ -131,14 +109,7 @@ const { pageProps, urlParsed, routeParams } = pageContext;
const q = ref(urlParsed.search.q); const q = ref(urlParsed.search.q);
const actors = ref([]); const actors = ref([]);
const countries = ref(pageProps.countries); const countries = ref(pageProps.countries);
const cupRange = ref(pageProps.cupRange);
const showFilters = ref(false);
if (pageContext.isHydration) { // hide sidebar on mobile, we can only run this client-side
if (window.matchMedia('(max-width: 1200px)')?.matches) {
showFilters.value = false;
}
}
actors.value = pageProps.actors; actors.value = pageProps.actors;
@ -204,20 +175,12 @@ function paginate({ page }) {
} }
function updateFilter(prop, value, reload = true) { function updateFilter(prop, value, reload = true) {
console.log('update!', prop, value);
filters.value[prop] = value; filters.value[prop] = value;
if (reload) { if (reload) {
search(); search();
} }
} }
/*
function toggleFilters(state) {
showFilters.value = state ?? !showFilters.value;
}
*/
</script> </script>
<style> <style>
@ -258,7 +221,7 @@ function toggleFilters(state) {
.actors-header { .actors-header {
display: flex; display: flex;
align-items: center; align-items: center;
padding: .5rem 0 .75rem 0; padding: .5rem 0 .25rem 2rem;
} }
.meta { .meta {
@ -266,7 +229,6 @@ function toggleFilters(state) {
flex-grow: 1; flex-grow: 1;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 0 1rem;
} }
.actors-container { .actors-container {

View File

@ -5,6 +5,7 @@ export async function onBeforeRender(pageContext) {
const { const {
actors, actors,
countries, countries,
cupRange,
limit, limit,
total, total,
} = await fetchActors(curateActorsQuery(pageContext.urlQuery), { } = await fetchActors(curateActorsQuery(pageContext.urlQuery), {
@ -19,6 +20,7 @@ export async function onBeforeRender(pageContext) {
pageProps: { pageProps: {
actors, actors,
countries, countries,
cupRange,
limit, limit,
total, total,
}, },