All files / apps/portfolio/app/components TermList.vue

100% Statements 9/9
100% Branches 10/10
100% Functions 6/6
100% Lines 7/7

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  23x 74x 23x         2x   92x               5x                                             74x    
<template>
    <component :is="ordered ? 'ol' : 'ul'" class="flex flex-col">
        <li
            v-for="item in rows"
            :key="item.id"
            class="grid gap-1 border-t border-default py-4"
            :class="wide ? 'sm:grid-cols-4' : 'sm:grid-cols-3'"
        >
            <span class="font-display text-2xl text-highlighted">{{ item.term }}</span>
            <span class="text-base" :class="wide ? 'sm:col-span-3' : 'sm:col-span-2'">
                <template v-for="(part, index) in item.parts" :key="index">
                    <strong v-if="part.strong" class="font-semibold text-highlighted">
                        <ULink
                            v-if="item.links?.[part.text]"
                            :to="item.links[part.text]"
                            raw
                            class="text-highlighted underline decoration-primary underline-offset-4"
                        >
                            {{ part.text }}
                        </ULink>
                        <template v-else>{{ part.text }}</template>
                    </strong>
                    <template v-else>{{ part.text }}</template>
                </template>
            </span>
        </li>
    </component>
</template>
 
<script setup lang="ts">
import type { Term } from "~/types/Term";
 
interface Props {
    items: readonly Term[];
    ordered?: boolean;
    /** Gives the detail three columns of four instead of two of three. */
    wide?: boolean;
}
 
const { items, ordered = false, wide = false } = defineProps<Props>();
 
const rows = computed(() => items.map((item) => ({ ...item, parts: emphasis(item.detail) })));
</script>