All files / apps/developer-portal/app/components WidgetPanel.vue

100% Statements 10/10
100% Branches 7/7
100% Functions 5/5
100% Lines 10/10

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  131x           32x 32x 32x   39x                                 132x     7x                                                     14x   14x                                       124x    
<template>
    <UCard
        variant="flush"
        class="flex flex-col"
        :ui="{ header: 'p-0 sm:px-0', body: 'min-h-0 flex-1', footer: 'px-4 py-2 sm:px-4' }"
    >
        <template #header>
            <div class="flex items-start justify-between gap-3 px-4 py-3">
                <div class="min-w-0">
                    <h2 class="text-sm font-semibold text-highlighted">
                        <NuxtLink v-if="to" :to class="group inline-flex items-center gap-1">
                            {{ title }}
                            <UIcon
                                name="i-lucide-arrow-up-right"
                                class="size-3.5 text-muted group-hover:text-highlighted"
                            />
                        </NuxtLink>
                        <template v-else>{{ title }}</template>
                    </h2>
                    <p v-if="meta" class="truncate text-xs text-muted">{{ meta }}</p>
                </div>
                <span
                    v-if="count !== undefined"
                    data-figure
                    class="shrink-0 text-2xl leading-none text-highlighted"
                >
                    {{ count }}
                </span>
            </div>
            <UTabs
                v-if="filters.length > 0"
                v-model="filter"
                :items="filters"
                :content="false"
                variant="link"
                size="xs"
                color="neutral"
                data-scroll-x
                class="overflow-x-auto border-t border-default px-4"
                :ui="{
                    root: 'items-start',
                    list: 'mb-0 h-9 w-max gap-3 border-b-0 p-0',
                    indicator: 'bottom-0 h-0.5 rounded-none bg-inverted',
                    trigger:
                        'shrink-0 px-0 py-0 font-normal data-[state=active]:font-medium data-[state=active]:text-highlighted',
                    label: 'overflow-visible',
                    trailingBadge: 'bg-transparent px-0 font-mono text-xs text-muted ring-0',
                }"
            />
        </template>
 
        <slot />
 
        <template v-if="all" #footer>
            <NuxtLink
                :to="all.to"
                class="flex items-center justify-between gap-3 text-xs text-muted hover:text-highlighted"
            >
                {{ all.label }}
                <UIcon name="i-lucide-arrow-right" class="size-3.5" />
            </NuxtLink>
        </template>
    </UCard>
</template>
 
<script setup lang="ts">
import type { TabsItem } from "@nuxt/ui";
 
interface Props {
    title: string;
    meta?: string;
    /** The page the whole dataset lives on, so the panel is a short list one step from the table. */
    to?: string;
    count?: number | string;
    filters?: TabsItem[];
    all?: { label: string; to: string } | null;
}
 
const { title, meta = "", to = "", count, filters = [], all = null } = defineProps<Props>();
 
const filter = defineModel<string>("filter", { default: "" });
</script>