All files / apps/huella-legal/layers/archive/app/components/subjects Formats.vue

100% Statements 16/16
100% Branches 2/2
100% Functions 7/7
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  4x       4x   2x   8x                       8x 8x   2x     2x           2x           4x                             4x   4x                 4x 4x 8x   8x                    
<template>
    <section aria-labelledby="formatos" class="border-y border-default bg-muted">
        <UContainer class="py-16 lg:py-20">
            <h2 id="formatos" class="scroll-mt-6 text-kicker">
                {{ $t("subjectsFormats.title") }}
            </h2>
            <ul
                class="mt-4 grid gap-px overflow-hidden rounded-xs border border-default bg-(--ui-border) sm:grid-cols-2 lg:grid-cols-3"
            >
                <li
                    v-for="{ value, count, key, classes, to } in items"
                    :key="value"
                    :class="classes.item"
                >
                    <ULink
                        raw
                        :to
                        class="group flex h-full flex-col gap-2 p-5 transition-colors focus-visible:-outline-offset-2 md:p-6"
                        :class="classes.link"
                    >
                        <BaseKicker>
                            {{ $t(classes.kicker, { count }) }}
                        </BaseKicker>
                        <span
                            class="font-serif text-h3 text-highlighted underline-title decoration-1 group-hover:underline"
                            >{{ $t(`subjectsFormats.formats.${key}.title`) }}</span
                        >
                        <span class="font-serif text-base/relaxed text-toned">{{
                            $t(`subjectsFormats.formats.${key}.description`)
                        }}</span>
                    </ULink>
                </li>
            </ul>
            <p class="mt-6 font-serif text-base/relaxed text-toned">
                {{ $t("subjectsFormats.publish.prompt") }}
                <ULink
                    raw
                    :to="{ name: 'publish', hash: '#tesis' }"
                    class="inline-flex min-h-11 items-center font-sans text-sm font-semibold text-primary underline-offset-4 hover:underline focus-visible:rounded-xs"
                    >{{ $t("subjectsFormats.publish.link") }}</ULink
                >
            </p>
        </UContainer>
    </section>
</template>
 
<script setup lang="ts">
import type { RouteLocationRaw } from "vue-router";
import type { Tone } from "~/types/Tone";
 
interface Props {
    formats: Facet<ArticleSummary["format"]>[];
}
 
const props = defineProps<Props>();
 
const TONES = {
    paper: { item: "bg-muted", link: "hover:bg-default", kicker: "subjectsFormats.format" },
    slate: {
        item: "surface-inverted bg-inverted",
        link: "hover:bg-elevated",
        kicker: "subjectsFormats.academic",
    },
} as const satisfies Record<Tone, Record<string, string>>;
 
const items = computed(() =>
    props.formats.map(({ value, count }) => {
        const tone: Tone = value === "tfg-tfm" ? "slate" : "paper";
 
        return {
            value,
            count,
            key: FORMAT_KEYS[value],
            classes: TONES[tone],
            to: { name: "publications", query: { format: value } } satisfies RouteLocationRaw,
        };
    }),
);
</script>