traxxx/assets/components/actors/photos.vue

139 lines
2.4 KiB
Vue

<template>
<div
v-lazy-container
class="photos"
:class="{
avatar: !!actor.avatar,
empty: actor.photos.length === 0,
}"
>
<a
v-show="actor.avatar"
:href="`/media/${actor.avatar.path}`"
target="_blank"
rel="noopener noreferrer"
class="avatar-link photo-link"
>
<img
:src="sfw ? `/img/${actor.avatar.sfw.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:data-src="sfw ? `/img/${actor.avatar.sfw.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:data-loading="sfw ? `/img/${actor.avatar.sfw.lazy}` : `/media/${actor.avatar.lazy}`"
:title="actor.avatar.copyright && `© ${actor.avatar.copyright}`"
class="avatar photo"
>
</a>
<a
v-for="photo in actor.photos"
:key="`photo-${photo.id}`"
:href="`/media/${photo.path}`"
target="_blank"
rel="noopener noreferrer"
class="photo-link"
>
<img
:src="sfw ? `/img/${photo.sfw.thumbnail}` : `/media/${photo.thumbnail}`"
:data-src="sfw ? `/img/${photo.sfw.thumbnail}` : `/media/${photo.thumbnail}`"
:data-loading="sfw ? `/img/${photo.sfw.lazy}` : `/media/${photo.lazy}`"
:title="`© ${photo.copyright || photo.entity.name}`"
class="photo"
>
</a>
</div>
</template>
<script>
function sfw() {
return this.$store.state.ui.sfw;
}
export default {
props: {
actor: {
type: Object,
default: null,
},
},
computed: {
sfw,
},
};
</script>
<style lang="scss" scoped>
@import 'theme';
.photos {
display: flex;
box-sizing: border-box;
padding: .5rem 1rem;
font-size: 0;
overflow-x: scroll;
scroll-behavior: smooth;
scrollbar-width: none;
&.expanded {
flex-wrap: wrap;
justify-content: center;
/*
display: grid;
grid-gap: .5rem;
grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
*/
.photo-link {
margin: 0 .5rem .5rem 0;
}
.photo {
height: 18rem;
}
}
&.empty {
display: none;
}
.avatar-link {
display: none;
}
&::-webkit-scrollbar {
display: none;
}
}
.photo-link {
margin: 0 .5rem 0 0;
}
.photo {
height: 15rem;
box-shadow: 0 0 3px $shadow-weak;
object-fit: cover;
}
@media(max-width: $breakpoint3) {
.photos {
&.empty.avatar {
display: flex;
}
.avatar-link {
display: inline-block;
}
&.expanded {
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
}
}
}
@media(max-width: $breakpoint0) {
.photos.expanded {
grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
}
}
</style>