Skip to content

Commit a85f7e9

Browse files
stanchclaude
andauthored
Add a more prominent button to copy JSON (#186)
🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 152b17a commit a85f7e9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ui/src/components/CopyButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { Button } from '@/components/ui/button'
44

55
type CopyButtonProps = {
66
value: any
7+
alwaysVisible?: boolean
78
}
89

9-
export function CopyButton({ value }: CopyButtonProps) {
10+
export function CopyButton({ value, alwaysVisible = false }: CopyButtonProps) {
1011
const [copied, setCopied] = useState(false)
1112

1213
const handleCopy = () => {
@@ -20,7 +21,7 @@ export function CopyButton({ value }: CopyButtonProps) {
2021
variant="ghost"
2122
size="sm"
2223
onClick={handleCopy}
23-
className="h-4 w-4 p-0 opacity-0 group-hover:opacity-100 transition-opacity"
24+
className={`h-4 w-4 p-0 transition-opacity ${alwaysVisible ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'}`}
2425
title="Copy to clipboard"
2526
>
2627
{copied ? <Check className="h-3 w-3" /> : <Copy className="h-3 w-3" />}

ui/src/components/JsonSidePanel.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Button } from '@/components/ui/button'
44
import { JsonViewer } from '@/components/JsonViewer'
55
import { TooltipProvider } from '@/components/ui/tooltip'
66
import { TruncatedColumnName } from '@/components/TruncatedColumnName'
7+
import { CopyButton } from '@/components/CopyButton'
78
import { createColumnMetadata } from '@/utils/column-metadata'
89

910
const STORAGE_KEY = 'snowplow-micro-json-panel-width'
@@ -110,11 +111,14 @@ export function JsonSidePanel({
110111
{/* Header with title and close button */}
111112
<div className="bg-background">
112113
<div className="flex items-center justify-between">
113-
<TruncatedColumnName
114-
columnMetadata={createColumnMetadata(title)}
115-
iconSize="md"
116-
className="text-lg font-light truncate"
117-
/>
114+
<div className="flex items-center gap-2">
115+
<TruncatedColumnName
116+
columnMetadata={createColumnMetadata(title)}
117+
iconSize="md"
118+
className="text-lg font-light truncate"
119+
/>
120+
<CopyButton value={value} alwaysVisible />
121+
</div>
118122
<Button
119123
variant="ghost"
120124
size="sm"

0 commit comments

Comments
 (0)