350 lines
6.6 KiB
Vue
350 lines
6.6 KiB
Vue
<template>
|
|
<div
|
|
class="movie-tile"
|
|
:class="{ unstashed: !favorited && pageStash && user && pageStash.id === user.primaryStash?.id }"
|
|
>
|
|
<div
|
|
class="cover-container"
|
|
:title="movie.title"
|
|
>
|
|
<a
|
|
:href="`/movie/${movie.id}/${movie.slug}`"
|
|
class="cover-link"
|
|
>
|
|
<img
|
|
v-if="movie.covers[0]"
|
|
:src="movie.covers[0].isS3 ? `https://cdndev.traxxx.me/${movie.covers[0].thumbnail}` : `/media/${movie.covers[0].thumbnail}`"
|
|
:style="{ 'background-image': movie.covers[0].isS3 ? `url(https://cdndev.traxxx.me/${movie.covers[0].lazy})` : `url(/media/${movie.covers[0].lazy})` }"
|
|
class="thumbnail"
|
|
loading="lazy"
|
|
>
|
|
|
|
<img
|
|
v-else
|
|
src="/public/img/icons/movie.svg"
|
|
class="nocover"
|
|
>
|
|
</a>
|
|
|
|
<Icon
|
|
v-show="favorited"
|
|
icon="heart7"
|
|
class="heart favorited"
|
|
@click.native.stop="unstash"
|
|
/>
|
|
|
|
<Icon
|
|
v-show="!favorited && user"
|
|
icon="heart8"
|
|
class="heart"
|
|
@click.native.stop="stash"
|
|
/>
|
|
</div>
|
|
|
|
<div class="tile-info">
|
|
<div class="tile-meta">
|
|
<div class="channel">
|
|
<Link
|
|
:href="movie.channel.isIndependent || !movie.network ? `/${movie.channel.type}/${movie.channel.slug}` : `/${movie.network.type}/${movie.network.slug}`"
|
|
class="favicon-link"
|
|
>
|
|
<img
|
|
:src="movie.channel.isIndependent || !movie.network ? `/logos/${movie.channel.slug}/favicon.png` : `/logos/${movie.network.slug}/favicon.png`"
|
|
class="favicon"
|
|
>
|
|
</Link>
|
|
|
|
<Link
|
|
:href="`/${movie.channel.type}/${movie.channel.slug}`"
|
|
class="nolink channel-link"
|
|
>{{ movie.channel.name }}</Link>
|
|
</div>
|
|
|
|
<time
|
|
:datetime="movie.effectiveDate.toISOString()"
|
|
class="date"
|
|
:class="{ nodate: !movie.date }"
|
|
>{{ format(movie.effectiveDate, movie.effectiveDate.getFullYear() === currentYear ? 'MMM d' : 'MMM d, y') }}</time>
|
|
</div>
|
|
|
|
<a
|
|
:href="`/movie/${movie.id}/${movie.slug}`"
|
|
:title="movie.title"
|
|
class="title nolink"
|
|
>{{ movie.title }}</a>
|
|
|
|
<ul
|
|
:title="movie.actors.map((actor) => actor.name).join(', ')"
|
|
class="actors nolist"
|
|
>
|
|
<li
|
|
v-for="actor in movie.actors"
|
|
:key="`actor-${movie.id}-${actor.slug}`"
|
|
class="actor-item"
|
|
>
|
|
<a
|
|
:href="`/actor/${actor.id}/${actor.slug}`"
|
|
class="actor nolink"
|
|
>{{ actor.name }}</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<ul
|
|
:title="movie.tags.map((tag) => tag.name).join(', ')"
|
|
class="tags nolist"
|
|
>
|
|
<li
|
|
v-for="tag in movie.tags"
|
|
:key="`tag-${movie.id}-${tag.slug}`"
|
|
>
|
|
<a
|
|
:href="`/tag/${tag.slug}`"
|
|
class="tag nolink"
|
|
>{{ tag.name }}</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, inject } from 'vue';
|
|
import { format } from 'date-fns';
|
|
|
|
import { post, del } from '#/src/api.js';
|
|
import events from '#/src/events.js';
|
|
import ellipsis from '#/utils/ellipsis.js';
|
|
|
|
const props = defineProps({
|
|
movie: {
|
|
type: Object,
|
|
default: null,
|
|
},
|
|
});
|
|
|
|
const pageContext = inject('pageContext');
|
|
const user = pageContext.user;
|
|
const pageStash = pageContext.pageProps.stash;
|
|
|
|
const currentYear = new Date().getFullYear();
|
|
const fbCutoff = 20;
|
|
|
|
const favorited = ref(props.movie.stashes.some((sceneStash) => sceneStash.primary));
|
|
|
|
async function stash() {
|
|
try {
|
|
favorited.value = true;
|
|
|
|
await post(`/stashes/${user.primaryStash.id}/movies`, { movieId: props.movie.id });
|
|
|
|
events.emit('feedback', {
|
|
type: 'success',
|
|
message: `"${ellipsis(props.movie.title, fbCutoff)}" stashed to ${user.primaryStash.name}`,
|
|
});
|
|
} catch (error) {
|
|
favorited.value = false;
|
|
|
|
events.emit('feedback', {
|
|
type: 'error',
|
|
message: `Failed to stash "${ellipsis(props.movie.title, fbCutoff)}" to ${user.primaryStash.name}`,
|
|
});
|
|
}
|
|
}
|
|
|
|
async function unstash() {
|
|
try {
|
|
favorited.value = false;
|
|
|
|
await del(`/stashes/${user.primaryStash.id}/movies/${props.movie.id}`);
|
|
|
|
events.emit('feedback', {
|
|
type: 'remove',
|
|
message: `"${ellipsis(props.movie.title, fbCutoff)}" unstashed from ${user.primaryStash.name}`,
|
|
});
|
|
} catch (error) {
|
|
favorited.value = true;
|
|
|
|
console.error(error);
|
|
|
|
events.emit('feedback', {
|
|
type: 'error',
|
|
message: `Failed to unstash "${ellipsis(props.movie.title, fbCutoff)}" from ${user.primaryStash.name}`,
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.movie-tile {
|
|
display: flex;
|
|
flex-direction: column;
|
|
box-shadow: 0 0 3px var(--shadow-weak-30);
|
|
border-radius: .25rem;
|
|
overflow: hidden;
|
|
background: var(--background-base);
|
|
|
|
&:hover {
|
|
box-shadow: 0 0 3px var(--shadow-weak-20);
|
|
|
|
.heart {
|
|
fill: var(--text-light);
|
|
}
|
|
}
|
|
|
|
&.unstashed {
|
|
opacity: .5;
|
|
}
|
|
}
|
|
|
|
.cover-container {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-grow: 1;
|
|
position: relative;
|
|
background: var(--shadow-weak-30);
|
|
aspect-ratio: 5/7;
|
|
}
|
|
|
|
.cover-link {
|
|
width: 100%;
|
|
height: 100%;
|
|
font-size: 0;
|
|
}
|
|
|
|
.thumbnail {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
background-size: cover;
|
|
background-position: center;
|
|
}
|
|
|
|
.nocover {
|
|
width: 25%;
|
|
opacity: .1;
|
|
}
|
|
|
|
.tile-info {
|
|
flex-shrink: 0;
|
|
font-size: 0;
|
|
}
|
|
|
|
.tile-meta {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: .4rem .5rem;
|
|
border-radius: 0 0 .25rem .25rem;
|
|
margin-bottom: .5rem;
|
|
background: var(--shadow-strong-30);
|
|
color: var(--text-light);
|
|
font-size: .8rem;
|
|
}
|
|
|
|
.channel {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
margin-right: .5rem;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.channel-link {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.favicon-link {
|
|
display: inline-flex;
|
|
}
|
|
|
|
.favicon {
|
|
width: 1rem;
|
|
height: 1rem;
|
|
margin-right: .5rem;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.date {
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.nodate {
|
|
color: var(--highlight-strong-10);
|
|
}
|
|
|
|
.title {
|
|
display: block;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
font-weight: bold;
|
|
padding: 0 .5rem;
|
|
margin-bottom: .25rem;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.actors {
|
|
height: 2.4rem;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
overflow: hidden;
|
|
font-size: .9rem;
|
|
padding: 0 .5rem;
|
|
margin-bottom: .35rem;
|
|
line-height: 1.35;
|
|
}
|
|
|
|
.actor-item:not(:last-child):after {
|
|
content: ',\00a0';
|
|
}
|
|
|
|
.actor {
|
|
&:hover {
|
|
color: var(--primary);
|
|
}
|
|
}
|
|
|
|
.tags {
|
|
height: 1rem;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: .5rem;
|
|
overflow: hidden;
|
|
padding: 0 .5rem;
|
|
margin-bottom: .25rem;
|
|
color: var(--shadow-strong-10);
|
|
font-size: .75rem;
|
|
}
|
|
|
|
.tag {
|
|
flex-shrink: 0;
|
|
|
|
&:hover {
|
|
color: var(--primary);
|
|
}
|
|
}
|
|
|
|
.icon.heart {
|
|
width: 2rem;
|
|
height: 1.5rem;
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
padding: .5rem .5rem 1rem 1rem;
|
|
fill: var(--highlight-strong-10);
|
|
filter: drop-shadow(0 0 3px var(--shadow));
|
|
|
|
&:hover {
|
|
cursor: pointer;
|
|
fill: var(--primary);
|
|
}
|
|
|
|
&.favorited {
|
|
fill: var(--primary);
|
|
}
|
|
}
|
|
</style>
|