'use client'; import Link from 'next/link'; import { ArrowRight } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; import type { UmamiMetricRow } from '@/lib/services/umami.service'; interface Props { title: string; rows: UmamiMetricRow[] | null; loading: boolean; /** Label substituted when `x` is empty (e.g. direct traffic referrers). */ defaultLabel?: string; /** Optional "View all" link target. When set, renders a link in the * card header that opens a full ranked-list page for this metric. */ viewAllHref?: string; /** Cap for the inline list (default 10). The full page uses no cap. */ limit?: number; } /** * Compact "top N" list used for top pages / referrers / countries. * Renders each row as label + numeric count, with a thin progress bar * scaled to the largest count in the set so the visual density tells * the same story at a glance as the numbers. */ export function TopList({ title, rows, loading, defaultLabel = '-', viewAllHref, limit = 10, }: Props) { return ( {title} {viewAllHref ? ( View all ) : null} {loading ? (
) : !rows || rows.length === 0 ? (
No data
) : ( )}
); }