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

nonnysignature

v1.0.5

Published

signature capture built with love by coding-nonny and codad5: signture drawing, increase and decrease font size, color change, backgroundcolor change, undo and redo, clear and save.

Downloads

12

Readme

NonnySignature

NonnySignature is an easy-to-use JavaScript-based library that helps you manage user signatures in the front-end. It provides a flexible solution for both React and vanilla JavaScript projects.

Installation

This library can be installed using either NPM or CDN.

  • using NPM
npm i nonnysignature
  • using CDN
<script src="https://Coding-Nonny.github.io/NonnySignature/lib/NonnySignature.js"></script>

Importing NonnySignature

import NonnySignature from "nonnysignature";

Initialize your pad

To initialize NonnySignature, you need to provide the class of the parent div that will hold the signature pad. You can use our default template or your own.

  • HTML
<body>
    <div class="mypad"></div>
</body>
  • JAVASCRIPT
const signaturePad = new NonnySignature(".mypad", false);

Constructor Object

  • The first parameter is the class of the parent div that will hold the signature pad (in this case, .mypad).
  • The second parameter is a boolean that determines whether to use the default template (false) or your own (true).

Using Our React Component:

We have also provided a flexible React component that you can use in your React development.

import SignaturePad from 'nonnysignature/react'

export default function App(){
    <SignaturePad id="mypad"></SignaturePad>
}

React Component Props

  • The id prop sets the ID for the current signature pad (in this case, mypad).

Saving the Signature

To save the signature image, you first need to add a Save button using the .nonny-save-png class name for png, .nonny-save-svg class name for svg. You can either use our default template or your own.

  • HTML
<div class="mypad">
  <canvas width="400" height="200"></canvas>
  <button class="nonny-save-png">Save png</button>
  <button class="nonny-save-svg">Save svg</button>
</div>
  • REACT
<SignaturePad id="mypad">
  <canvas width="400" height="200"></canvas>
  <button className="nonny-save-png">Save png</button>
   <button className="nonny-save-svg">Save svg</button>
</SignaturePad>

Then, set the onSave method or props.

Setting The Method

  • You can use nonny-save-callback class name on a button to initialize the onSave method.
signaturePad.onSave((imageData) => console.log(imageData.toImage('png', 1)));

Setting Props

<SignaturePad id="mypad" onSave={(imageData) => console.log(imageData.toImage('png', 1))}>
  ...Your custom template
</SignaturePad>

Explaining the onSave Method

  • The onSave method takes a callback function as its parameter.
  • The callback function takes an ImageData object as its parameter.
  • The ImageData object has a few methods, including toImage(imageType, quality) and toSvg().
  • The toImage method takes two arguments: imageType (currently supported types are png, jpeg, and webp) and quality (a number between 0 and 1, with 0 being the poorest quality and 1 being the maximum quality).
  • The toSvg() method returns signature as svg.

Note: If you click the save button without using the onSave method, the canvas will be downloaded as an image.

Additionally, the library also provides the following functionalities:

| Name | Function | Class Name | | -------- | -------- | -------- | | Clear button: | The clear button is used to clear the canvas. You can add a clear button to the signature pad using the class name nonny-clear. | nonny-clear | | Size Up button: | This helps to increase the size of the canvas stroke. You can add a button to increase the size of the stroke using the class name nonny-sizeup. | nonny-sizeup | | Size Down button: | This helps to decrease the size of the canvas stroke. You can add a button to decrease the size of the stroke using the class name nonny-sizedown. | nonny-sizedown | | Undo button: | This removes strokes from the canvas until none is left, you can recover strokes using the redo button. You can add an undo button using the class name nonny-undo. | nonny-undo | | Redo button: | This retrieves strokes removed by the undo button. You can add a redo button using the class name nonny-redo. | nonny-redo | | Background color input: | You can add an input of type color to change the background color of the signature pad. The input should have the class name nonny-bgcolor and the default background color is white value="#FFFFFF". | nonny-bgcolor | | Stroke color input: | You can add an input of type color to change the stroke color of the signature pad. The input should have the class name nonny-color and default color is black value="#000000". | nonny-color |

  • In REACT

you can use the buttons like this

<SignaturePad id="mypad">
  <canvas width="400" height="200"></canvas>
  <button className="nonny-clear">clear</button>
  <input type="color" className="nonny-color" value="#000000">
</SignaturePad>

For working example, click here.

  • Or check the example for handling double signature client and management click here

If you encounter any issues or have any suggestions, please create an issue in the GitHub repository.