All files / apps/developer-portal/layers/projects/app/components/project ExtraTab.vue

100% Statements 11/11
100% Branches 4/4
100% Functions 6/6
100% Lines 9/9

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  3x           3x   2x   3x 3x           2x                                         3x   3x 2x                  
<template>
    <WidgetPanel
        :title="tab.label"
        :meta="$t('projectExtraTab.meta', { name })"
        :count="tab.items.length"
        :to="tab.to"
    >
        <EmptyState v-if="tab.items.length === 0">{{ tab.empty }}</EmptyState>
        <ul v-else class="divide-y divide-default">
            <li v-for="row in rows" :key="row.id">
                <NuxtLink :to="row.to" class="flex flex-col gap-2 px-4 py-3 hover:bg-elevated">
                    <div class="flex items-baseline justify-between gap-3">
                        <span class="truncate text-sm font-medium text-highlighted">
                            {{ row.title }}
                        </span>
                        <span data-figure class="text-xl leading-none text-highlighted">
                            {{ row.percent }}<span class="text-sm text-muted">%</span>
                        </span>
                    </div>
                    <SplitBar :parts="row.parts" />
                </NuxtLink>
            </li>
        </ul>
    </WidgetPanel>
</template>
 
<script setup lang="ts">
import type { ProjectTab } from "~/types/ProjectTab";
import type { ProjectTabRow } from "~/types/ProjectTabRow";
import type { SplitPart } from "~/types/SplitPart";
 
interface Props {
    tab: ProjectTab & { label: string; empty: string; items: ProjectTabRow[] };
    /** The project's folder. */
    name: string;
}
 
const { tab, name } = defineProps<Props>();
 
const { t } = useI18n();
 
const rows = computed(() =>
    tab.items.map((row) => ({
        ...row,
        parts: [
            { label: t("projectExtraTab.parts.done"), value: row.done, tone: "ink" },
            { label: t("projectExtraTab.parts.left"), value: row.left, tone: "soft" },
        ] satisfies SplitPart[],
    })),
);
</script>