docs: fix code block's usage of z-index (#5238)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2023-09-27 18:48:18 +03:00
1 parent 6942a907a5
commit f5a698ad6f
3 files changed
+13 -3

No files matched your search

@@ -27,7 +27,6 @@ export const CodeBlock = ({
className={clsx( className={clsx(
"bg-medusa-code-bg-base relative mb-docs_1 rounded-docs_DEFAULT", "bg-medusa-code-bg-base relative mb-docs_1 rounded-docs_DEFAULT",
"border-medusa-code-border w-full max-w-full border", "border-medusa-code-border w-full max-w-full border",
"xs:after:content-[''] xs:after:rounded xs:after:absolute xs:after:right-0 xs:after:top-0 xs:after:w-[calc(10%+24px)] xs:after:h-full xs:after:bg-code-fade",
collapsed && "max-h-[400px] overflow-auto", collapsed && "max-h-[400px] overflow-auto",
className className
)} )}
@@ -97,12 +96,19 @@ export const CodeBlock = ({
</pre> </pre>
<div <div
className={clsx( className={clsx(
"absolute z-[1] hidden gap-docs_1 md:flex", "absolute hidden gap-docs_1 md:flex",
"xs:rounded xs:absolute xs:right-0 xs:top-0 xs:w-[calc(10%+24px)] xs:h-full xs:bg-code-fade"
)}
>
<CopyButton
text={source}
tooltipClassName="font-base"
className={clsx(
"absolute",
tokens.length === 1 && "right-docs_0.75 top-[10px]", tokens.length === 1 && "right-docs_0.75 top-[10px]",
tokens.length > 1 && "right-docs_1 top-docs_1" tokens.length > 1 && "right-docs_1 top-docs_1"
)} )}
> >
<CopyButton text={source} tooltipClassName="font-base">
<SquareTwoStackSolid className="text-medusa-code-icon" /> <SquareTwoStackSolid className="text-medusa-code-icon" />
</CopyButton> </CopyButton>
</div> </div>
@@ -16,6 +16,7 @@ export const CopyButton = ({
buttonClassName = "", buttonClassName = "",
tooltipClassName = "", tooltipClassName = "",
children, children,
className,
}: CopyButtonProps) => { }: CopyButtonProps) => {
const [isCopied, setIsCopied] = useState(false) const [isCopied, setIsCopied] = useState(false)
const copyTimeout = useRef<number>(0) const copyTimeout = useRef<number>(0)
@@ -34,6 +35,7 @@ export const CopyButton = ({
<Tooltip <Tooltip
text={isCopied ? `Copied!` : `Copy to Clipboard`} text={isCopied ? `Copied!` : `Copy to Clipboard`}
tooltipClassName={tooltipClassName} tooltipClassName={tooltipClassName}
className={className}
> >
<span <span
className={clsx("cursor-pointer", buttonClassName)} className={clsx("cursor-pointer", buttonClassName)}
@@ -21,6 +21,7 @@ export const Tooltip = ({
children, children,
html = "", html = "",
tooltipChildren, tooltipChildren,
className,
...tooltipProps ...tooltipProps
}: TooltipProps) => { }: TooltipProps) => {
const [elementId, setElementId] = useState<string>("") const [elementId, setElementId] = useState<string>("")
@@ -38,6 +39,7 @@ export const Tooltip = ({
data-tooltip-content={text} data-tooltip-content={text}
data-tooltip-html={html} data-tooltip-html={html}
data-tooltip-id={elementId} data-tooltip-id={elementId}
className={className}
> >
{children} {children}
</span> </span>