|
@@ -11,7 +11,8 @@ export function CopyButton(props: CopyButtonProps) {
|
|
|
|
|
|
|
|
function handleCopyClick() {
|
|
function handleCopyClick() {
|
|
|
if (props.text) {
|
|
if (props.text) {
|
|
|
- navigator.clipboard.writeText(props.text).catch((err) => console.error("Copy failed", err))
|
|
|
|
|
|
|
+ navigator.clipboard.writeText(props.text)
|
|
|
|
|
+ .catch((err) => console.error("Copy failed", err))
|
|
|
|
|
|
|
|
setCopied(true)
|
|
setCopied(true)
|
|
|
setTimeout(() => setCopied(false), 2000)
|
|
setTimeout(() => setCopied(false), 2000)
|
|
@@ -19,17 +20,17 @@ export function CopyButton(props: CopyButtonProps) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <div class={styles.copyButtonWrapper}>
|
|
|
|
|
|
|
+ <div data-component="copy-button" class={styles.root}>
|
|
|
<button
|
|
<button
|
|
|
type="button"
|
|
type="button"
|
|
|
- class={styles.copyButton}
|
|
|
|
|
onClick={handleCopyClick}
|
|
onClick={handleCopyClick}
|
|
|
data-copied={copied() ? true : undefined}
|
|
data-copied={copied() ? true : undefined}
|
|
|
- title="Copy content"
|
|
|
|
|
>
|
|
>
|
|
|
- {copied() ? <IconCheckCircle width={16} height={16} /> : <IconClipboard width={16} height={16} />}
|
|
|
|
|
|
|
+ {copied()
|
|
|
|
|
+ ? <IconCheckCircle width={16} height={16} />
|
|
|
|
|
+ : <IconClipboard width={16} height={16} />
|
|
|
|
|
+ }
|
|
|
</button>
|
|
</button>
|
|
|
- {copied() && <span class={styles.copyTooltip}>Copied!</span>}
|
|
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|