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

@asphalt-react/badge

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asphalt-react/badge - npm Package Compare versions

Comparing version 1.14.1 to 1.15.0

10

CHANGELOG.md

@@ -6,2 +6,12 @@ # Change Log

# [1.15.0](https://source.golabs.io/asphalt/asphalt-react/compare/v1.14.1...v1.15.0) (2022-05-26)
### Features
* **badge:** accept string as value ([b1bfe41](https://source.golabs.io/asphalt/asphalt-react/commits/b1bfe4143044cf2a5e446c3bbdd518855c794409)), closes [#1202339549530819](https://app.asana.com/0/1170955946111597/1202339549530819)
## [1.14.1](https://source.golabs.io/asphalt/asphalt-react/compare/v1.14.0...v1.14.1) (2022-05-12)

@@ -8,0 +18,0 @@

24

dist/cjs/index.js

@@ -71,3 +71,3 @@ 'use strict';

/**
* returns `replaceValue` if `value` is greater than 99
* Returns value of Badge
*

@@ -80,4 +80,11 @@ * @param {Number} value

const formatBadge = (value, replaceValue = `99+`) => {
if (!value) return 0;
return value > 99 ? replaceValue : `${value}`;
if (!value) return 0; // "0" is a valid value
const isNumber = Number(value) > -1;
if (isNumber) {
return value > 99 ? replaceValue : value;
}
return value;
};

@@ -113,5 +120,3 @@ const typePropValidator = createPropOccurValidator([helper.DANGER, helper.WARNING, helper.SUCCESS, helper.INFO]);

/**
* decides whether to show a _light/strong_ `Badge`
* if the value is a number or can be converted to a number,
* show a _strong_ `Badge` otherwise a _light_ `Badge`
* Decides whether to show a _light/strong_ `Badge`
*

@@ -124,3 +129,4 @@ * @param {String} value to show in `Badge`

/**
* if value is a `""` or an Array, or null, converting it into a number gives `0`
* Typecasting these values into number gives "0".
* "0" is an acceptable value, but these are not
*/

@@ -131,3 +137,3 @@ if (value === "" || Array.isArray(value) || value === null) {

return Number(value) > -1;
return true;
};

@@ -170,3 +176,3 @@

/**
* Numeric value displayed in badge.
* Value to display in Badge.
*/

@@ -173,0 +179,0 @@ value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].number, PropTypes__default['default'].string]),

@@ -61,3 +61,3 @@ import React from 'react';

/**
* returns `replaceValue` if `value` is greater than 99
* Returns value of Badge
*

@@ -70,4 +70,11 @@ * @param {Number} value

const formatBadge = (value, replaceValue = `99+`) => {
if (!value) return 0;
return value > 99 ? replaceValue : `${value}`;
if (!value) return 0; // "0" is a valid value
const isNumber = Number(value) > -1;
if (isNumber) {
return value > 99 ? replaceValue : value;
}
return value;
};

@@ -103,5 +110,3 @@ const typePropValidator = createPropOccurValidator([DANGER, WARNING, SUCCESS, INFO]);

/**
* decides whether to show a _light/strong_ `Badge`
* if the value is a number or can be converted to a number,
* show a _strong_ `Badge` otherwise a _light_ `Badge`
* Decides whether to show a _light/strong_ `Badge`
*

@@ -114,3 +119,4 @@ * @param {String} value to show in `Badge`

/**
* if value is a `""` or an Array, or null, converting it into a number gives `0`
* Typecasting these values into number gives "0".
* "0" is an acceptable value, but these are not
*/

@@ -121,3 +127,3 @@ if (value === "" || Array.isArray(value) || value === null) {

return Number(value) > -1;
return true;
};

@@ -160,3 +166,3 @@

/**
* Numeric value displayed in badge.
* Value to display in Badge.
*/

@@ -163,0 +169,0 @@ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),

@@ -36,3 +36,3 @@ import React from "react"

/**
* Numeric value displayed in badge.
* Value to display in Badge.
*/

@@ -39,0 +39,0 @@ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),

@@ -13,3 +13,3 @@ import {

/**
* returns `replaceValue` if `value` is greater than 99
* Returns value of Badge
*

@@ -22,3 +22,11 @@ * @param {Number} value

if (!value) return 0
return value > 99 ? replaceValue : `${value}`
// "0" is a valid value
const isNumber = Number(value) > -1
if (isNumber) {
return value > 99 ? replaceValue : value
}
return value
}

@@ -52,5 +60,3 @@

/**
* decides whether to show a _light/strong_ `Badge`
* if the value is a number or can be converted to a number,
* show a _strong_ `Badge` otherwise a _light_ `Badge`
* Decides whether to show a _light/strong_ `Badge`
*

@@ -62,3 +68,4 @@ * @param {String} value to show in `Badge`

/**
* if value is a `""` or an Array, or null, converting it into a number gives `0`
* Typecasting these values into number gives "0".
* "0" is an acceptable value, but these are not
*/

@@ -69,3 +76,3 @@ if (value === "" || Array.isArray(value) || value === null) {

return Number(value) > -1
return true
}
{
"name": "@asphalt-react/badge",
"version": "1.14.1",
"version": "1.15.0",
"description": "Badge",

@@ -45,3 +45,3 @@ "keywords": [

"license": "UNLICENSED",
"gitHead": "eed9dc0befa8f1f3d2d85683efccfa3fbc33247b"
"gitHead": "7c229e49ebe71b331a3aba840f630c5532f10ed4"
}
# Badge
Badges are used to inform about status or show a numerical value in proximity to notifications or any action that has been taken.
Badges are used to inform about status or show a value in proximity to notifications or any action that has been taken.
There are 2 types of badges
There are 2 variants of Badges:
1. **Strong**
2. **Light**
1. **Strong**: has a value
2. **Light**: without any value
Use a strong badge to denote quantity, use a light badge to seek mild attention. Both types offer different support variants namely *danger*, *warning*, *info* and *success* which are available as props.
Use a strong Badge to denote quantity, use a light Badge to seek mild attention. Both types offer different support variants namely *danger*, *warning*, *info* and *success* which are available as props.
Badge renders *danger* variation by default for both Strong and Light badges.
Badge renders *danger* variation by default for both strong and light variants.

@@ -32,3 +32,3 @@ ## Usage

Numeric value displayed in badge.
Value to display in Badge.

@@ -35,0 +35,0 @@ | type | required | default |

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