traxxx/assets/components/actors/photos.vue

137 lines
2.4 KiB
Vue
Raw Normal View History

<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.credit && `© ${actor.avatar.credit}`"
class="avatar photo"
@load="$parent.$emit('load')"
>
</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.credit || photo.entity.name}`"
class="photo"
@load="$parent.$emit('load')"
>
</a>
</div>
</template>
<script>
2020-05-17 23:22:56 +00:00
function sfw() {
return this.$store.state.ui.sfw;
}
export default {
props: {
actor: {
type: Object,
default: null,
},
},
2020-05-17 23:22:56 +00:00
computed: {
sfw,
},
};
</script>
<style lang="scss" scoped>
@import 'theme';
.photos {
display: flex;
box-sizing: border-box;
padding: .5rem 1rem;
margin: 0 1rem 0 0;
font-size: 0;
overflow-x: scroll;
scroll-behavior: smooth;
scrollbar-width: none;
&.expanded {
2020-06-29 23:07:48 +00:00
flex-wrap: wrap;
justify-content: center;
margin: 0;
.photo-link {
2020-06-29 23:07:48 +00:00
margin: 0 .5rem .5rem 0;
}
.photo {
2020-06-29 23:07:48 +00:00
height: 18rem;
}
}
&.empty {
display: none;
}
.avatar-link {
display: none;
}
&::-webkit-scrollbar {
display: none;
}
}
.photo-link {
margin: 0 .5rem 0 0;
}
.photo {
height: 15rem;
2020-07-05 02:27:46 +00:00
box-shadow: 0 0 3px var(--darken-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>