Skip to content

Commit 902b0cf

Browse files
committed
make copy somewhat working
1 parent 5cc4359 commit 902b0cf

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

apps/postgres-new/components/code-block.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import { useTheme } from 'next-themes'
1010
import { Children, ReactNode, useState } from 'react'
1111
import { Light as SyntaxHighlighter, SyntaxHighlighterProps } from 'react-syntax-highlighter'
12+
import { Copy } from 'lucide-react'
1213

1314
import curl from 'highlightjs-curl'
1415
import bash from 'react-syntax-highlighter/dist/cjs/languages/hljs/bash'
@@ -23,6 +24,7 @@ import sql from 'react-syntax-highlighter/dist/cjs/languages/hljs/sql'
2324
import ts from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript'
2425

2526
import { cn } from '~/lib/utils'
27+
import { Button } from './ui/button'
2628

2729
export interface CodeBlockProps {
2830
title?: ReactNode
@@ -69,6 +71,7 @@ export const CodeBlock = ({
6971

7072
const handleCopy = () => {
7173
setCopied(true)
74+
navigator.clipboard.writeText(value ?? '')
7275
setTimeout(() => {
7376
setCopied(false)
7477
}, 1000)
@@ -168,11 +171,24 @@ export const CodeBlock = ({
168171
{!hideCopy && (value || children) && className ? (
169172
<div
170173
className={[
171-
'absolute right-2 top-2',
174+
'absolute right-1 top-1',
172175
'opacity-0 group-hover:opacity-100 transition',
173176
`${isDarkTheme ? 'dark' : ''}`,
174177
].join(' ')}
175-
></div>
178+
>
179+
<Button
180+
onClick={handleCopy}
181+
data-size="tiny"
182+
type="button"
183+
variant="outline"
184+
className="relative"
185+
>
186+
<div className="text-foreground-muted">
187+
<Copy size={14} />
188+
</div>{' '}
189+
<span className="truncate">Copy</span>
190+
</Button>
191+
</div>
176192
) : null}
177193
</div>
178194
) : (

apps/postgres-new/components/sidebar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ function DeployDialog(
448448
>
449449
{psqlCommand}
450450
</CodeBlock>
451+
<p>Please write down your password, it will not be shown again.</p>
451452
</DialogContent>
452453
</DialogPortal>
453454
</Dialog>

0 commit comments

Comments
 (0)