<template>
    <a
        :href="`/tag/${tag.slug}`"
        :title="tag.name"
        class="tile"
    >
        <img
            v-if="imageAvailable"
            :src="`/img/tags/${tag.slug}_thumb.jpg`"
            :alt="tag.name"
            class="poster"
            @error="imageAvailable = false"
        >

        <span class="title">{{ tag.name }}</span>
    </a>
</template>

<script>
export default {
    props: {
        tag: {
            type: Object,
            default: null,
        },
    },
    data() {
        return {
            imageAvailable: true,
        };
    },
};
</script>

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

.tile {
    background: $background;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    box-shadow: 0 0 3px rgba(0, 0, 0, .25);
    text-align: center;
    text-decoration: none;
}

.poster {
    width: 100%;
    height: 14rem;
    object-fit: cover;
}

.title {
    color: $text;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    padding: .5rem 1rem;
}

.title {
    color: $text;
    height: 100%;
    display: flex;
    align-items: center;
    margin: 0;
}
</style>
