All files / apps/huella-legal/layers/archive/app/components/home Subjects.vue

100% Statements 17/17
80% Branches 4/5
100% Functions 8/8
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81  4x               4x                     4x   1x 1x 8x                     1x   8x         1x 1x 1x                       1x 6x           6x     4x                       4x    
<template>
    <UPageSection
        orientation="horizontal"
        :aria-labelledby="titleId"
        :description="$t('homeSubjects.lead', { count: subjects.length }, subjects.length)"
        :ui="{ description: 'max-w-sm' }"
        class="border-y border-default bg-muted"
    >
        <template #headline>
            <BaseKicker>{{ $t("homeSubjects.kicker") }}</BaseKicker>
        </template>
        <template #title>
            <span :id="titleId">{{ $t("homeSubjects.title") }}</span>
        </template>
        <template #links>
            <UButton
                variant="outline"
                color="neutral"
                :label="$t('homeSubjects.all')"
                :to="{ name: 'categories' }"
            />
        </template>
        <div class="lg:col-span-8">
            <ul class="grid gap-x-10 sm:grid-cols-2 xl:grid-cols-3 xl:gap-x-8">
                <li
                    v-for="{ value, count } in subjects"
                    :key="value.id"
                    class="border-b border-muted"
                >
                    <ULink
                        raw
                        :to="{ name: 'category', params: { slug: value.slug } }"
                        class="group flex min-h-14 items-baseline gap-3 py-3 focus-visible:rounded-xs xl:gap-2"
                    >
                        <span
                            class="font-serif text-lg text-highlighted underline-title group-hover:underline xl:text-base"
                            >{{ value.name }}</span
                        >
                        <span
                            class="flex-1 translate-y-[-0.2em] border-b border-dotted border-ivory-400"
                            aria-hidden="true"
                        />
                        <span class="font-sans text-meta text-muted tabular-nums">
                            <span aria-hidden="true">{{ count }}</span>
                            <span class="sr-only">{{
                                $t("homeSubjects.count", { count }, count)
                            }}</span>
                        </span>
                    </ULink>
                </li>
            </ul>
            <nav
                v-if="formats.length > 1"
                :aria-label="$t('homeSubjects.formats.label')"
                class="mt-6 -ml-2 flex flex-wrap items-center gap-x-1 font-sans text-sm"
            >
                <span class="mr-2 pl-2 text-muted">{{ $t("homeSubjects.formats.prompt") }}</span>
                <ULink
                    v-for="{ value } in formats"
                    :key="value"
                    raw
                    :to="{ name: 'publications', query: { format: value } }"
                    class="inline-flex min-h-11 items-center px-2 font-semibold text-primary underline-offset-4 hover:underline focus-visible:rounded-xs"
                    >{{ $t(`homeSubjects.formats.${FORMAT_KEYS[value]}`) }}</ULink
                >
            </nav>
        </div>
    </UPageSection>
</template>
 
<script setup lang="ts">
interface Props {
    subjects: Facet<Category>[];
    formats: Facet<ArticleSummary["format"]>[];
}
 
defineProps<Props>();
 
const titleId = useId();
</script>