1import { useState } from "react";
2import {
3 IconArrowRight,
4 IconDeviceDesktop,
5 IconFileText,
6 IconFolder,
7 IconMoon,
8 IconPalette,
9 IconPlus,
10 IconSearch,
11 IconSettings,
12 IconSun,
13 IconUser,
14} from "@tabler/icons-react";
15import { CommandDialog, type CommandGroup } from "@/components/wensity/command";
16
17const groups: CommandGroup[] = [
18 {
19 heading: "Recent",
20 items: [
21 { id: "customer-jane", label: "Jane Cooper", description: "Open customer profile", icon: <IconUser /> },
22 { id: "q2-report", label: "Q2 revenue report", description: "Edited 12 minutes ago", icon: <IconFileText /> },
23 ],
24 },
25 {
26 heading: "Navigate",
27 items: [
28 { id: "dashboard", label: "Dashboard", description: "Workspace overview", icon: <IconDeviceDesktop /> },
29 { id: "customers", label: "Customers", description: "Accounts, segments, and notes", icon: <IconUser /> },
30 { id: "files", label: "Files", description: "Contracts and shared assets", icon: <IconFolder /> },
31 ],
32 },
33 {
34 heading: "Actions",
35 items: [
36 { id: "new-file", label: "Create file", icon: <IconPlus />, shortcut: ["⌘", "N"] },
37 { id: "invite", label: "Invite teammate", icon: <IconArrowRight />, shortcut: ["⌘", "I"] },
38 { id: "search", label: "Search everywhere", icon: <IconSearch />, shortcut: ["⌘", "K"] },
39 ],
40 },
41 {
42 heading: "Preferences",
43 items: [
44 {
45 id: "theme",
46 label: "Theme",
47 description: "Light, dark, or system",
48 icon: <IconPalette />,
49 pageTitle: "Theme",
50 items: [
51 {
52 items: [
53 { id: "theme-light", label: "Light", icon: <IconSun /> },
54 { id: "theme-dark", label: "Dark", icon: <IconMoon /> },
55 { id: "theme-system", label: "System", icon: <IconDeviceDesktop /> },
56 ],
57 },
58 ],
59 },
60 { id: "settings", label: "Workspace settings", icon: <IconSettings />, shortcut: ["⌘", ","] },
61 ],
62 },
63];
64
65export function CommandInDialog() {
66 const [open, setOpen] = useState(false);
67
68 return (
69 <CommandDialog
70 open={open}
71 onOpenChange={setOpen}
72 groups={groups}
73 shortcut={{ key: "k", meta: true }}
74 trigger={
75 <button
76 type="button"
77 className="inline-flex h-9 items-center gap-2 rounded-lg border border-[var(--border)] px-3 text-[13px] text-[var(--muted-foreground)] transition-colors duration-100 ease-out hover:bg-[color-mix(in_srgb,var(--foreground)_4%,var(--background))] hover:text-[var(--foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color-mix(in_srgb,var(--foreground)_18%,transparent)]"
78 >
79 <IconSearch stroke={1.75} className="size-4" />
80 Search...
81 </button>
82 }
83 />
84 );
85}