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

@khanacademy/khannotations

v0.1.6

Published

Khannotations is a React library for rough, animated, annotations.

Downloads

955

Readme

Khannotations

Khannotations is a React library for rough, animated, annotations.

It uses RoughJS and is made by Khan Academy.

View live demo

Installation

To add Khannotations to a project, run this from the project directory:

npm install --save @khanacademy/khannotations aphrodite

If your project uses yarn, instead run this:

yarn add @khanacademy/khannotations aphrodite

Usage

Inline annotations

Khannotations provides two React components that render inline annotations: RoughHighlight and RoughUnderline. You should be able to replace elements like <strong> or <u> with these components.

For example, you could replace the following example:

Lorem <u>ipsum</u> dolor sit amet.

with:

// This example is in TypeScript.
// For JavaScript, omit UnderlineStyle/AnimationStrategy.
import {RoughUnderline, UnderlineStyle, AnimationStrategy} from "@khanacademy/khannotations";

// For JavaScript, omit ": AnimationStategy".
let speedAnimation: AnimationStrategy = {
    animation: "speed",
    speed: 5,
    delay: 100,
};

// For JavaScript, omit ": UnderlineStyle".
let underlineStyle: UnderlineStyle = {
    roughness: 3,
    stroke: "red",
    strokeWidth: 2,
    bowing: {
        bowing: "inverse",
        ratio: 300,
    },
    lift: 3,
};

const MyComponent = () => (
    <span>
        Lorem{" "}
        <RoughUnderline animation={speedAnimation} roughStyle={underlineStyle}>
            ipsum
        </RoughUnderline>{" "}
        dolor sit amet.
    </span>
);

Khannotations does not provide defaults, so you'll need to fill out your animation strategy and styles yourself. If you find yourself doing this a lot, you can always make a wrapper component that renders an annotation with your prefered styles. For example, you could make a drop-in replacement for <u> with:

const MyUnderline = (props) => (
    <RoughUnderline animation={speedAnimation} roughStyle={underlineStyle}>
        {props.children}
    </RoughUnderline>
);

See the API docs for full usage.

RoughCircledBox

RoughCircledBox is a block element that draws a rough ellipse just touching its native bounding box.

AnimatedLineDrawing

AnimatedLineDrawing is a block element that draws an SVG path.

AnimatedGroup

If you want the annotations in a document to be rendered sequentially in DOM order, put your annotations in an AnimatedGroup.

This works for RoughUnderlines, RoughHighlights, RoughCircledBoxes, and AnimatedLineDrawings.

Development

Contributions are welcome.

To develop Khannotations, you need Yarn.

To install JS dependencies, run yarn.

To open the storybook, run yarn run storybook. This is where you'll probably do most of your work. When you make changes to a module, it will be automatically updated in the storybook.

To work on the demo page (./src/_App.tsx), run yarn start.

To build the demo page, API documentation, and production build, run yarn build. The app is built to the following folders:

  • The demo is built to ./docs
  • The API documentation is built to ./docs/api
  • The UMD modules are built to ./dist