traxxx/assets/components/tile/actor.vue

283 lines
4.9 KiB
Vue
Raw Normal View History

<template>
<div
v-if="actor"
class="actor"
>
<router-link
2020-05-25 02:39:58 +00:00
:to="{ name: 'actor', params: { actorId: actor.id, actorSlug: actor.slug } }"
class="link"
>
<span
class="handle"
>
2020-05-17 23:22:56 +00:00
<span
v-tooltip.top="actor.name"
class="name"
>{{ actor.name }}</span>
<router-link
v-if="actor.network"
v-tooltip="actor.network.name"
:to="{ name: 'network', params: { networkSlug: actor.network.slug } }"
class="favicon"
>
2020-05-17 23:22:56 +00:00
<img
:src="`/img/logos/${actor.network.slug}/favicon.png`"
class="favicon-icon"
>
</router-link>
2020-05-17 23:22:56 +00:00
<Icon
v-if="alias"
2020-05-26 02:11:29 +00:00
v-tooltip="`Alias of ${alias.name}`"
2020-05-17 23:22:56 +00:00
icon="users3"
class="favicon alias"
/>
<Icon
v-if="actor.dateOfDeath"
v-tooltip="`Died ${formatDate(actor.dateOfDeath, 'MMMM D, YYYY')}`"
icon="tombstone"
class="favicon died"
/>
</span>
<div class="avatar-container">
<img
v-if="actor.avatar"
:data-src="sfw ? `/img/${actor.avatar.sfw.thumbnail}` : `/media/${actor.avatar.thumbnail}`"
:data-loading="sfw ? `/img/${actor.avatar.sfw.lazy}` : `/media/${actor.avatar.lazy}`"
class="avatar lazy"
>
<span
v-else
class="avatar"
><img
:src="`/img/avatar_${actor.gender || 'female'}.svg`"
class="avatar-fallback"
></span>
<span
class="details"
>
2020-05-17 23:22:56 +00:00
<span class="gender-age">
<Gender :gender="actor.gender" />
<span
v-if="actor.ageAtDeath"
v-tooltip="`Born ${formatDate(actor.dateOfBirth, 'MMMM D, YYYY')}<br>Died ${formatDate(actor.dateOfDeath, 'MMMM D, YYYY')}`"
class="age-death"
>{{ actor.ageAtDeath }}</span>
<span
v-else-if="actor.age"
v-tooltip="`Born on ${formatDate(actor.dateOfBirth, 'MMMM D, YYYY')}`"
class="age-now"
>{{ actor.age }}</span>
<span
v-if="actor.ageThen && actor.ageThen < actor.age"
v-tooltip="`${actor.ageThen} years old on release date`"
class="age-then"
>{{ actor.ageThen }}</span>
</span>
<span
v-if="actor.origin"
v-tooltip="`Born in ${actor.origin.country.alias || actor.origin.country.name}`"
class="country"
>
{{ actor.origin.country.alpha2 }}
<img
class="flag"
:src="`/img/flags/${actor.origin.country.alpha2.toLowerCase()}.svg`"
>
</span>
<span
v-else
class="country"
/>
</span>
</div>
</router-link>
</div>
</template>
<script>
import Gender from '../actors/gender.vue';
2020-05-17 23:22:56 +00:00
function sfw() {
return this.$store.state.ui.sfw;
}
export default {
components: {
Gender,
},
props: {
actor: {
type: Object,
default: null,
},
2020-05-17 23:22:56 +00:00
alias: {
type: Object,
default: null,
},
},
computed: {
sfw,
},
};
</script>
<style lang="scss" scoped>
@import 'theme';
.actor {
width: 100%;
display: inline-block;
2020-04-27 00:37:30 +00:00
position: relative;
margin: 0 .5rem .5rem 0;
box-shadow: 0 0 3px var(--darken-weak);
background: var(--background);
overflow: hidden;
2020-04-27 00:37:30 +00:00
&::before {
content: '';
display: inline-block;
padding-bottom: 150%;
}
}
.link {
2020-04-27 00:37:30 +00:00
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
position: absolute;
top: 0;
left: 0;
color: var(--text);
text-decoration: none;
&:hover {
color: var(--primary);
}
}
.handle {
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
box-shadow: 0 0 3px var(--shadow);
2020-05-17 23:22:56 +00:00
.name {
padding: .5rem;
}
.alias {
2020-05-26 02:11:29 +00:00
fill: var(--shadow);
2020-05-17 23:22:56 +00:00
}
}
.favicon {
2020-05-17 23:22:56 +00:00
font-size: 0;
padding: .5rem .25rem;
&:last-child {
padding: .5rem;
}
&.died {
2020-05-26 02:11:29 +00:00
fill: var(--shadow);
}
2020-05-17 23:22:56 +00:00
}
.favicon-icon {
width: 1rem;
height: 1rem;
}
.name {
flex-grow: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.avatar-container {
2020-04-27 00:37:30 +00:00
display: flex;
flex-grow: 1;
position: relative;
2020-05-17 23:22:56 +00:00
overflow: hidden;
background: var(--profile);
}
.avatar {
color: var(--darken-weak);
background: var(--darken-hint);
width: 100%;
2020-04-27 00:37:30 +00:00
height: 100%;
display: flex;
2020-04-27 00:37:30 +00:00
flex-direction: column;
align-items: center;
justify-content: center;
object-fit: cover;
object-position: 50% 0;
}
2019-12-10 21:35:00 +00:00
.avatar-fallback {
max-height: 100%;
max-width: 100%;
opacity: .1;
}
2019-12-10 21:35:00 +00:00
.details {
background: var(--darken);
color: var(--text-light);
2019-12-10 21:35:00 +00:00
width: 100%;
height: 1.75rem;
2019-12-10 21:35:00 +00:00
display: flex;
align-items: center;
2020-05-17 23:22:56 +00:00
justify-content: space-between;
2019-12-10 21:35:00 +00:00
box-sizing: border-box;
padding: .5rem;
position: absolute;
bottom: 0;
font-size: .9rem;
2019-12-10 21:35:00 +00:00
font-weight: bold;
}
2020-05-17 23:22:56 +00:00
.gender-age {
display: flex;
align-items: center;
}
.gender {
2020-05-17 23:22:56 +00:00
margin: .25rem .25rem 0 0;
}
.country {
display: flex;
justify-content: flex-end;
align-items: center;
}
.flag {
2020-05-17 23:22:56 +00:00
height: .75rem;
margin: 0 0 0 .5rem;
}
2020-05-26 02:11:29 +00:00
.age-now,
.age-death {
margin: 0 .25rem 0 0;
}
.age-then {
color: var(--lighten);
}
</style>