Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-npm-numeric-label

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-npm-numeric-label

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

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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
ValueDescriptionDefault
LLeft justified
RRight justified*
CCentered
locales
  • Optional parameter to provide locale

Default to 'en-AU'

currency
  • Optional parameter to provide currency format for numbers
ValueDescription
trueto include text dollar sign
and 2 decimals eg: 'usd $0.00'
falseto 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
ValueDescription
trueto have 2 decimals and
include a percentage sign
eg: '00.00%'
falsenot format eg: '0.00'
precision
  • Optional parameter to provide number of decimal places
ValueDescription
Integer xto round to x decimal places
nilno rounding
wholenumber
  • Optional parameter to provide rounding for numbers (to an integer value, no decimal place)
ValueDescription
ceilto round up to the nearest whole number
floorto round down to the nearest whole number
nilno ceil or floor
commafy
  • Optional parameter to add commas to large number for readability
ValueDescription
trueCommas will be include, eg: 10,000
falseCommas 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

Keywords

FAQs

Package last updated on 08 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc