forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

empty-state.tsx67 lines, 1.7 KiBHistoryRawDownload
1import { Show } from "solid-js";
2import { Illustration } from "@/components/ui/illustration";
3import { cn } from "@/lib/cn";
4import type { IllustrationName } from "@/lib/illustrations";
5
6export type EmptyStateKind =
7 | "default"
8 | "search"
9 | "notes"
10 | "exams"
11 | "events"
12 | "courses"
13 | "messages"
14 | "meals"
15 | "homework"
16 | "payments"
17 | "people"
18 | "schedule"
19 | "whiteboard"
20 | "work"
21 | "coming-soon";
22
23const KIND_ILLUSTRATION: Record<EmptyStateKind, IllustrationName> = {
24 default: "empty",
25 search: "no-results",
26 notes: "notes",
27 exams: "exams",
28 events: "events",
29 courses: "courses",
30 messages: "messages",
31 meals: "meals",
32 homework: "homework",
33 payments: "payments",
34 people: "people",
35 schedule: "schedule",
36 whiteboard: "whiteboard",
37 work: "work",
38 "coming-soon": "coming-soon",
39};
40
41/** Empty panel with a theme-tinted illustration matching what is missing. */
42export function EmptyState(props: {
43 title: string;
44 description?: string;
45 kind?: EmptyStateKind;
46 class?: string;
47}) {
48 const kind = () => props.kind ?? "default";
49
50 return (
51 <div
52 class={cn(
53 "empty-state flex min-h-[289px] flex-col items-center justify-center gap-5 rounded-xl border border-border-hairline bg-surface-base px-10 py-12 text-center",
54 props.class,
55 )}
56 >
57 <Illustration name={KIND_ILLUSTRATION[kind()]} class="h-32 w-48 sm:h-36 sm:w-56" />
58
59 <div class="space-y-1.5">
60 <p class="text-lg font-semibold leading-7 tracking-[-0.015em] text-text-strong">{props.title}</p>
61 <Show when={props.description}>
62 <p class="mx-auto max-w-[420px] text-sm leading-[21px] text-text-subtle">{props.description}</p>
63 </Show>
64 </div>
65 </div>
66 );
67}