components/linyi/skeleton.tsx
class-variance-authority
"use client"; import * as React from "react";import { cva, type VariantProps } from "class-variance-authority";import { cn } from "@/lib/cn"; export const skeletonVariants = cva("block bg-well border border-line/40", { variants: { shape: { line: "h-3 w-full rounded-[6px]", rect: "h-24 w-full rounded-well", circle: "size-10 rounded-pill", }, animated: { true: "animate-pulse motion-reduce:animate-none", false: "", }, }, defaultVariants: { shape: "line", animated: true, },}); export interface SkeletonProps extends React.ComponentPropsWithRef<"div">, VariantProps<typeof skeletonVariants> {} export function Skeleton({ className, shape = "line", animated = true, ...props}: SkeletonProps) { return ( <div aria-hidden="true" className={cn(skeletonVariants({ shape, animated }), className)} {...props} /> );}