Skip to content

Commit a697192

Browse files
committed
add visual feedback to copy button
1 parent 53a5bfd commit a697192

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/lib/components/CopyToClipBoardBtn.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { onDestroy } from "svelte";
33
44
import CarbonCopy from "~icons/carbon/copy";
5+
import CarbonCheckmark from "~icons/carbon/checkmark";
56
import Tooltip from "./Tooltip.svelte";
67
78
interface Props {
@@ -67,6 +68,8 @@
6768
clearTimeout(timeout);
6869
}
6970
});
71+
72+
const Icon = $derived(isSuccess ? CarbonCheckmark : CarbonCopy);
7073
</script>
7174

7275
<button
@@ -79,8 +82,10 @@
7982
}}
8083
>
8184
<div class="relative">
82-
{#if children}{@render children()}{:else}
83-
<CarbonCopy class={iconClassNames} />
85+
{#if children}
86+
{@render children()}
87+
{:else}
88+
<Icon class={iconClassNames} />
8489
{/if}
8590

8691
{#if showTooltip}

0 commit comments

Comments
 (0)