<template>
    <router-link
        :to="{ name: 'tag', params: { tagSlug: tag.slug } }"
        :title="tag.name"
        class="tile"
    >
        <span class="title">{{ tag.name }}</span>

        <img
            v-if="tag.poster"
            :src="sfw ? `/img/${tag.poster.sfw.thumbnail}` : `/img/${tag.poster.thumbnail}`"
            :title="sfw ? tag.poster.sfw.comment : tag.poster.comment"
            :alt="tag.name"
            class="poster"
        >
    </router-link>
</template>

<script>
function sfw() {
    return this.$store.state.ui.sfw;
}

export default {
    props: {
        tag: {
            type: Object,
            default: null,
        },
    },
    computed: {
        sfw,
    },
};
</script>

<style lang="scss" scoped>
@import 'theme';

.tile {
    color: var(--text-light);
    background: var(--profile);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-sizing: border-box;
    position: relative;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 0 3px var(--darken-weak);
}

.poster {
    width: 100%;
    height: 16rem;
    object-fit: cover;
    object-position: 50% 100%;
}

.title {
    width: 100%;
    display: flex;
    box-sizing: border-box;
    padding: .5rem 1rem;
    position: absolute;
    bottom: 0;
    background: var(--darken);
    font-size: 1rem;
    font-weight: bold;
    text-transform: capitalize;
    text-shadow: 0 0 3px var(--darken-strong);
}
</style>
