All files / components/Icon/EligibilityIcon EligibilityIcon.jsx

100% Statements 10/10
100% Branches 4/4
100% Functions 0/0
100% Lines 10/10
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73              134x   134x   134x 134x 134x 134x                 134x                     268x             32x   32x                                                          
import _ from 'lodash';
import React from 'react';
import PropTypes from 'prop-types';
import Icon from '../Icon';
import { lucidClassNames } from '../../../util/style-helpers';
import { createClass, omitProps } from '../../../util/component-types';
 
const cx = lucidClassNames.bind('&-EligibilityIcon');
 
const { oneOf } = PropTypes;
 
const LEFT = 'left';
const RIGHT = 'right';
const NEITHER = 'neither';
const BOTH = 'both';
 
/**
 *
 * {"categories": ["visual design", "icons"], "extend": "Icon", "madeFrom": ["Icon"]}
 *
 * An eligibility icon.
 */
 
const EligibilityIcon = createClass({
	displayName: 'EligibilityIcon',
	propTypes: {
		...Icon.propTypes,
		/**
		 * Eligibility variations of the icon.
		 */
		eligibility: oneOf(['both', 'neither', 'left', 'right']),
	},
 
	getDefaultProps() {
		return {
			eligibility: NEITHER,
			isDisabled: false,
		};
	},
 
	render() {
		const { className, eligibility, isDisabled, ...passThroughs } = this.props;
 
		return (
			<Icon
				{...omitProps(passThroughs, EligibilityIcon, [], false)}
				{..._.pick(passThroughs, _.keys(Icon.propTypes))}
				isDisabled={isDisabled}
				className={cx('&', className)}
			>
				<g>
					<path
						className={cx('&-half-circle', {
							'&-is-selected': eligibility === LEFT || eligibility === BOTH,
							'&-half-circle-is-disabled': isDisabled,
						})}
						d="M6.98.928C3.51 1.424.844 4.398.844 8c0 3.604 2.666 6.576 6.133 7.072V.928z"
					/>
					<path
						className={cx('&-half-circle', {
							'&-is-selected': eligibility === RIGHT || eligibility === BOTH,
							'&-half-circle-is-disabled': isDisabled,
						})}
						d="M9.022.928c3.465.496 6.133 3.47 6.133 7.072 0 3.604-2.668 6.576-6.133 7.072V.928z"
					/>
				</g>
			</Icon>
		);
	},
});
 
export default EligibilityIcon;