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

DeviceLoadingView.tsx

47 lines1.6 KB

1import { Smartphone } from "lucide-react";
2​
3import { Spinner } from "~/components/ui/spinner";
4​
5export function DeviceLoadingView(props: {
6 readonly name: string;
7 readonly description?: string;
8 readonly stage: "opening" | "stream";
9 readonly message: string;
10 readonly error?: boolean;
11}) {
12 return (
13 <div
14 role={props.error ? "alert" : "status"}
15 className="flex size-full items-center justify-center bg-background px-6 py-10"
16 >
17 <div className="flex max-w-sm flex-col items-center gap-3 text-center">
18 <div className="grid size-12 place-items-center rounded-xl border bg-muted/30">
19 <Smartphone className="size-6 text-muted-foreground" />
20 </div>
21 <div className="space-y-1">
22 <p className="text-sm font-medium">{props.name}</p>
23 {props.description ? (
24 <p className="text-xs text-muted-foreground">{props.description}</p>
25 ) : null}
26 </div>
27 <div className="flex items-center gap-2 text-xs text-muted-foreground">
28 {!props.error ? <Spinner className="size-3" /> : null}
29 <span>{props.message}</span>
30 </div>
31 {!props.error ? (
32 <div
33 className="flex w-24 gap-1"
34 aria-label={
35 props.stage === "opening" ? "Step 1 of 2: open device" : "Step 2 of 2: connect video"
36 }
37 >
38 <span className="h-1 flex-1 rounded-full bg-foreground/60" />
39 <span
40 className={`h-1 flex-1 rounded-full ${props.stage === "stream" ? "bg-foreground/60" : "bg-muted"}`}
41 />
42 </div>
43 ) : null}
44 </div>
45 </div>
46 );