All files / Icon/DotsIcon DotsIcon.tsx

100% Statements 11/11
80% Branches 8/10
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                176x   176x         176x           59x 59x       59x         59x                                   176x 176x                 176x             176x            
import _ from 'lodash';
import React from 'react';
import Icon, { IIconProps, propTypes as iconPropTypes } from '../Icon';
import { lucidClassNames } from '../../../util/style-helpers';
import { omitProps } from '../../../util/component-types';
import { Color } from '../Icon';
import PropTypes from 'react-peek/prop-types';
 
const cx = lucidClassNames.bind('&-DotsIcon');
 
const { oneOf } = PropTypes;
interface IDotsIconProps extends IIconProps {
	direction?: 'vertical' | 'horizontal';
}
 
export const DotsIcon = ({
	className,
	direction = 'horizontal',
	color = Color.primary,
	...passThroughs
}: IDotsIconProps) => {
	const isVerticalOrientation = direction === 'vertical';
	const leftOrTopPosition = {
		cx: isVerticalOrientation ? '8' : '14.5',
		cy: isVerticalOrientation ? '14.5' : '8',
	};
	const rightOrBottomPosition = {
		cx: isVerticalOrientation ? '8' : '1.5',
		cy: isVerticalOrientation ? '1.5' : '8',
	};
 
	return (
		<Icon
			{...omitProps(passThroughs, undefined, _.keys(DotsIcon.propTypes), false)}
			{..._.pick(passThroughs, _.keys(iconPropTypes))}
			color={color}
			className={cx('&', className)}
		>
			<circle className={cx(`&-color-${color}`)} cx='8' cy='8' r='1' />
			<circle className={cx(`&-color-${color}`)} {...leftOrTopPosition} r='1' />
			<circle
				className={cx(`&-color-${color}`)}
				{...rightOrBottomPosition}
				r='1'
			/>
		</Icon>
	);
};
 
DotsIcon.displayName = 'DotsIcon';
DotsIcon.peek = {
	description: `
		Three dots in a row.
	`,
	categories: ['visual design', 'icons'],
	extend: 'Icon',
	madeFrom: ['Icon'],
};
 
DotsIcon.propTypes = {
	...iconPropTypes,
	direction: oneOf(['vertical', 'horizontal'])`
		Sets the orientation of how the dots are displayed. Defaults to 'horizontal'. 
	`,
};
 
DotsIcon.defaultProps = {
	...Icon.defaultProps,
	direction: 'horizontal',
};
 
export default DotsIcon;