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-npm-numeric-label

v1.2.0

Published

A react component to display numeric data, in it's various formats. These may include currencies, percentages and large numbers.

Downloads

7

Readme

react-npm-numeric-label

A React component to display numeric data, in it's various formats. These may include currencies, percentages and large numbers.

npm Version Build Status

Overview

A minimal usage will just display the numeric value

let myNumber = 123;
<NumericLabel>{myNumber}</NumericLabel>;

Other options can be passed in as params like so:

let params = {
  justification: 'L',
  locales : 'en-AU'
  currency: true,
  currencyIndicator: 'USD$',
  percentage: false,
  precision: 2,
  commafy: false
  cssClass: ['class1', 'class2']
};
<NumericLabel params=params>123</NumericLabel>;

Params in more detail:

justification

  • Optional parameter to justify text

| Value | Description | Default | | ------------- |----------------|---------| | L | Left justified | | | R | Right justified| * | | C | Centered | |

locales

  • Optional parameter to provide locale

Default to 'en-AU'

currency

  • Optional parameter to provide currency format for numbers

| Value | Description | | ------------- |--------------------------------| | true | to include text dollar sign | | | and 2 decimals eg: 'usd $0.00'| | false | to have no format eg: '0.00' |

currencyIndicator

  • Optional parameter to provide currency indicator

if the currency: parameter is set to true and no value is supplied here, default to a dollar sign $

percentage

  • Optional parameter to provide percentage format for numbers

| Value | Description | ------------- |------------------------- | true | to have 2 decimals and | | include a percentage sign | | eg: '00.00%' | false | not format eg: '0.00'

precision

  • Optional parameter to provide number of decimal places

| Value | Description | ------------- |----------- | Integer x | to round to x decimal places | nil | no rounding

wholenumber

  • Optional parameter to provide rounding for numbers (to an integer value, no decimal place)

| Value | Description | ------------- |----------- | ceil | to round up to the nearest whole number | floor | to round down to the nearest whole number | nil | no ceil or floor

commafy

  • Optional parameter to add commas to large number for readability

| Value | Description | ------------- |------------- | true | Commas will be include, eg: 10,000 | false | Commas will not be include, eg: 10000

cssClass

  • Optional parameter to add one or more css classes to the surrounding div

Features

  • Display numbers with precision.
  • Display numbers as currency.
  • Display numbers as percentage.
  • Justification and Styling of numbers.
  • Runs in the browser and Node.js.
  • Built on standards.

Example

import React,{Component} from 'react';
import ReactDOM from 'react-dom';
import NumericLable from 'react-npm-numeric-label';

class App extends Component {
	constructor(props){
		super(props);

	}

	render() {
	    var option = {
	      'justification':'C',
	      'locales':'en-AU',
	      'currency':true,
	      'currencyIndicator':'AUD',
	      'percentage':false,
	      'precision':2,
	      'wholenumber':null,
	      'commafy':true,
	      'cssClass':['red']
	    };
		return(
			<div className='numeric-wrapper'>
		      <h2>Numeric Lable Component</h2>
		      <NumericLable params={option}>1243.2155</NumericLable>
		      <NumericLable>123</NumericLable>
			</div>
		);
	}
}

ReactDOM.render(<App />,document.querySelector('.container'));

Technology Stack:

  • react
  • mocha

Usage:

Clone the repo as a new project:

git clone https://github.com/lobdev/react-npm-numeric-label.git <numeric-label>

Start Server:

First you have to replace the lib/component/numeric_label.js to server.js in package.json
cd numeric-label
npm i
npm start

Run App:

npm start command automatically initiate browser at 3000 port
http:://localhost:3000

Run tests:

cd numeric-label
npm i
npm test

Developer Notes:

Make sure you configure your editor/IDE to use:

.editorconfig
.eslintrc