All files / src/components/zd-modal modal-close-button.ts

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

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 4693x 93x           93x       3x         3x         3x         3x                                      
import { ModalService } from '../../services';
import { Button } from '../zd-button/button';
import { IModalCloseButton } from './interfaces';
 
/**
 * Base class for Modal Close Button component.
 */
export class ModalCloseButton extends Button implements IModalCloseButton {
	/**
	 * Name of Modal component to be closed
	 */
	public modalName = '';
 
	/**
	 * Makes the background transparent (equal to text prop in Vuetify).
	 */
	public flat = true;
 
	/**
	 * Designates the button as icon, round and flat.
	 */
	public icon = true;
 
	/**
	 * Designates the button icon, that will be rendered before the label.
	 */
	public iconName = 'close';
 
	/* istanbul ignore next */
	/**
	 * Creates a new modal close button
	 * @param props Modal close button structure
	 */
	constructor(props: IModalCloseButton) {
		super(props);
		this.modalName = this.getInitValue('modalName', props.modalName, this.modalName);
		this.flat = this.getInitValue('flat', props.flat, this.flat);
		this.icon = this.getInitValue('icon', props.icon, this.icon);
		this.iconName = this.getInitValue('iconName', props.iconName, this.iconName);
		this.events.click = () => {
			ModalService.closeByName(this.modalName);
		};
		this.createAccessors();
	}
}