0.5.3 • Published 2 years ago

svelte-copyable v0.5.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Svelte Copyable

An easy to use Svelte action to copy text.

Using the Action

  <script>
    import { copyable } from "svelte-copyable";
    
    const couponCode = "ABC";
  </script>
  
  <div use:copyable={couponCode}>
    Copy coupon code
  </div>

Using the Action with a Callback Event

<script>
  import { copyable } from "svelte-copyable";

  const couponCode = "ABC";
  let showCopiedAlert = false;

  function toggleCopiedAlert() {
    if (showCopiedAlert) return;

    showCopiedAlert = !showCopiedAlert;

    setTimeout(() => {
      showCopiedAlert = false;
    }, 1000);
  }
</script>

<div>
  <div use:copyable={couponCode} on:textCopied={() => toggleCopiedAlert()}>
    Copy coupon code
  </div>

  {#if showCopiedAlert}
    <p>Copied</p>
  {/if}
</div>
0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago