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

vue-paintable

v2.1.5

Published

Draw on any screen

Downloads

143

Readme

vue-paintable npm

With this vue plugin and component you can add a paintable canvas through your page. All paintings are saved by default into localStorage.

How to use?

npm install vue-paintable

or

yarn add vue-paintable

Inside your main (typically main.js)

import Vue from 'vue';
import Paintable from 'vue-paintable';

Vue.use(Paintable, {
  // optional methods
  setItem(key, image) {
    localStorage.setItem(key, image);
  },
  // you also can use async
  getItem(key) {
    return localStorage.getItem(key);
  },
  removeItem(key) {
    localStorage.removeItem(key);
  }
});
//...

Inside your components

<template>
  <paintable
    alwaysOnTop
    :active="isActive"
    :width="800"
    :height="800"
    :disableNavigation="disableNavigation"
    :hide="hidePaintable"
    :horizontalNavigation="true"
    :navigation="navigation"
    :name="isFirstPaintable ? 'my-screen' : 'my-second-screen'"
    :factor="1"
    :lineWidth="dynamicLineWidth"
    :lineWidthEraser="20"
    :useEraser="useEraser"
    :color="color"
    class="paint"
    ref="paintable"
    @toggle-paintable="toggledPaintable"
  >
    Your content
    <router-view></router-view>
  </paintable>
</template>

Navigation

Set your own navigation content by adding an object to your <paintable> component.

{
  'draw-save': {
    body: 'draw',
    activeBody: '<strong>save</strong>'
  },
  color: {
    body: 'CP'
  }
}

Display navigation horizontal

To display the navigation horizontally add horizontalNavigation to prop list.

Available navigation items:

  • color
  • line-width
  • undo
  • redo
  • delete
  • cancel

has active state (activeBody):

  • draw-save
  • eraser-pencil

Custom Navigation

To use a custom navigation disable the default navigation with disableNavigation.

use $refs to call paintable methods

<paintable ref="paintable">content</paintable>

<button @click="$refs.paintable.undoDrawingStep">undo</button>
<button @click="$refs.paintable.redoDrawingStep">redo</button>
<button @click="$refs.paintable.clearCanvas">clear</button>
<button @click="$refs.paintable.saveCurrentCanvasToStorage">
  save
</button>
<button @click="$refs.paintable.cancelDrawing">cancel</button>

Take a look at the demo (/src/App.vue)

Props

| name | type | required | default | description | | -------------------- | ------------------------------- | -------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------| | name | string - required | true | - | unique identifier | | showUndoRedo | boolean | false | true | show undo and redo button | | hide | boolean | false | false | hide the complete paintable | | colors | Array of colors (rgb, hex etc.) | false | ['black', '#f00', '#4481c7', 'rgba(255, 235, 59, 0.4)', '#999', 'green'] | array of choosable colors | | width | number | false | window.innerWidth | canvas width | | height | number | false | window.innerHeight | canvas height | | showLineWidth | boolean | false | true | show button to set line width | | lineWidth | number | false | 5 | line width | | alwaysOnTop | boolean | false | true | set canvas always as top layer | | factor | number | false | 1 | set a scale factor if needed | | lineWidthEraser | number | false | 20 | set eraser line width | | horizontalNavigation | boolean | false | true | display the navigation horizontally or vertically | | disableNavigation | boolean | false | false | hide navigation | | active | boolean | false | false | set paintable active/inactive | | color | string | false | #000 | current color | | useEraser | boolean | false | false | set to true, to use the eraser | | threshold | number | false | 0 | set the threshold on which an event gets triggered (see events)|

Events

| name | type | description | | ---------------- | ------- | ---------------------------------------------------- | | toggle-paintable | boolean | Is emitted, when changing paintable state | | thresholdReached | boolean | Is emitted, when the speciefied threshold is reached |

<paintable @toggle-paintable="toggledPaintable"></paintable>

<paintable :threshold="10" @thresholdReached="thresholdReached"></paintable>

development

If you want to develop with this plugin, follow these steps:

  • clone repo
  • run yarn install or npm install
  • run yarn serve or npm run serve

build

You can find all built files inside the dist folder.

  • run yarn build or npm run build