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

100% Statements 26/26
70% Branches 7/10
100% Functions 12/12
100% Lines 22/22

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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124  6x         38x 38x                             38x     6x             6x         38x           6x                         6x                 38x 12x                   38x     12x         12x   38x 18x                                               6x   6x   18x   6x   6x   6x    
<template>
    <UContainer
        as="section"
        :aria-label="$t('homeFeatured.label')"
        class="grid grid-cols-1 gap-12 pt-8 pb-16 lg:grid-cols-12 lg:gap-0 lg:pt-10 lg:pb-20"
    >
        <article class="group relative flex flex-col gap-5 lg:col-span-8 lg:pr-12">
            <div class="@container aspect-16/10 overflow-hidden rounded-xs">
                <!-- Decorative: the title below it already names the article -->
                <NuxtImg
                    v-if="lead.image"
                    :src="lead.image.url"
                    :width="lead.image.width"
                    :height="leadHeight"
                    fit="cover"
                    sizes="sm:100vw md:100vw lg:720px"
                    alt=""
                    fetchpriority="high"
                    class="size-full object-cover"
                />
                <ArticleMediaFallback v-else tone="slate" />
            </div>
            <p class="flex flex-wrap items-center gap-x-2 gap-y-1 font-sans text-xs">
                <BaseKicker>{{
                    $t(`homeFeatured.formats.${FORMAT_KEYS[lead.format]}`)
                }}</BaseKicker>
                <template v-if="lead.category">
                    <span class="text-dimmed" aria-hidden="true">ยท</span>
                    <ULink
                        raw
                        :to="{ name: 'category', params: { slug: lead.category.slug } }"
                        class="relative z-10 font-medium text-muted underline-offset-4 hover:underline focus-visible:rounded-xs"
                        >{{ lead.category.name }}</ULink
                    >
                </template>
            </p>
            <h2
                class="font-serif text-feature text-balance text-highlighted md:text-feature-lg lg:text-feature-xl"
            >
                <ULink
                    raw
                    :to="leadLink"
                    class="underline-title decoration-2 group-hover:underline after:absolute after:inset-0 focus-visible:rounded-xs focus-visible:outline-offset-4"
                    >{{ lead.title }}</ULink
                >
            </h2>
            <p v-if="lead.excerpt" class="max-w-measure font-serif text-reading text-toned">
                {{ lead.excerpt }}
            </p>
            <ArticleByline
                :authors
                :published-at="lead.publishedAt"
                :reading-minutes="lead.readingMinutes"
                avatars
                class="[&_a]:relative [&_a]:z-10"
            />
        </article>
 
        <aside
            :aria-labelledby="latestId"
            class="border-t-2 border-inverted pt-4 lg:col-span-4 lg:border-t-0 lg:border-l lg:border-default lg:pt-0 lg:pl-10"
        >
            <h2 :id="latestId" class="text-kicker">
                {{ $t("homeFeatured.latest.title") }}
            </h2>
            <ol class="mt-2 flex flex-col divide-y divide-muted">
                <li
                    v-for="(article, index) in latest"
                    :key="article.id"
                    class="relative grid grid-cols-[2rem_1fr] py-4"
                >
                    <span
                        class="font-serif text-xl/snug text-secondary tabular-nums"
                        aria-hidden="true"
                        >{{ index + 1 }}</span
                    >
                    <span class="flex flex-col gap-1">
                        <BaseKicker>{{
                            $t(`homeFeatured.formats.${FORMAT_KEYS[article.format]}`)
                        }}</BaseKicker>
                        <ULink
                            raw
                            :to="articleLink(article.slug)"
                            class="font-serif text-lg/snug text-highlighted underline-title after:absolute after:inset-0 hover:underline focus-visible:rounded-xs focus-visible:outline-offset-2"
                            >{{ article.title }}</ULink
                        >
                        <span class="font-sans text-meta text-muted">{{
                            article.authors.map(({ name }) => name).join(", ")
                        }}</span>
                    </span>
                </li>
            </ol>
            <UButton
                variant="link"
                :label="$t('homeFeatured.latest.all')"
                trailing-icon="i-lucide-arrow-right"
                :to="{ name: 'publications' }"
                class="-ml-3"
            />
        </aside>
    </UContainer>
</template>
 
<script setup lang="ts">
import type { RouteLocationRaw } from "vue-router";
 
interface Props {
    lead: ArticleSummary;
    latest: ArticleSummary[];
}
 
const props = defineProps<Props>();
 
const latestId = useId();
 
const articleLink = (slug: string): RouteLocationRaw => ({ name: "article", params: { slug } });
 
const leadLink = computed<RouteLocationRaw>(() => articleLink(props.lead.slug));
 
const authors = computed(() => bylineAuthors(props.lead.authors));
 
const leadHeight = computed(() => coverHeight(props.lead.image?.width, 16 / 10));
</script>