mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 22:29:11 +03:00
* use our own tree view * fix padidng * updated styles --------- Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
30 lines
705 B
TypeScript
30 lines
705 B
TypeScript
'use client'
|
|
|
|
import { Check, Copy } from 'lucide-react'
|
|
import { useEffect, useState } from 'react'
|
|
import { Button_Shadcn_ } from 'ui'
|
|
|
|
export function CommandCopyButton({ command }: { command: string }) {
|
|
const [copied, setCopied] = useState(false)
|
|
|
|
useEffect(() => {
|
|
if (copied) {
|
|
const timeout = setTimeout(() => setCopied(false), 2000)
|
|
return () => clearTimeout(timeout)
|
|
}
|
|
}, [copied])
|
|
|
|
return (
|
|
<Button_Shadcn_
|
|
variant="ghost"
|
|
size="icon"
|
|
onClick={() => {
|
|
navigator.clipboard.writeText(command)
|
|
setCopied(true)
|
|
}}
|
|
>
|
|
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
|
|
</Button_Shadcn_>
|
|
)
|
|
}
|