All files / components/Badge Badge.jsx

100% Statements 5/5
100% Branches 0/0
100% Functions 0/0
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43          134x   134x                   134x                           5x   5x                  
import React from 'react';
import PropTypes from 'prop-types';
import { lucidClassNames } from '../../util/style-helpers';
import { createClass, omitProps } from '../../util/component-types';
 
const cx = lucidClassNames.bind('&-Badge');
 
const { node, string } = PropTypes;
 
/**
 *
 * {"categories": ["visual design", "icons"]}
 *
 * `Badge` is a quick utility component to create a badge around any
 * element(s). Do not wrap existing `Icon`s in a badge, rather add the
 * `isBadge` prop to any Icon component to turn it into a badge.
 */
const Badge = createClass({
	displayName: 'Badge',
	propTypes: {
		/**
		 * class names that are appended to the defaults
		 */
		className: string,
		/**
		 * any valid React children
		 */
		children: node,
	},
 
	render() {
		const { className, children, ...passThroughs } = this.props;
 
		return (
			<span className={cx('&', className)} {...omitProps(passThroughs, Badge)}>
				{children}
			</span>
		);
	},
});
 
export default Badge;