forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits

empty-state.tsx80 lines, 3.6 KiBHistoryRawDownload
1import { Show } from "solid-js";
2import { cn } from "@/lib/cn";
3import { DOMAIN_COLORS } from "@/lib/domain-colors";
4
5export type EmptyStateKind = "default" | "notes" | "exams" | "events" | "courses" | "messages" | "meals";
6
7const KIND_TONE: Record<EmptyStateKind, string> = {
8 default: "border-primary/40 ring-1 ring-primary/25 bg-muted/30 text-foreground",
9 notes: DOMAIN_COLORS.notes.emptyStateClass,
10 exams: DOMAIN_COLORS.exams.emptyStateClass,
11 events: DOMAIN_COLORS.events.emptyStateClass,
12 courses: DOMAIN_COLORS.courses.emptyStateClass,
13 messages: DOMAIN_COLORS.messages.emptyStateClass,
14 meals: "border-amber-500/40 ring-1 ring-amber-500/25 bg-muted/30 text-foreground",
15};
16
17/** Clean dashed empty panel with animated vector illustrations. */
18export function EmptyState(props: {
19 title: string;
20 description?: string;
21 kind?: EmptyStateKind;
22 class?: string;
23}) {
24 const kind = () => props.kind ?? "default";
25
26 return (
27 <div
28 class={cn(
29 "flex min-h-48 flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border/70 bg-muted/15 px-6 py-8 text-center transition-all duration-300",
30 props.class,
31 )}
32 >
33 <div class={cn("relative flex h-16 w-16 items-center justify-center rounded-lg border shadow-inner", KIND_TONE[kind()])}>
34 <Show when={kind() === "notes"}>
35 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
36 <path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z" />
37 <path d="M6 6h10" />
38 <path d="M6 10h8" />
39 <circle cx="18" cy="18" r="2.5" class="fill-current opacity-30" />
40 </svg>
41 </Show>
42 <Show when={kind() === "exams"}>
43 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
44 <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
45 <polyline points="14 2 14 8 20 8" />
46 <path d="m9 15 2 2 4-4" />
47 </svg>
48 </Show>
49 <Show when={kind() === "events"}>
50 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
51 <rect width="18" height="18" x="3" y="4" rx="2" ry="2" />
52 <line x1="16" x2="16" y1="2" y2="6" />
53 <line x1="8" x2="8" y1="2" y2="6" />
54 <line x1="3" x2="21" y1="10" y2="10" />
55 <path d="m9 16 2 2 4-4" />
56 </svg>
57 </Show>
58 <Show when={kind() === "meals"}>
59 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
60 <path d="M3 2v7c0 1.1.9 2 2 2h0a2 2 0 0 0 2-2V2M5 2v20" />
61 <path d="M15 2v20M15 8c0-3.3 1.3-6 4-6v20" />
62 </svg>
63 </Show>
64 <Show when={kind() === "default" || kind() === "courses"}>
65 <svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
66 <path d="M22 10v6M2 10l10-5 10 5-10 5z" />
67 <path d="M6 12v5c3 3 9 3 12 0v-5" />
68 </svg>
69 </Show>
70 </div>
71
72 <div class="space-y-1">
73 <p class="text-sm font-semibold text-foreground">{props.title}</p>
74 <Show when={props.description}>
75 <p class="max-w-sm text-xs leading-relaxed text-muted-foreground">{props.description}</p>
76 </Show>
77 </div>
78 </div>
79 );
80}