1import { createLucideIcon } from "lucide-react";
2
3import { useNewWorkWorkspace } from "../../hooks/useNewWorkWorkspace";
4import { Button } from "../ui/button";
5import { useSidebar } from "../ui/sidebar";
6import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
7
8const BriefcasePlusIcon = createLucideIcon("briefcase-plus", [
9 ["path", { d: "M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2", key: "handle" }],
10 ["path", { d: "M12 20H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4", key: "case" }],
11 ["path", { d: "M16 18h6M19 15v6", key: "plus" }],
12]);
13
14export function NewWorkWorkspaceButton() {
15 const { setOpenMobile } = useSidebar();
16 const { project, pending, label, disabled, run } = useNewWorkWorkspace(() =>
17 setOpenMobile(false),
18 );
19 if (!project) return null;
20
21 return (
22 <Tooltip>
23 <TooltipTrigger
24 render={
25 <Button
26 variant="ghost"
27 size="icon-sm"
28 aria-label={label}
29 aria-busy={pending}
30 disabled={disabled}
31 onClick={() => void run()}
32 >
33 <BriefcasePlusIcon className="size-4" aria-hidden="true" />
34 </Button>
35 }
36 />
37 <TooltipPopup side="bottom">{label}</TooltipPopup>
38 </Tooltip>
39 );
40}