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

react-magnetic-board

v1.0.9

Published

React magnetic board component using HTML5 canvas.

Downloads

21

Readme

React Magnetic Board

npm version npm bundle size Build Status storybook

Light, zero dependencies magnetic board component using HTML5 canvas 🧲

Demo

Demos created with React DemoTab 📑

Install

npm install react-magnetic-board

Example

import React from 'react';
import ReactDOM from 'react-dom';
import MagneticBoard from 'react-magnetic-board';

const circleSVG = 'M 100, 100  m -75, 0  a 75,75 0 1,0 150,0  a 75,75 0 1,0 -150,0';

const App = () => {
  return (
    <MagneticBoard
      magnet={{
        path: circleSVG,
        scale: 0.25,
        offsetX: 100,
        offsetY: 90,
        fillStyle: '#d93030',
        shadowColor: '#bf2626',
        shadowBlur: 5,
      }}
      width={600}
      height={500}
    />
  );
};

ReactDOM.render(<App />, document.getElementById('root'));

Props

All of the props are optional.
Below is the complete list of possible props and their options:

▶︎ indicates the default value if there's one

magnet: Magnet ▶︎ undefined
Magnet = { path: string; scale?: number; offsetX?: number; offsetY?: number; fillStyle?: string; shadowColor?: string; shadowBlur?: number; x?: number; y?: number; }
Magnet resource.

width: number ▶︎ 500
Magnetic Board width.

height: number ▶︎ 400
Magnetic Board height.

className: string ▶︎ undefined
Class name.

initMagnets: Magnet[] ▶︎ []
Initialize magnets.

onUndo: boolean ▶︎ undefined
Inverting 'onUndo' prop value triggers undo command.

onClear: boolean ▶︎ undefined
Inverting 'onClear' prop value clears the board.

onMagnetChange: Function => (magnets: Magnet[])
Gets triggered when user changes magnet(s) on the component.

Development

Easily set up a local development environment!

Build all the examples and starts storybook server on localhost:9009:

  • clone
  • npm install
  • npm start

OR

Clone this repo on your machine, navigate to its location in the terminal and run:

npm install
npm link # link your local repo to your global packages
npm run build:watch # build the files and watch for changes

Clone project repo that you wish to test with react-magnetic-board library and run:

npm install
npm link react-magnetic-board # link your local copy into this project's node_modules
npm start

Start coding! 🎉

Roadmap

  • Move magnet(s)
  • Add marker pens and eraser
  • Tests