"use client";
import { cn } from "@/lib/utils";
type LoadingStateProps = {
message?: string;
size?: "sm" | "md" | "lg";
className?: string;
};
export function LoadingState({
message = "Loading...",
size = "md",
className,
}: LoadingStateProps) {
const sizeClasses = {
sm: "h-6 w-6 border-2",
md: "h-8 w-8 border-2",
lg: "h-12 w-12 border-3",
};
return (
{message && (
{message}
)}
);
}
type SkeletonProps = {
variant?: "text" | "card" | "circle" | "rect";
width?: string | number;
height?: string | number;
lines?: number;
className?: string;
};
export function Skeleton({
variant = "rect",
width,
height,
lines = 1,
className,
}: SkeletonProps) {
const baseClasses = "skeleton";
const variantClasses = {
text: "rounded-md",
card: "rounded-lg",
circle: "rounded-full",
rect: "rounded-sm",
};
const style = {
width: width || (variant === "text" ? "100%" : "120px"),
height: height || (variant === "text" ? "1em" : variant === "circle" ? width || "40px" : "80px"),
};
if (variant === "text" && lines > 1) {
return (
{Array.from({ length: lines }).map((_, i) => (
))}
);
}
return (
);
}
type PageLoadingProps = {
message?: string;
subtitle?: string;
};
export function PageLoading({ message, subtitle }: PageLoadingProps) {
return (
{subtitle && (
{subtitle}
)}
);
}
type InlineLoadingProps = {
text?: string;
size?: "sm" | "md" | "lg";
className?: string;
};
export function InlineLoading({
text = "Loading...",
size = "sm",
className,
}: InlineLoadingProps) {
return (
{text}
);
}
type CardSkeletonProps = {
lines?: number;
withImage?: boolean;
className?: string;
};
export function CardSkeleton({
lines = 3,
withImage = false,
className,
}: CardSkeletonProps) {
return (
{withImage && (
)}
);
}