Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

empty.tsx

114 lines3.2 KB

1import { cva, type VariantProps } from "class-variance-authority";
2​
3import { cn } from "~/lib/utils";
4​
5function Empty({ className, ...props }: React.ComponentProps<"div">) {
6 return (
7 <div
8 className={cn(
9 "flex min-w-0 flex-1 flex-col items-center justify-center gap-6 text-balance p-6 text-center md:p-12",
10 className,
11 )}
12 data-slot="empty"
13 {...props}
14 />
15 );
17​
18function EmptyHeader({ className, ...props }: React.ComponentProps<"div">) {
19 return (
20 <div
21 className={cn("flex max-w-sm flex-col items-center text-center", className)}
22 data-slot="empty-header"
23 {...props}
24 />
25 );
27​
28const emptyMediaVariants = cva(
29 "flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
30 {
31 defaultVariants: {
32 variant: "default",
33 },
34 variants: {
35 variant: {
36 default: "bg-transparent",
37 icon: "relative flex size-9 shrink-0 items-center justify-center rounded-md border bg-card not-dark:bg-clip-padding text-foreground shadow-sm/5 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-md)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)] [&_svg:not([class*='size-'])]:size-4.5",
38 },
39 },
40 },
41);
42​
43function EmptyMedia({
44 className,
45 variant = "default",
46 ...props
47}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
48 return (
49 <div
50 className={cn("relative mb-6", className)}
51 data-slot="empty-media"
52 data-variant={variant}
53 {...props}
54 >
55 {variant === "icon" && (
56 <>
57 <div
58 aria-hidden="true"
59 className={cn(
60 emptyMediaVariants({ className, variant }),
61 "-translate-x-0.5 -rotate-10 pointer-events-none absolute bottom-px origin-bottom-left scale-84 shadow-none",
62 )}
63 />
64 <div
65 aria-hidden="true"
66 className={cn(
67 emptyMediaVariants({ className, variant }),
68 "pointer-events-none absolute bottom-px origin-bottom-right translate-x-0.5 rotate-10 scale-84 shadow-none",
69 )}
70 />
71 </>
72 )}
73 <div className={cn(emptyMediaVariants({ className, variant }))} {...props} />
74 </div>
75 );
77​
78function EmptyTitle({ className, ...props }: React.ComponentProps<"div">) {
79 return (
80 <div
81 className={cn("font-heading font-semibold text-xl", className)}
82 data-slot="empty-title"
83 {...props}
84 />
85 );
87​
88function EmptyDescription({ className, ...props }: React.ComponentProps<"p">) {
89 return (
90 <div
91 className={cn(
92 "text-muted-foreground text-sm [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4 [[data-slot=empty-title]+&]:mt-1",
93 className,
94 )}
95 data-slot="empty-description"
96 {...props}
97 />
98 );
100​
101function EmptyContent({ className, ...props }: React.ComponentProps<"div">) {
102 return (
103 <div
104 className={cn(
105 "flex w-full min-w-0 max-w-sm flex-col items-center gap-4 text-balance text-sm",
106 className,
107 )}
108 data-slot="empty-content"
109 {...props}
110 />
111 );
113​
114export { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia };