<template>
    <div class="releases">
        <h3
            v-if="context"
            class="heading"
        ><span class="range">{{ range }}</span> releases for '{{ context }}'</h3>

        <ul class="nolist tiles">
            <li
                v-for="release in releases"
                :key="`release-${release.id}`"
            >
                <ReleaseTile :release="release" />
            </li>
        </ul>
    </div>
</template>

<script>
import ReleaseTile from '../tile/release.vue';

function range() {
    return this.$store.state.ui.range;
}

export default {
    components: {
        ReleaseTile,
    },
    props: {
        releases: {
            type: Array,
            default: () => [],
        },
        context: {
            type: String,
            default: null,
        },
    },
    computed: {
        range,
    },
};
</script>

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

.heading {
    padding: 0;
    margin: 0 0 1rem 0;

    .range {
        text-transform: capitalize;
    }
}

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

@media(max-width: $breakpoint4) {
    .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>