| 11 | } |
| 12 | |
| 13 | export function CopyIconButton({ |
| 14 | text, |
| 15 | tabIndex, |
| 16 | checkIconClassName = "h-4 w-4 text-green-400", |
| 17 | clipboardIconClassName = "h-4 w-4 text-gray-400", |
| 18 | tooltipPlacement = "bottom", |
| 19 | }: CopyIconButtonProps) { |
| 20 | const { copyText, copied } = useCopy(text); |
| 21 | |
| 22 | return ( |
| 23 | <> |
| 24 | <HeaderButtonWithToolTip |
| 25 | tooltipPlacement={tooltipPlacement} |
| 26 | tabIndex={tabIndex} |
| 27 | text={copied ? "Copied" : "Copy"} |
| 28 | onClick={copyText} |
| 29 | > |
| 30 | {copied ? ( |
| 31 | <CheckIcon className={checkIconClassName} /> |
| 32 | ) : ( |
| 33 | <ClipboardIcon className={clipboardIconClassName} /> |
| 34 | )} |
| 35 | </HeaderButtonWithToolTip> |
| 36 | </> |
| 37 | ); |
| 38 | } |