1.0.0 • Published 4 years ago

react-bean-counter v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-bean-counter

A spinning dial counter for React, similar to price spinners in the Robinhood stock app.

NPM JavaScript Style Guide

npm.io

Install

npm install --save react-bean-counter

Demo

git clone git@github.com:BirdTho/react-bean-counter.git
cd react-bean-counter
npm install
npm run storybook

Usage

import React from 'react'

import BeanCounter from 'react-bean-counter'

class Example extends Component {
  render() {
    return <BeanCounter value={1234.56} precision={2} className='custom-bean-style'/>
  }
}

Custom styling

BeanCounter will automatically calculate metrics of digits based on the size of the font. It uses an offscreen element to measure digit dimensions for a given font and font size.

For instance, you can pass in custom class name to the BeanCounter using the optional className parameter.

.custom-bean-style {
  font-size: 16px;
  font-family: Helvetica, sans-serif;
  color: white;
}

.custom-bean-style > span, .custom-bean-style .bean-digit-container {
  background-color: rgb(30, 30, 30);
}

License

MIT © BirdTho