|
1
|
"use client" |
|
2
|
|
|
3
|
import React from "react" |
|
4
|
import clsx from "clsx" |
|
5
|
import { CopyButton } from "@/components/CopyButton" |
|
6
|
|
|
7
|
export type InlineCodeProps = React.ComponentProps<"code"> & { |
|
8
|
variant?: "default" | "grey-bg" |
|
9
|
} |
|
10
|
|
|
11
|
export const InlineCode = ({ |
|
12
|
variant = "default", |
|
13
|
...props |
|
14
|
}: InlineCodeProps) => { |
|
15
|
return ( |
|
16
|
<CopyButton |
|
17
|
text={props.children as string} |
|
18
|
buttonClassName={clsx( |
|
19
|
"bg-transparent border-0 p-0 inline text-medusa-fg-subtle group", |
|
20
|
"font-monospace" |
|
21
|
)} |
|
22
|
> |
|
23
|
<code |
|
24
|
{...props} |
|
25
|
className={clsx( |
|
26
|
"text-medusa-tag-neutral-text border whitespace-break-spaces", |
|
27
|
"font-monospace text-code-label rounded-docs_sm py-0 px-[5px]", |
|
28
|
variant === "default" && [ |
|
29
|
"bg-medusa-tag-neutral-bg group-hover:bg-medusa-tag-neutral-bg-hover", |
|
30
|
"group-active:bg-medusa-bg-subtle-pressed group-focus:bg-medusa-bg-subtle-pressed", |
|
31
|
"border-medusa-tag-neutral-border", |
|
32
|
], |
|
33
|
variant === "grey-bg" && [ |
|
34
|
"bg-medusa-bg-switch-off group-hover:bg-medusa-bg-switch-off-hover", |
|
35
|
"group-active:bg-medusa-bg-switch-off-hover group-focus:bg-medusa-switch-off-hover", |
|
36
|
"border-medusa-border-strong", |
|
37
|
], |
|
38
|
props.className |
|
39
|
)} |
|
40
|
/> |
|
41
|
</CopyButton> |
|
42
|
) |
|
43
|
} |