From 0b51b14246bf5013edd309ad770ba28bb0d061b6 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 25 Jun 2022 16:20:53 -0700 Subject: [PATCH] refactor(code-snippet): forward text/copy props to CopyButton --- src/CodeSnippet/CodeSnippet.svelte | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/CodeSnippet/CodeSnippet.svelte b/src/CodeSnippet/CodeSnippet.svelte index 82eb63a3..a4b0cce3 100644 --- a/src/CodeSnippet/CodeSnippet.svelte +++ b/src/CodeSnippet/CodeSnippet.svelte @@ -110,11 +110,6 @@ if (height > 0) showMoreLess = ref.getBoundingClientRect().height > 255; } - function copyCode() { - copy(code); - dispatch("copy"); - } - $: expandText = expanded ? showLessText : showMoreText; $: minHeight = expanded ? 16 * 15 : 48; $: maxHeight = expanded ? "none" : 16 * 15 + "px"; @@ -174,7 +169,8 @@ {...$$restProps} on:click on:click="{() => { - copyCode(); + copy(code); + dispatch('copy'); if (animation === 'fade-in') return; animation = 'fade-in'; timeout = setTimeout(() => { @@ -229,12 +225,14 @@ {#if !hideCopyButton} {/if}