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

@lab49/react-value-flash

v0.1.7

Published

Flash on value change. Perfect for financial applications.

Downloads

2

Readme

@lab49/react-value-flash

codecov .github/workflows/cicd.yml npm version Contributor Covenant

react-value-flash will display a flashed value on screen based on some value change. This pattern is extremely common in financial applications, and at Lab49, we're focused on the finance industry.

Incorporate this component into your application and pass along a number. As that number changes, this component will briefly flash a color, letting the user know the number has changed. By default, this component will flash green when the value changes up, or red when the value changes down.

Not only are these colors configurable, but the properties of the flash itself and the formatting of the value are configurable as well.

Furthermore, this component doesn't come with any styles, but does provide plenty of hooks to add your own styles. Even though flash color and transition properties are configurable as props, you can still use the generated classnames (which are also configurable) to add your own unique styles.

This component is perfect for:

  • Trading platforms
  • Analytics dashboards
  • Monitoring dashboards

Features

  • Written in TypeScript
  • Small, simple, configurable, performant
  • Maintained by a team of finance industry professionals

Table of contents

Demo

Hosted demo: https://master--5f3fca6e6b5eba0022c71e4e.chromatic.com/

You can also run the demo locally. To get started:

git clone [email protected]:lab49/react-value-flash.git
npm install
npm run storybook
⇡ Top

Installation

npm install @lab49/react-value-flash
⇡ Top

Usage

import { Flash } from '@lab49/react-value-flash';

<Flash value={20_000}>

As discussed above, there are a number of classnames you can use to add your own styles. There is an example of doing exactly that in the include Storybook, but as an example, here's a description of the available classnames:

| Class | Description | | --- | --- | | .rvf_Flash | Root DOM node | | .rvf_Flash__value | Rendered value, direct (and only) child of the root node. | | .rvf_Flash--flashing | Applied only when the component is in the flashing state. | | .rvf_Flash--flashing-up | Applied when flashing 'up'. | | .rvf_Flash--flashing-down | Applied when flashing 'down'. | | .rvf_Flash--positive | Applied when the value is positive. | | .rvf_Flash--negative | Applied when the value is negative. |

⇡ Top

API

Flash

<Flash /> is a (props: Props) => JSX.Element. See Props below for a description of the avilable props.

import { Flash } from '@lab49/react-value-flash';

const MyComponent = () => <Flash value={1} />;

Props

interface Props {
  /**
   * Color value when the component flashes 'down'.
   */
  downColor?: string;
  /**
   * One of the built in formatters.
   */
  formatter?: 'currency' | 'percentage' | 'number';
  /**
   * Pass your own formatter function.
   */
  formatterFn?: Formatter;
  /**
   * Prefix for the CSS selectors in the DOM.
   */
  stylePrefix?: string;
  /**
   * Amount of time the flashed state is visible for, in milliseconds.
   */
  timeout?: number;
  /**
   * Custom CSS transition property.
   */
  transition?: string;
  /**
   * Transition length, in milliseconds.
   */
  transitionLength?: number;
  /**
   * Color value when the component flashes 'up'.
   */
  upColor?: string;
  /**
   * Value to display. The only required prop.
   */
  value: number;
}

FlashDirection

enum FlashDirection {
  Down = 'down',
  Up = 'up',
}
⇡ Top

Extra

This project was created with create-react-library.

⇡ Top

License

MIT @ Lab49

⇡ Top

Sponsored by Lab49