-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathcommand.tsx
More file actions
91 lines (83 loc) · 2.3 KB
/
Copy pathcommand.tsx
File metadata and controls
91 lines (83 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'use client';
import { Command as CommandPrimitive } from 'cmdk';
import { SearchIcon } from 'lucide-react';
import * as React from 'react';
import { cn } from '@/lib/utils';
function Command({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive>) {
return (
<CommandPrimitive
data-slot='command'
className={cn(
'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
className
)}
{...props}
/>
);
}
function CommandInput({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
return (
<div
data-slot='command-input-wrapper'
className='flex h-10 items-center gap-2 border-b border-[#2e3a38] px-3'
>
<SearchIcon className='size-4 shrink-0 text-muted-foreground' />
<CommandPrimitive.Input
data-slot='command-input'
className={cn(
'flex h-10 w-full bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
className
)}
{...props}
/>
</div>
);
}
function CommandList({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.List>) {
return (
<CommandPrimitive.List
data-slot='command-list'
className={cn(
'max-h-[260px] scroll-py-1 overflow-x-hidden overflow-y-auto',
className
)}
{...props}
/>
);
}
function CommandEmpty(
props: React.ComponentProps<typeof CommandPrimitive.Empty>
) {
return (
<CommandPrimitive.Empty
data-slot='command-empty'
className='py-6 text-center text-sm text-muted-foreground'
{...props}
/>
);
}
function CommandItem({
className,
...props
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
return (
<CommandPrimitive.Item
data-slot='command-item'
className={cn(
"relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-2 text-sm outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-foreground/8 data-[selected=true]:text-foreground [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
/>
);
}
export { Command, CommandEmpty, CommandInput, CommandItem, CommandList };