npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-signature-pad

v0.0.2

Published

Svelte Action to capture smoothed signatures as SVG paths using the excellent [perfect-freehand](https://github.com/steveruizok/perfect-freehand) library.

Downloads

282

Readme

svelte-signature-pad

Svelte Action to capture smoothed signatures as SVG paths using the excellent perfect-freehand library.

Instructions

Install using you package manager of choice:

pnpm i svelte-signature-pad

Import action into page and pass and object with ondraw and oncomplete method properties.

Each will receive a path which can be rendered as SVG in your component. ondraw fires while the user is drawing and would be the current stroke. oncomplete fires when they have finished the line (which could transition to a different color).

Example

<script lang="ts">
  import { signature } from 'svelte-signature-pad'

  let layers: { path: string; width: number; height: number }[] = []

  let width: number
  let height: number
  let preview: string

  const ondraw = (path: string) => (preview = path)
  const oncomplete = (path: string) => {
    preview = ''
    layers = [...layers, { width, height, path }]
  }

  const clear = () => {
    layers = []
  }
</script>

<div class="relative w-full h-[360px] bg-gray-100 border border-dashed border-gray-300">
  <div class="absolute left-4 right-4 bottom-24 border-t border-dotted border-gray-300" />
  <div
    class="w-full h-full"
    use:signature={{ ondraw, oncomplete }}
    bind:clientWidth={width}
    bind:clientHeight={height}
    on:touchmove|preventDefault={() => false}
  >
    {#each layers as layer}
      <svg class="absolute w-full h-full fill-black pointer-events-none" viewBox="0 0 {layer.width} {layer.height}">
        <path d={layer.path} />
      </svg>
    {/each}

    {#if preview}
      <svg class="absolute w-full h-full fill-gray-900 pointer-events-none" viewBox="0 0 {width} {height}">
        <path d={preview} />
      </svg>
    {/if}
  </div>
  <button class="absolute top-2 right-2 px-4 py-2 text-sm text-gray-500 bg-white border border-gray-200" on:click={clear}>Clear</button>
</div>

<p class="mt-2 text-sm">Please sign on the dotted line to indicate that you agree to all the legal terms we all know you didn't read. Thank you!</p>

<div class="relative mt-4">
  {#each layers as layer}
    <svg class="absolute fill-black" viewBox="0 0 {layer.width * 2} {layer.height * 2}">
      <path d={layer.path} />
    </svg>
  {/each}
</div>