Skip to content

Commit d8f1842

Browse files
committed
fix(): Update command menu.
1 parent c0048ea commit d8f1842

File tree

2 files changed

+39
-42
lines changed

2 files changed

+39
-42
lines changed

src/shadcn/ui/command.tsx

+33-36
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
"use client";
1+
"use client"
22

3-
import { type DialogProps } from "@radix-ui/react-dialog";
4-
import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
5-
import { Command as CommandPrimitive } from "cmdk";
6-
import * as React from "react";
3+
import * as React from "react"
4+
import { type DialogProps } from "@radix-ui/react-dialog"
5+
import { Command as CommandPrimitive } from "cmdk"
6+
import { Search } from "lucide-react"
77

8-
import { cn } from "src/utils";
9-
import { Dialog, DialogContent } from "./dialog";
8+
import { cn } from "src"
9+
import { Dialog, DialogContent } from "src"
1010

1111
const Command = React.forwardRef<
1212
React.ElementRef<typeof CommandPrimitive>,
@@ -20,12 +20,10 @@ const Command = React.forwardRef<
2020
)}
2121
{...props}
2222
/>
23-
));
24-
Command.displayName = CommandPrimitive.displayName;
23+
))
24+
Command.displayName = CommandPrimitive.displayName
2525

26-
interface CommandDialogProps extends DialogProps {}
27-
28-
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
26+
const CommandDialog = ({ children, ...props }: DialogProps) => {
2927
return (
3028
<Dialog {...props}>
3129
<DialogContent className="overflow-hidden p-0">
@@ -34,15 +32,15 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
3432
</Command>
3533
</DialogContent>
3634
</Dialog>
37-
);
38-
};
35+
)
36+
}
3937

4038
const CommandInput = React.forwardRef<
4139
React.ElementRef<typeof CommandPrimitive.Input>,
4240
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
4341
>(({ className, ...props }, ref) => (
4442
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
45-
<MagnifyingGlassIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
43+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
4644
<CommandPrimitive.Input
4745
ref={ref}
4846
className={cn(
@@ -52,9 +50,9 @@ const CommandInput = React.forwardRef<
5250
{...props}
5351
/>
5452
</div>
55-
));
53+
))
5654

57-
CommandInput.displayName = CommandPrimitive.Input.displayName;
55+
CommandInput.displayName = CommandPrimitive.Input.displayName
5856

5957
const CommandList = React.forwardRef<
6058
React.ElementRef<typeof CommandPrimitive.List>,
@@ -65,9 +63,9 @@ const CommandList = React.forwardRef<
6563
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
6664
{...props}
6765
/>
68-
));
66+
))
6967

70-
CommandList.displayName = CommandPrimitive.List.displayName;
68+
CommandList.displayName = CommandPrimitive.List.displayName
7169

7270
const CommandEmpty = React.forwardRef<
7371
React.ElementRef<typeof CommandPrimitive.Empty>,
@@ -78,9 +76,9 @@ const CommandEmpty = React.forwardRef<
7876
className="py-6 text-center text-sm"
7977
{...props}
8078
/>
81-
));
79+
))
8280

83-
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
81+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName
8482

8583
const CommandGroup = React.forwardRef<
8684
React.ElementRef<typeof CommandPrimitive.Group>,
@@ -94,9 +92,9 @@ const CommandGroup = React.forwardRef<
9492
)}
9593
{...props}
9694
/>
97-
));
95+
))
9896

99-
CommandGroup.displayName = CommandPrimitive.Group.displayName;
97+
CommandGroup.displayName = CommandPrimitive.Group.displayName
10098

10199
const CommandSeparator = React.forwardRef<
102100
React.ElementRef<typeof CommandPrimitive.Separator>,
@@ -107,8 +105,8 @@ const CommandSeparator = React.forwardRef<
107105
className={cn("-mx-1 h-px bg-border", className)}
108106
{...props}
109107
/>
110-
));
111-
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
108+
))
109+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName
112110

113111
const CommandItem = React.forwardRef<
114112
React.ElementRef<typeof CommandPrimitive.Item>,
@@ -117,15 +115,14 @@ const CommandItem = React.forwardRef<
117115
<CommandPrimitive.Item
118116
ref={ref}
119117
className={cn(
120-
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50',
121-
props.disabled ? 'opacity-50 pointer-events-none' : '',
118+
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
122119
className
123120
)}
124121
{...props}
125122
/>
126-
));
123+
))
127124

128-
CommandItem.displayName = CommandPrimitive.Item.displayName;
125+
CommandItem.displayName = CommandPrimitive.Item.displayName
129126

130127
const CommandShortcut = ({
131128
className,
@@ -139,18 +136,18 @@ const CommandShortcut = ({
139136
)}
140137
{...props}
141138
/>
142-
);
143-
};
144-
CommandShortcut.displayName = "CommandShortcut";
139+
)
140+
}
141+
CommandShortcut.displayName = "CommandShortcut"
145142

146143
export {
147144
Command,
148145
CommandDialog,
146+
CommandInput,
147+
CommandList,
149148
CommandEmpty,
150149
CommandGroup,
151-
CommandInput,
152150
CommandItem,
153-
CommandList,
154-
CommandSeparator,
155151
CommandShortcut,
156-
};
152+
CommandSeparator,
153+
}

stories/shadcn/command.stories.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ const CommandDemo = () => {
2727
<CommandEmpty>No results found.</CommandEmpty>
2828
<CommandGroup heading="Suggestions">
2929
<CommandItem>
30-
<CalendarIcon className="mr-2 h-4 w-4" />
30+
<CalendarIcon />
3131
<span>Calendar</span>
3232
</CommandItem>
3333
<CommandItem>
34-
<FaceIcon className="mr-2 h-4 w-4" />
34+
<FaceIcon />
3535
<span>Search Emoji</span>
3636
</CommandItem>
3737
<CommandItem>
38-
<RocketIcon className="mr-2 h-4 w-4" />
38+
<RocketIcon />
3939
<span>Launch</span>
4040
</CommandItem>
4141
</CommandGroup>
4242
<CommandSeparator />
4343
<CommandGroup heading="Settings">
4444
<CommandItem disabled >
45-
<PersonIcon className="mr-2 h-4 w-4" />
45+
<PersonIcon />
4646
<span>Profile</span>
4747
<CommandShortcut>⌘P</CommandShortcut>
4848
</CommandItem>
4949
<CommandItem>
50-
<EnvelopeClosedIcon className="mr-2 h-4 w-4" />
50+
<EnvelopeClosedIcon />
5151
<span>Mail</span>
5252
<CommandShortcut>⌘B</CommandShortcut>
5353
</CommandItem>
5454
<CommandItem>
55-
<GearIcon className="mr-2 h-4 w-4" />
55+
<GearIcon />
5656
<span>Settings</span>
5757
<CommandShortcut>⌘S</CommandShortcut>
5858
</CommandItem>

0 commit comments

Comments
 (0)