import { cn } from "../../lib/utils"; import * as React from "react"; interface SkeletonProps extends React.HTMLAttributes { /** Shape of the skeleton */ variant?: "default" | "circle" | "rounded" | "square"; /** Width of the skeleton */ width?: string | number; /** Height of the skeleton */ height?: string | number; /** Animation type for the skeleton */ animation?: "pulse" | "wave" | "none"; /** Whether to show a shimmer effect */ shimmer?: boolean; /** Number of skeleton items to display */ count?: number; } function Skeleton({ className, variant = "default", width, height, animation = "pulse", shimmer = false, count = 1, ...props }: SkeletonProps) { // Variant classes const variantClasses = { default: "rounded-md", circle: "rounded-full", rounded: "rounded-xl", square: "rounded-none" }; // Animation classes const animationClasses = { pulse: "animate-pulse", wave: "animate-shimmer", none: "" }; // Style object for width and height const style: React.CSSProperties = { width: width !== undefined ? (typeof width === "number" ? `${width}px` : width) : undefined, height: height !== undefined ? (typeof height === "number" ? `${height}px` : height) : undefined, ...props.style }; // Render multiple skeleton items if count > 1 if (count > 1) { return (
{Array.from({ length: count }).map((_, index) => (
))}
); } return (
); } // Template Card Skeleton component for reuse function TemplateCardSkeleton() { return (
{/* Image placeholder */} {/* Content area */}
{/* Title */} {/* Description */}
{/* Tags */}
{/* Price and button */}
); } export { Skeleton, TemplateCardSkeleton };