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-rough-notation

v1.0.5

Published

This is a React wrapper for [RoughNotation](https://roughnotation.com/), a small JavaScript library to create and animate annotations on a web page.

Downloads

16,880

Readme

Rough Notation React (Wrapper)

npm

This is a React wrapper for RoughNotation, a small JavaScript library to create and animate annotations on a web page.

Rough Notation logo

Table of contents

Installation

You can add rough-notation to your project via npm.

npm install --save react-rough-notation

Then just import the components you need.

import { RoughNotation, RoughNotationGroup } from "react-rough-notation";

RoughNotation Component

This is the main component, is a span element by default but you can change the tag name by anything you want using the customElement prop.

Usage

<RoughNotation type="underline" show={state.show}>
  Hello RoughNotation
</RoughNotation>

Props

Any unlisted prop will be pass to the component so you can use any react prop to handle interactions or styling.

| name | type | default | description | | ------------------- | ---------------------------------------------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | animate | boolean | true | Turn on/off animation when annotating | | animationDelay | number | 0 | Delay in animation in milliseconds | | animationDuration | number | 800 | Duration of the animation in milliseconds | | brackets | enum or [enum] from left, right, top, bottom | right | Value could be a string or an array of strings, each string being one of these values: left, right, top, bottom. When drawing a bracket, this configures which side(s) of the element to bracket. | | color | string | | String value representing the color of the annotation sketch | | customElement | string | span | Element wrapper tagName | | getAnnotationObject | function | (annotation) => {} | Callback function called after annotation init, it will receive the javascript annotation object as a param | | iterations | number | 2 | By default annotations are drawn in two iterations, e.g. when underlining, drawing from left to right and then back from right to left. Setting this property can let you configure the number of iterations. | | multiline | boolean | false | This property only applies to inline text. To annotate multiline text (each line separately), set this property to true. | | order | number, string | | Annotation order to animate if is inside an Annotation Group | | padding | number, [top, right, bottom, left], [vertical, horizontal] | 5 | Padding in pixels between the element and roughly where the annotation is drawn. If you wish to specify different top, left, right, bottom paddings, you can set the value to an array akin to CSS style padding [top, right, bottom, left] or just [top & bottom, left & right] | | show | boolean | false | Show/hide the annotation | | strokeWidth | number | 1 | Width of the annotation strokes | | type | enum from (Type values)[#type-values] | underline | It sets the annotation style |

Type values

| value | description | | -------------- | ------------------------------------------------------- | | underline | Create a sketchy underline below an element | | box | This style draws a box around the element | | circle | Draw a circle around the element | | highlight | Creates a highlight effect as if maked by a highlighter | | strike-through | This style draws a box around the element | | crossed-off | This style draws a box around the element |

Updating Styles

Some props can be changed after the initialization without re-rendering the annotation. i.e: if you like to change the color, just change the color prop, here is the complete list:

| Prop | | ----------------- | | animated | | animationDuration | | color | | padding | | strokeWidth |

Note: the type of the annotation cannot be changed. Create a new annotation for that.

RoughNotationGroup Component

This is a wrapper for multiple annotations, it will trigger the show() method on every child annotation after the prev annotation animation is complete. It does not render any HTML element.

Usage

<RoughNotationGroup show={state.show}>
  <RoughNotation type="underline">Hello,</RoughNotation>
  <RoughNotation type="underline">This is</RoughNotation>
  <RoughNotation type="underline">a Test</RoughNotation>
</RoughNotationGroup>

Props

| name | type | default | description | | ---- | ------- | ------- | -------------------------- | | show | boolean | | show/hides the annotations |

Custom order

If you need to trigger annotations in a specific order, use the order prop in each RoughAnnotation component.

i.e: Reverse order

<RoughNotationGroup show={state.show}>
  <RoughNotation type="underline" order="3">
    Hello,
  </RoughNotation>
  <RoughNotation type="underline" order="2">
    This is
  </RoughNotation>
  <RoughNotation type="underline" order="1">
    a Test
  </RoughNotation>
</RoughNotationGroup>

Note: It will annotate first the components with the order prop, and then the ones without it.

Playground

You can find a CodeSandbox demo here

TODO

  • [ ] Auto compile and publish to npm
  • [ ] Testing