12 lines
370 B
TypeScript
12 lines
370 B
TypeScript
import type { Renderable } from 'react-hot-toast'
|
|
import { toast } from 'react-hot-toast'
|
|
|
|
export async function copy(text: string, message: Renderable = 'Copied to clipboard!') {
|
|
try {
|
|
await navigator.clipboard.writeText(text)
|
|
return toast.success(message)
|
|
} catch (err: unknown) {
|
|
return toast.error(String(err), { style: { maxWidth: 'none' } })
|
|
}
|
|
}
|