mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
refactor(code-snippet): pass required text
prop to CopyButton
(#1372)
This also passes the `copy` prop to `CopyButton` instead of wrapping it in another function.
This commit is contained in:
parent
6a3614bf55
commit
d5d6294b02
1 changed files with 5 additions and 7 deletions
|
@ -110,11 +110,6 @@
|
||||||
if (height > 0) showMoreLess = ref.getBoundingClientRect().height > 255;
|
if (height > 0) showMoreLess = ref.getBoundingClientRect().height > 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyCode() {
|
|
||||||
copy(code);
|
|
||||||
dispatch("copy");
|
|
||||||
}
|
|
||||||
|
|
||||||
$: expandText = expanded ? showLessText : showMoreText;
|
$: expandText = expanded ? showLessText : showMoreText;
|
||||||
$: minHeight = expanded ? 16 * 15 : 48;
|
$: minHeight = expanded ? 16 * 15 : 48;
|
||||||
$: maxHeight = expanded ? "none" : 16 * 15 + "px";
|
$: maxHeight = expanded ? "none" : 16 * 15 + "px";
|
||||||
|
@ -174,7 +169,8 @@
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
on:click="{() => {
|
on:click="{() => {
|
||||||
copyCode();
|
copy(code);
|
||||||
|
dispatch('copy');
|
||||||
if (animation === 'fade-in') return;
|
if (animation === 'fade-in') return;
|
||||||
animation = 'fade-in';
|
animation = 'fade-in';
|
||||||
timeout = setTimeout(() => {
|
timeout = setTimeout(() => {
|
||||||
|
@ -229,12 +225,14 @@
|
||||||
</div>
|
</div>
|
||||||
{#if !hideCopyButton}
|
{#if !hideCopyButton}
|
||||||
<CopyButton
|
<CopyButton
|
||||||
|
text="{code}"
|
||||||
|
copy="{copy}"
|
||||||
disabled="{disabled}"
|
disabled="{disabled}"
|
||||||
feedback="{feedback}"
|
feedback="{feedback}"
|
||||||
feedbackTimeout="{feedbackTimeout}"
|
feedbackTimeout="{feedbackTimeout}"
|
||||||
iconDescription="{copyButtonDescription}"
|
iconDescription="{copyButtonDescription}"
|
||||||
on:click
|
on:click
|
||||||
on:click="{copyCode}"
|
on:copy
|
||||||
on:animationend
|
on:animationend
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue