-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
318 additions
and
139 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
import { FC } from 'react'; | ||
import { DialogTitle, Root } from '@radix-ui/react-dialog'; | ||
|
||
import { | ||
CommandDialog, | ||
Command as CommandBase, | ||
CommandGroup, | ||
CommandItem, | ||
CommandSeparator, | ||
DialogContent, | ||
} from './components'; | ||
import { CommandProps } from './Command.types'; | ||
import { CommandProvider } from './contexts/Command.provider'; | ||
import { VisuallyHidden } from '@radix-ui/react-visually-hidden'; | ||
|
||
const Command: FC<CommandProps> = ({ children, ...props }) => ( | ||
<CommandProvider> | ||
<CommandDialog {...props}>{children}</CommandDialog> | ||
</CommandProvider> | ||
<Root {...props}> | ||
<DialogContent className="overflow-hidden p-0"> | ||
<DialogTitle className="hidden"> | ||
<VisuallyHidden>Test</VisuallyHidden> | ||
</DialogTitle> | ||
|
||
<CommandBase className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[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]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"> | ||
{children} | ||
</CommandBase> | ||
</DialogContent> | ||
</Root> | ||
); | ||
|
||
export { Command, CommandGroup, CommandItem, CommandSeparator }; |
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
76 changes: 0 additions & 76 deletions
76
lib/components/Command/components/CommandDialog/CommandDialog.tsx
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
lib/components/Command/components/CommandDialog/CommandDialog.types.ts
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
lib/components/Command/components/CommandDialog/CommandDialog.variants.ts
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from 'react'; | ||
import { Close, Content, DialogPortal } from '@radix-ui/react-dialog'; | ||
import { X } from 'react-feather'; | ||
|
||
import { cn } from '../../../utils'; | ||
|
||
import { DialogOverlay } from './DialogOverlay'; | ||
|
||
const DialogContent = forwardRef< | ||
ComponentRef<typeof Content>, | ||
ComponentPropsWithoutRef<typeof Content> | ||
>(({ className, children, ...props }, ref) => ( | ||
<DialogPortal> | ||
<DialogOverlay /> | ||
|
||
<Content | ||
ref={ref} | ||
className={cn( | ||
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg', | ||
className, | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
|
||
<Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"> | ||
<X className="h-4 w-4" /> | ||
<span className="sr-only">Close</span> | ||
</Close> | ||
</Content> | ||
</DialogPortal> | ||
)); | ||
|
||
DialogContent.displayName = Content.displayName; | ||
|
||
export { DialogContent }; |
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,22 @@ | ||
import { ComponentRef, forwardRef } from 'react'; | ||
import { Overlay } from '@radix-ui/react-dialog'; | ||
|
||
import { cn } from '../../../utils'; | ||
|
||
const DialogOverlay = forwardRef< | ||
ComponentRef<typeof Overlay>, | ||
React.ComponentPropsWithoutRef<typeof Overlay> | ||
>(({ className, ...props }, ref) => ( | ||
<Overlay | ||
ref={ref} | ||
className={cn( | ||
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0', | ||
className, | ||
)} | ||
{...props} | ||
/> | ||
)); | ||
|
||
DialogOverlay.displayName = Overlay.displayName; | ||
|
||
export { DialogOverlay }; |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
export * from './CommandDialog/CommandDialog'; | ||
export * from './CommandEmpty'; | ||
export * from './CommandGroup'; | ||
export * from './CommandInput'; | ||
export * from './CommandItem'; | ||
export * from './CommandList'; | ||
export * from './CommandSeparator'; | ||
export * from './CommandShortcut'; | ||
export * from './DialogContent'; | ||
export * from './Command'; |
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,3 @@ | ||
export * from './Command.context'; | ||
export * from './Command.provider'; | ||
export * from './Command.types'; |
Oops, something went wrong.