Skip to content

Commit 57eed8f

Browse files
committed
fix: add className prop to CopyButton for consistent styling in JsonBlock
1 parent c5b59e1 commit 57eed8f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/components/CopyButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ const CopyButton = ({
1212
displayText,
1313
buttonText,
1414
tooltipWithText = false,
15+
className,
1516
}: {
1617
textToCopy: string;
1718
displayText?: string;
1819
buttonText?: string;
1920
tooltipWithText?: boolean;
21+
className?: string;
2022
}) => {
2123
const [showTooltip, setShowTooltip] = useState(false);
2224
const [tooltipMessage, setTooltipMessage] = useState('Copy');
@@ -45,7 +47,7 @@ const CopyButton = ({
4547
return (
4648
<TooltipProvider delayDuration={0}>
4749
<Tooltip open={showTooltip}>
48-
<TooltipTrigger asChild>
50+
<TooltipTrigger asChild className={className}>
4951
<span className="box-content flex max-w-full items-center gap-1">
5052
{displayText && (
5153
<span className="overflow-hidden overflow-ellipsis">

src/modules/JsonBlock.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const JsonBlock = ({
3939
}
4040

4141
return (
42-
<div className={`flex min-w-0 items-start gap-1 ${className}`}>
42+
<div className={`relative flex min-w-0 items-start gap-1 ${className}`}>
4343
<div className="min-w-0 flex-1 overflow-x-auto">
4444
<JsonView
4545
value={jsonData}
@@ -52,7 +52,11 @@ const JsonBlock = ({
5252
/>
5353
</div>
5454
{enableClipboard && (
55-
<CopyButton buttonText="Copy Json" textToCopy={rawToCopy} />
55+
<CopyButton
56+
className="absolute top-0 right-0"
57+
buttonText="Copy Json"
58+
textToCopy={rawToCopy}
59+
/>
5660
)}
5761
</div>
5862
);

0 commit comments

Comments
 (0)