import classnames from "classnames" ; import { CopyStatus , useClipboard } from "../hooks/useClipboard" ; interface CopyButtonProps { text : string ; children : React . ReactNode ; } export default function CopyButton ( { text , children } ) { const { copy , status } = useClipboard ( text ) ; let value = children ; if ( status === CopyStatus . SUCCESS ) { value = "Copied!" ; } else if ( status === CopyStatus . ERROR ) { value = "Copy failed :(" ; } const classes = classnames ( "clipboard" , { clipboard_notification : status !== CopyStatus . INACTIVE , } ) ; return ( < button type = "button" className = { classes } onClick = { ( ) => copy ( ) } > { value } < /button>); }