"use client";
import type { LucideIcon } from "lucide-react";
import { Loader2 } from "lucide-react";
export function PageHeader({
icon: Icon,
title,
subtitle,
children,
}: {
icon?: LucideIcon;
title: string;
subtitle?: string;
children?: React.ReactNode;
}) {
return (
{Icon && (
)}
{title}
{subtitle &&
{subtitle}
}
{children &&
{children}
}
);
}
export function PageSection({
title,
icon: Icon,
children,
actions,
className,
}: {
title?: string;
icon?: LucideIcon;
children: React.ReactNode;
actions?: React.ReactNode;
className?: string;
}) {
return (
{(title || actions) && (
{title && (
{Icon && }
{title}
)}
{actions &&
{actions}
}
)}
{children}
);
}
export function Stat({
label,
value,
icon: Icon,
detail,
tone = "neutral",
}: {
label: string;
value: React.ReactNode;
icon?: LucideIcon;
detail?: string;
tone?: "neutral" | "primary" | "accent" | "red" | "green";
}) {
const toneClass = {
neutral: "border-border/50 bg-card/60 text-foreground",
primary: "border-primary/20 bg-primary/10 text-primary",
accent: "border-accent/20 bg-accent/10 text-accent",
red: "border-red-500/20 bg-red-500/10 text-red-400",
green: "border-emerald-500/20 bg-emerald-500/10 text-emerald-400",
}[tone];
return (
{value}
{detail &&
{detail}
}
);
}
export function Loading({ children, message }: { children?: React.ReactNode; message?: string }) {
return (
{message &&
{message}
}
{children &&
{children}
}
);
}
export function ErrorState({ error, onRetry, title, message }: { error?: string; onRetry?: () => void; title?: string; message?: string }) {
const text = error || message || "Something went wrong";
return (
{title || "Error"}
{text}
{onRetry && (
)}
);
}
export function PageSkeleton({
title = "Loading",
count = 1,
}: {
title?: string;
count?: number;
}) {
return (
{Array.from({ length: count }).map((_, i) => (
))}
);
}
export function EmptyState({
icon: Icon,
title,
message,
description,
action,
}: {
icon?: LucideIcon;
title: string;
message?: string;
description?: string;
action?: React.ReactNode;
}) {
const body = message || description || "";
return (
{Icon && (
)}
{title}
{body &&
{body}
}
{action &&
{action}
}
);
}