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

NoProjectsHero.tsx

53 lines2.3 KB

1import { MessageSquareDashedIcon, PlusIcon } from "lucide-react";
2​
3import { openCommandPalette } from "../commandPaletteBus";
4import { isElectron } from "../env";
5import { useScratchProject } from "../hooks/useScratchProject";
6import { usePrimaryEnvironmentId } from "../state/environments";
7import { Button } from "./ui/button";
8import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "./ui/empty";
9import { SidebarInset } from "./ui/sidebar";
10import { WorkspacePageHeader } from "./WorkspacePageHeader";
11​
12export function NoProjectsHero() {
13 const primaryEnvironmentId = usePrimaryEnvironmentId();
14 const { scratchEnvironmentId, startScratchThread } = useScratchProject();
15 const scratchTargetEnvironmentId = scratchEnvironmentId(primaryEnvironmentId);
16​
17 return (
18 <SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none">
19 <div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-background">
20 {/* The desktop window only moves where CSS opts in, so keep a titlebar strip. */}
21 {isElectron ? <WorkspacePageHeader electron /> : null}
22 <Empty size="hero" className="flex-1">
23 <div className="w-full max-w-lg px-8 py-12">
24 <EmptyHeader className="max-w-none">
25 <EmptyTitle>What should we work on?</EmptyTitle>
26 <EmptyDescription>
27 {scratchTargetEnvironmentId === null
28 ? "Add a project to start your first thread."
29 : "Add a project, or start without one."}
30 </EmptyDescription>
31 <div className="mt-6 flex justify-center gap-2">
32 <Button size="sm" onClick={() => openCommandPalette({ open: "add-project" })}>
33 <PlusIcon className="size-4" />
34 Add project
35 </Button>
36 {scratchTargetEnvironmentId === null ? null : (
37 <Button
38 size="sm"
39 variant="outline"
40 onClick={() => void startScratchThread(scratchTargetEnvironmentId)}
41 >
42 <MessageSquareDashedIcon className="size-4" />
43 Start without a project
44 </Button>
45 )}
46 </div>
47 </EmptyHeader>
48 </div>
49 </Empty>
50 </div>
51 </SidebarInset>
52 );