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-envelope-graph

v0.1.4

Published

A drag-and-drop-enabled, responsive, envelope graph that allows to shape a wave with attack, decay, sustain and release

Downloads

53

Readme

react-envelope-graph

npm version

A drag-and-drop-enabled, responsive, envelope graph that allows to shape a wave with attack, decay, sustain and release.

Check out the Demo!

Installing

$ npm i --save react-envelope-graph

or

$ yarn add react-envelope-graph

Usage

Import the component

import EnvelopeGraph from "react-envelope-graph";

and then use it:

function App() {
  return (
    <EnvelopeGraph
      defaultXa={1}
      defaultXd={0.5}
      defaultYs={0.5}
      defaultXr={0.7}
      ratio={{
        xa: 0.25,
        xd: 0.25,
        xr: 0.2
      }}
      style={{
        backgroundColor: "black",
        padding: "2.5%",
        height: "100vh",
        width: "20vw"
      }}
      styles={{
        line: {
          fill: "none",
          stroke: "red",
          strokeWidth: 2,
        },
        dndBox: {
          fill: "none",
          stroke: "blue",
          strokeWidth: 0.1,
          height: 1,
          width: 1
        },
        dndBoxActive: {
          fill: "blue",
        }
      }}
      onChange={console.log}
    />
  );
}

Notes

  • The height/width ratio is preserved within the svg
  • width and height can be specified via the style prop
  • defaultXa, defaultXd, defaultYs and defaultXr need to have a value between 0 and 1
  • In ratio, the sum of the values xa, xd and xr needs to remain below 0.75. xs is internally set to xs === 0.25.
  • Most numeric values in the styles prop must not use a unit (e.g. px or em) as they set values on SVG components (user units)
  • Note that styles is not a regular style prop, but a custom prop that additionally allows to configure interaction reactions too
  • To regularly style the component, use the style prop
  • When defaultXa, defaultXd, defaultYs and defaultXr props are changed, no onChange event is fired and the graph is set to these values.
  • Optional props: ratio, dndBox, onChange, style

Contributing

To try the component:

$ git clone [email protected]:TimDaub/react-envelope-graph.git
$ npm i
$ npm run dev

Current Limitations

Help is very much appreciated. I'll try to handle PRs as fast as I can. Below is a list of the current limitations:

Changelog

0.1.4

  • defaultXa, defaultXd, defaultYs and defaultXr can now be used to continuously set the graphs values without an onChange event firing

0.1.3

  • Bugfix: Dropped getBoundingClientRect in favor of getComputedStyles for measuring the svg's dimensions. Setting margin and padding via style should now be possible without problems.

0.1.2

  • Bugfix: Properly fix ratio issues with height and width. They're now members of the style prop

0.1.1

  • Hotfix: Set height/width of graph to 100% to respect ratio. I'll have to go back on that fix later...

0.1.0

  • Breaking change: Removed functions onAttackChange, onDecayChange, onSustainChange and onReleaseChange in favor of onChange, which returns all values as an object

0.0.11

  • When setting the props height and width, the graph's ratio is adjusts accordingly

0.0.10

  • Bugfix: Remove ratio.xs from configurable params

0.0.9

  • Bugfix: Dragging the function works even thought the graph has any type of padding

0.0.8

  • Bugfix: Yet fixing corner length another time...

0.0.7

  • Bugfix: Left top corner same length as others

0.0.6

  • Add cut corners to graph
  • Allow definition of padding through native style prop and remove marginTop, marginRight, marginBottom, and marginRight props

0.0.5

  • Improve support for styles prop to allow to styling of the component
  • Move dndBox prop to styles

0.0.4

  • DnD box's size now configurable

0.0.3

  • Bugfix: When mouse leaves graph, DnD stops

0.0.2

  • Event subscriptions
  • Improved props API
  • Responsive

0.0.1

  • Dragable ADSR graph

License

MIT