<template>
    <div class="tags">
        <div class="tiles">
            <Tag
                v-for="tag in popularTags"
                :key="`tag-${tag.id}`"
                :tag="tag"
            />
        </div>
    </div>
</template>

<script>
import Tag from '../tile/tag.vue';

async function mounted() {
    const tags = await this.$store.dispatch('fetchTags', {
        slugs: [
            'airtight',
            'anal',
            'asian',
            'blonde',
            'blowjob',
            'brunette',
            'caucasian',
            'creampie',
            'deepthroat',
            'double-penetration',
            'ebony',
            'facefucking',
            'facial',
            'gangbang',
            'interracial',
            'latina',
            'lesbian',
            'maid',
            'mff',
            'mfm',
            'orgy',
            'redhead',
            'schoolgirl',
            'teen',
        ],
    });

    const tagsBySlug = tags.reduce((acc, tag) => ({ ...acc, [tag.slug]: tag }), {});

    this.popularTags = [
        'anal',
        'teen',
        'lesbian',
        'mff',
        'mfm',
        'orgy',
        'double-penetration',
        'gangbang',
        'airtight',
        'creampie',
        'facial',
        'interracial',
        'blowjob',
        'deepthroat',
        'facefucking',
        'asian',
        'ebony',
        'latina',
        'caucasian',
        'blonde',
        'brunette',
        'redhead',
        'schoolgirl',
        'maid',
    ].map(tagSlug => tagsBySlug[tagSlug]);

    this.pageTitle = 'Tags';
}

export default {
    components: {
        Tag,
    },
    data() {
        return {
            popularTags: [],
            pageTitle: null,
        };
    },
    mounted,
};
</script>

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

.tags {
    padding: 1rem;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, .25fr));
    grid-gap: 2rem;
}

.heading {
    font-size: 1.3rem;
}

@media(max-width: $breakpoint3) {
    .tiles {
        grid-template-columns: repeat(auto-fit, minmax(20rem, .5fr));
    }
}

@media(max-width: $breakpoint) {
    .tiles {
        grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    }
}
</style>
