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

100% Statements 9/9
100% Branches 5/5
100% Functions 3/3
100% Lines 8/8

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  44x 2x 2x       44x 2x 2x                   33x                                               44x    
<template>
    <UContainer as="section" :id class="grid gap-8 border-t border-accented py-14 md:grid-cols-12">
        <header class="flex items-baseline gap-4 md:col-span-4 md:flex-col md:items-start">
            <span class="font-display text-title text-primary">{{ number }}</span>
            <h2 class="font-display text-section text-highlighted" :style="carriedTitle">
                {{ $t(`rules.${id}.title`) }}
            </h2>
        </header>
        <div class="flex flex-col gap-6 md:col-span-8">
            <p class="text-xl text-highlighted">{{ $t(`rules.${id}.body`, bodyParams) }}</p>
            <p v-if="skill" class="font-mono text-sm text-muted">
                {{ $t("ruleSection.skill") }} <code>{{ skill }}</code>
                <template v-if="count"> · {{ $t(`rules.${id}.count`, { count }) }}</template>
            </p>
            <p v-else-if="count" class="font-mono text-sm text-muted">
                {{ $t(`rules.${id}.count`, { count }) }}
            </p>
            <slot />
            <ULink v-if="to" :to class="self-start text-primary underline underline-offset-4">
                {{ $t(`rules.${id}.more`) }} →
            </ULink>
        </div>
    </UContainer>
</template>
 
<script setup lang="ts">
import type { RuleId } from "~/types/RuleId";
 
interface Props {
    id: RuleId;
    number: number;
    /** Values the rule's `body` copy interpolates. */
    bodyParams?: Record<string, number>;
    /** The skill an agent loads to follow the rule. */
    skill?: string;
    /** What the rule has produced so far; zero or unset prints nothing. */
    count?: number;
    /** Where the rule's `more` link leads. */
    to?: string;
}
 
const { id, number, bodyParams = {}, skill, count = 0, to } = defineProps<Props>();
 
const carriedTitle = computed(() => carried(`rule-${id}`));
</script>