Added scene view toggle.

This commit is contained in:
DebaucheryLibrarian 2024-09-05 01:44:48 +02:00
parent 6458264abf
commit 77c6136a05
3 changed files with 158 additions and 74 deletions

View File

@ -1,6 +1,7 @@
<template>
<div
class="scenes-page"
:class="{ [view]: true }"
>
<transition name="sidebar">
<Filters
@ -66,53 +67,89 @@
:campaign="campaigns.meta"
/>
<select
v-model="scope"
class="input"
@change="search({ autoScope: false })"
>
<!-- not selected in SSR without prop -->
<option
v-if="pageStash"
:selected="scope === 'stashed'"
value="stashed"
>Added</option>
<div class="views">
<div class="view-toggles noselect">
<Icon
v-show="view === 'grid'"
icon="menu3"
class="view-toggle"
@click="setView('list')"
/>
<option
v-if="filters.search"
:selected="scope === 'results'"
value="results"
>Relevance</option>
<Icon
v-show="view === 'list'"
icon="grid6"
class="view-toggle"
@click="setView('grid')"
/>
</div>
<option value="latest">Latest</option>
<option value="upcoming">Upcoming</option>
<option value="new">New</option>
<option value="likes">Popular</option>
</select>
<select
v-model="scope"
class="input"
@change="search({ autoScope: false })"
>
<!-- not selected in SSR without prop -->
<option
v-if="pageStash"
:selected="scope === 'stashed'"
value="stashed"
>Added</option>
<option
v-if="filters.search"
:selected="scope === 'results'"
value="results"
>Relevance</option>
<option value="latest">Latest</option>
<option value="upcoming">Upcoming</option>
<option value="new">New</option>
<option value="likes">Popular</option>
</select>
</div>
</div>
<nav
v-if="showScopeTabs"
class="scopes"
>
<div class="scopes-pills">
<Link
:href="getPath('latest')"
class="scope nolink"
:active="scope === 'latest'"
>Latest</Link>
<div class="views">
<div class="scopes-pills">
<Link
:href="getPath('latest')"
class="scope nolink"
:active="scope === 'latest'"
>Latest</Link>
<Link
:href="getPath('upcoming')"
class="scope nolink"
:active="scope === 'upcoming'"
>Upcoming</Link>
<Link
:href="getPath('upcoming')"
class="scope nolink"
:active="scope === 'upcoming'"
>Upcoming</Link>
<Link
:href="getPath('new')"
class="scope nolink"
:active="scope === 'new'"
>New</Link>
<Link
:href="getPath('new')"
class="scope nolink"
:active="scope === 'new'"
>New</Link>
</div>
<div class="view-toggles noselect">
<Icon
v-show="view === 'grid'"
icon="menu3"
class="view-toggle"
@click="setView('list')"
/>
<Icon
v-show="view === 'list'"
icon="grid6"
class="view-toggle"
@click="setView('grid')"
/>
</div>
</div>
<Campaign
@ -135,7 +172,10 @@
v-else
:key="`scene-${item.id}`"
>
<SceneTile :scene="item" />
<SceneTile
:scene="item"
:class="{ [view]: true }"
/>
</li>
</template>
</ul>
@ -161,6 +201,7 @@ import {
inject,
} from 'vue';
import Cookies from 'js-cookie';
import { parse } from 'path-to-regexp';
import navigate from '#/src/navigate.js';
@ -203,6 +244,7 @@ const {
routeParams,
urlParsed,
campaigns,
env,
} = inject('pageContext');
const {
@ -224,6 +266,8 @@ const total = ref(Number(pageProps.sceneTotal || pageProps.total));
const loading = ref(false);
const scenesContainer = ref(null);
const view = ref(env.scenesView || 'grid');
const actorIds = urlParsed.search.actors?.split(',').map((identifier) => parseActorIdentifier(identifier)?.id).filter(Boolean) || [];
const queryActors = actorIds.map((urlActorId) => aggActors.value.find((aggActor) => aggActor.id === urlActorId)).filter(Boolean);
@ -330,6 +374,11 @@ function updateFilter(prop, value, reload = true) {
search();
}
}
function setView(newView) {
view.value = newView;
Cookies.set('scenesView', newView);
}
</script>
<style scoped>
@ -402,6 +451,27 @@ function updateFilter(prop, value, reload = true) {
}
}
.views {
display: flex;
align-items: center;
justify-content: flex-end;
}
.view-toggles {
display: none;
margin-left: .5rem;
}
.view-toggle {
padding: .5rem 1rem;
fill: var(--glass);
&:hover {
cursor: pointer;
fill: var(--primary);
}
}
.scopes-pills {
display: flex;
align-items: center;
@ -460,18 +530,29 @@ function updateFilter(prop, value, reload = true) {
width: 100%;
justify-content: center;
}
.scopes .views {
width: 100%;
}
}
@media(--small-20) {
/*
.scenes {
grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
.list {
.scenes {
grid-template-columns: 1fr;
}
}
*/
.scenes {
grid-template-columns: 1fr;
padding: .5rem .5rem 1rem .5rem;
}
.view-toggles {
display: flex;
}
.scopes-pills {
justify-content: flex-start;
}
}
</style>

View File

@ -273,45 +273,47 @@ const favorited = ref(props.scene.stashes.some((sceneStash) => sceneStash.id ===
}
@media(--small-20) {
.tile-full {
flex-direction: row;
}
.tile.list {
.tile-full {
flex-direction: row;
}
.poster-container {
width: 10rem;
flex-shrink: 0;
}
.poster-container {
width: 10rem;
flex-shrink: 0;
}
.poster {
border-radius: .25rem 0 0 0;
}
.poster {
border-radius: .25rem 0 0 0;
}
.bookmarks.tiled {
right: auto;
left: 0;
}
.bookmarks.tiled {
right: auto;
left: 0;
}
.meta-full {
display: none;
}
.meta-full {
display: none;
}
.meta-compact {
display: flex;
}
.meta-compact {
display: flex;
}
.info {
width: 0;
flex-grow: 1;
justify-content: center;
}
.info {
width: 0;
flex-grow: 1;
justify-content: center;
}
.row {
margin: 0 .5rem .5rem .5rem;
}
.row {
margin: 0 .5rem .5rem .5rem;
}
.title {
margin-top: .6rem;
margin-bottom: .6rem;
.title {
margin-top: .6rem;
margin-bottom: .6rem;
}
}
}
</style>

View File

@ -32,6 +32,7 @@ export default async function mainHandler(req, res, next) {
} : null,
env: {
theme: req.cookies.theme || req.headers['sec-ch-prefers-color-scheme'] || 'light',
scenesView: req.cookies.scenesView || 'list',
selectedTemplate: Number(req.cookies.selectedTemplate) || 0,
allowLogin: config.auth.login,
allowSignup: config.auth.signup,