-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d4ea1c
commit 55cf33e
Showing
33 changed files
with
655 additions
and
878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
'use client' | ||
import { Command as CommandPrimitive } from 'cmdk' | ||
import { MagnifyingGlass } from 'phosphor-react' | ||
import { ComponentPropsWithoutRef, ElementRef, forwardRef, HTMLAttributes } from 'react' | ||
import { Modal, ModalContent, ModalProps } from '../../src' | ||
import { cn } from '../../src/utils/cn' | ||
|
||
const Command = forwardRef<ElementRef<typeof CommandPrimitive>, ComponentPropsWithoutRef<typeof CommandPrimitive>>( | ||
({ className, ...props }, ref) => ( | ||
<CommandPrimitive | ||
ref={ref} | ||
className={cn('mx-auto flex flex-col overflow-hidden outline-none ', className)} | ||
{...props} | ||
/> | ||
), | ||
) | ||
Command.displayName = CommandPrimitive.displayName | ||
|
||
interface CommandDialogProps extends ModalProps {} | ||
|
||
const CommandDialog = ({ children, ...props }: CommandDialogProps) => { | ||
return ( | ||
<Modal {...props}> | ||
<ModalContent className="max-w-[35rem] overflow-hidden rounded-xl bg-white p-5 text-metal-600 shadow-xLarge dark:bg-metal-900 dark:text-white"> | ||
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-metal-600 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:p-2 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4"> | ||
{children} | ||
</Command> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
} | ||
|
||
const CommandInput = forwardRef< | ||
ElementRef<typeof CommandPrimitive.Input>, | ||
ComponentPropsWithoutRef<typeof CommandPrimitive.Input> | ||
>(({ className, ...props }, ref) => ( | ||
<div className="flex items-center border-b border-b-metal-100 px-3 dark:border-b-metal-800" cmdk-input-wrapper=""> | ||
<MagnifyingGlass className="mr-2 h-4 w-4 shrink-0 opacity-50" /> | ||
<CommandPrimitive.Input | ||
ref={ref} | ||
className={cn( | ||
'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-metal-400 disabled:cursor-not-allowed disabled:opacity-50 dark:placeholder:text-metal-600', | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
</div> | ||
)) | ||
|
||
CommandInput.displayName = CommandPrimitive.Input.displayName | ||
|
||
const CommandList = forwardRef< | ||
ElementRef<typeof CommandPrimitive.List>, | ||
ComponentPropsWithoutRef<typeof CommandPrimitive.List> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.List | ||
ref={ref} | ||
id="search" | ||
className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)} | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandList.displayName = CommandPrimitive.List.displayName | ||
|
||
const CommandEmpty = forwardRef< | ||
ElementRef<typeof CommandPrimitive.Empty>, | ||
ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> | ||
>((props, ref) => <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-body-4" {...props} />) | ||
|
||
CommandEmpty.displayName = CommandPrimitive.Empty.displayName | ||
|
||
const CommandGroup = forwardRef< | ||
ElementRef<typeof CommandPrimitive.Group>, | ||
ComponentPropsWithoutRef<typeof CommandPrimitive.Group> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.Group | ||
ref={ref} | ||
className={cn( | ||
'overflow-hidden p-1 text-metal-600 dark:text-white [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-body-5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-metal-400 dark:[&_[cmdk-group-heading]]:text-white/50', | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandGroup.displayName = CommandPrimitive.Group.displayName | ||
|
||
const CommandSeparator = forwardRef< | ||
ElementRef<typeof CommandPrimitive.Separator>, | ||
ComponentPropsWithoutRef<typeof CommandPrimitive.Separator> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.Separator | ||
ref={ref} | ||
className={cn('-mx-1 h-px bg-metal-25 dark:bg-metal-800', className)} | ||
{...props} | ||
/> | ||
)) | ||
CommandSeparator.displayName = CommandPrimitive.Separator.displayName | ||
|
||
const CommandItem = forwardRef< | ||
ElementRef<typeof CommandPrimitive.Item>, | ||
ComponentPropsWithoutRef<typeof CommandPrimitive.Item> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
"relative flex cursor-default select-none items-center gap-2 rounded-md text-body-4 outline-none transition-all duration-200 data-[disabled=true]:pointer-events-none data-[selected=true]:bg-metal-50 data-[selected=true]:text-metal-900 data-[disabled=true]:opacity-50 dark:data-[selected='true']:bg-metal-800 dark:data-[selected=true]:text-white", | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandItem.displayName = CommandPrimitive.Item.displayName | ||
|
||
const CommandShortcut = ({ className, ...props }: HTMLAttributes<HTMLSpanElement>) => { | ||
return <span className={cn('ml-auto text-body-5 text-metal-400', className)} {...props} /> | ||
} | ||
CommandShortcut.displayName = 'CommandShortcut' | ||
|
||
export { | ||
Command, | ||
CommandDialog, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandInput, | ||
CommandItem, | ||
CommandList, | ||
CommandSeparator, | ||
CommandShortcut, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.