All files / src/components/zd-icon icon.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 0/0
100% Lines 12/12

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 74 75 76 77 78 79 80 8193x           93x         2x         2x         2x         2x         2x           2x           2x         2x         2x         2x                                            
import { ComponentRender } from '../zd-component/component-render';
import { IIcon } from './interfaces';
 
/**
 * The Icon component <code>zd-icon</code> is used to show an icon.
 */
export class Icon extends ComponentRender implements IIcon {
	/**
	 * Applies specified color to the control - it can be the name of material color
	 * (for example success or purple) or css color (#033 or rgba(255, 0, 0, 0.5)).
	 */
	public color = '';
 
	/**
	 * Makes icon smaller (20px)
	 */
	public dense = false;
 
	/**
	 * Disable the icon
	 */
	public disabled = false;
 
	/**
	 * Defines the icon, that will be rendered
	 */
	public iconName = '';
 
	/**
	 * Makes the component large.
	 */
	public large = false;
 
	/**
	 * Applies appropriate margins to the icon inside
	 * of a button when placed to the left of another element or text
	 */
	public left = false;
 
	/**
	 * Applies appropriate margins to the icon inside of
	 * a button when placed to the right of another element or text
	 */
	public right = false;
 
	/**
	 * Specifies a custom font size for the icon
	 */
	public size: number | string = '';
 
	/**
	 * Makes the component small.
	 */
	public small = false;
 
	/**
	 * Specifies a custom tag to be used
	 */
	public tag = 'i';
 
	/* istanbul ignore next */
	/**
	 * Create a new Button
	 * @param props Icon definition
	 */
	constructor(props: IIcon) {
		super(props);
		this.color = this.getInitValue('color', props.color, this.color);
		this.dense = this.getInitValue('dense', props.dense, this.dense);
		this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
		this.iconName = this.getInitValue('iconName', props.iconName, this.iconName);
		this.large = this.getInitValue('large', props.large, this.large);
		this.left = this.getInitValue('left', props.left, this.left);
		this.right = this.getInitValue('right', props.right, this.right);
		this.size = this.getInitValue('size', props.size, this.size);
		this.small = this.getInitValue('small', props.small, this.small);
		this.tag = this.getInitValue('tag', props.tag, this.tag);
		this.createAccessors();
	}
}