Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

60 linesCodeBlameRaw
1import { Command as Cmdk } from "cmdk";
2import { Search } from "lucide-react";
3import type { ComponentProps } from "react";
4
5import { cn } from "../../lib/cn";
6
7// shadcn/ui's command menu (cmdk), styled with g1t's tokens: a searchable list
8// for the palette and the combobox. The combobox in ./combobox wraps it in
9// a popover.
10
11export function Command({ className, ...props }: ComponentProps<typeof Cmdk>) {
12 return <Cmdk className={cn("flex w-full flex-col overflow-hidden text-sm text-fg", className)} {...props} />;
13}
14
15export function CommandInput({ className, ...props }: ComponentProps<typeof Cmdk.Input>) {
16 return (
17 <div className="flex items-center gap-2 border-b border-line px-3" cmdk-input-wrapper="">
18 <Search size={14} className="shrink-0 text-faint" />
19 <Cmdk.Input className={cn("h-10 w-full bg-transparent text-sm outline-none placeholder:text-faint focus-visible:outline-none", className)} {...props} />
20 </div>
21 );
22}
23
24export function CommandList({ className, ...props }: ComponentProps<typeof Cmdk.List>) {
25 return <Cmdk.List className={cn("max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto p-1", className)} {...props} />;
26}
27
28export function CommandEmpty({ className, ...props }: ComponentProps<typeof Cmdk.Empty>) {
29 return <Cmdk.Empty className={cn("py-6 text-center text-sm text-faint", className)} {...props} />;
30}
31
32export function CommandGroup({ className, ...props }: ComponentProps<typeof Cmdk.Group>) {
33 return (
34 <Cmdk.Group
35 className={cn(
36 "**:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:pt-2 **:[[cmdk-group-heading]]:pb-1 **:[[cmdk-group-heading]]:text-[0.6875rem] **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:tracking-wide **:[[cmdk-group-heading]]:text-faint **:[[cmdk-group-heading]]:uppercase",
37 className,
38 )}
39 {...props}
40 />
41 );
42}
43
44export function CommandSeparator({ className, ...props }: ComponentProps<typeof Cmdk.Separator>) {
45 return <Cmdk.Separator className={cn("-mx-1 my-1 h-px bg-line", className)} {...props} />;
46}
47
48export function CommandItem({ className, ...props }: ComponentProps<typeof Cmdk.Item>) {
49 return (
50 <Cmdk.Item
51 className={cn(
52 "relative flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-fg/90 outline-none select-none",
53 "data-[selected=true]:bg-line data-[selected=true]:text-fg data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-45",
54 "[&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted",
55 className,
56 )}
57 {...props}
58 />
59 );
60}