1 "use client"
2
3 import { Copy } from "@/components/copy"
4 import { clx } from "@/utils/clx"
5 import React from "react"
6
7 /**
8 * This component is based on the div element and supports all of its props
9 */
10 const CommandComponent = ({
11 className,
12 ...props
13 }: React.HTMLAttributes<HTMLDivElement>) => {
14 return (
15 <div
16 className={clx(
17 "bg-ui-contrast-bg-base shadow-elevation-code-block flex items-center rounded-lg px-4 py-1.5",
18 "[&>code]:text-ui-contrast-fg-primary [&>code]:code-body [&>code]:mx-2",
19 className
20 )}
21 {...props}
22 />
23 )
24 }
25 CommandComponent.displayName = "Command"
26
27 const CommandCopy = React.forwardRef<
28 React.ElementRef<typeof Copy>,
29 React.ComponentPropsWithoutRef<typeof Copy>
30 >(({ className, ...props }, ref) => {
31 return (
32 <Copy
33 {...props}
34 ref={ref}
35 className={clx("!text-ui-contrast-fg-secondary ml-auto", className)}
36 />
37 )
38 })
39 CommandCopy.displayName = "Command.Copy"
40
41 const Command = Object.assign(CommandComponent, { Copy: CommandCopy })
42
43 export { Command }