forked from jordanlambrecht/tracker-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorDisplay.tsx
More file actions
54 lines (51 loc) · 1.74 KB
/
Copy pathErrorDisplay.tsx
File metadata and controls
54 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// src/components/ui/ErrorDisplay.tsx
"use client"
import { H1 } from "@typography"
import clsx from "clsx"
import Link from "next/link"
import { CopyButton } from "@/components/ui/ActionButtons"
import { Button, buttonVariants } from "@/components/ui/Button"
import { Tooltip } from "@/components/ui/Tooltip"
export function ErrorDisplay({
message,
onRetry,
linkHref,
linkText,
}: {
message: string
onRetry: () => void
linkHref: string
linkText: string
}) {
const errorText = message || "An unexpected error occurred."
return (
<div className="flex min-h-screen items-center justify-center bg-base px-4">
<div className="w-full max-w-md bg-elevated p-8 nm-raised-lg rounded-nm-xl">
<p className="mb-1 font-mono text-xs uppercase tracking-widest text-danger">
Runtime Error
</p>
<H1 className="mb-4 text-xl font-semibold">Something went wrong</H1>
<div className="relative mb-6">
<pre className="bg-control-bg p-3 pr-10 font-mono text-xs text-secondary nm-inset whitespace-pre-wrap break-all rounded-nm-md">
{errorText}
</pre>
<Tooltip content="Copy error message">
<CopyButton
value={errorText}
className="absolute top-2 right-2 p-1.5 text-muted hover:text-secondary transition-colors duration-150 cursor-pointer"
/>
</Tooltip>
</div>
<div className="flex gap-3">
<Button variant="primary" size="sm" onClick={onRetry} text="Try Again" />
<Link
href={linkHref}
className={clsx(buttonVariants({ variant: "ghost", size: "sm" }), "rounded-nm-sm")}
>
{linkText}
</Link>
</div>
</div>
</div>
)
}