@engie-group/fluid-design-system-angular
Version:
Fluid Design System Angular
103 lines (86 loc) • 2.29 kB
text/typescript
import {CommonModule} from '@angular/common';
import {ChangeDetectionStrategy, Component, EventEmitter, Input, Output} from '@angular/core';
import {IconComponent} from '../icon/icon.component';
import {IconButtonSize, IconButtonVariant} from './icon-button.model';
export class IconButtonComponent {
private readonly ICON_BUTTON_CLASS_NAME = 'nj-icon-btn';
/**
* Type of the button. Some values may be `button`, `submit`, `reset`
*/
type = 'button';
/**
* For toggle buttons, indicate the state
*/
ariaPressed?: boolean;
/**
* Additional description for assistive technologies based on visible text
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby
*/
ariaDescribedby?: string;
/**
* Whether button is disabled or not
*/
isDisabled: boolean;
/**
* Tab index, allows you to customize keyboard navigation
*/
tabIndex: number;
/**
* Button variant theme
* @default `primary`
*/
variant: IconButtonVariant;
/**
* Button size
* @default `xs`
*/
size: IconButtonSize;
/**
* Whether button has custom icon
*/
hasCustomIcon = false;
/**
* Button material icon
*/
icon: string;
/**
* Text alternative for assistive technologies
*/
label: string;
/**
* Additional icon-button css classes
*/
additionalClass?: string;
/**
* Button click output. Emits a MouseEvent
*/
buttonClick = new EventEmitter<MouseEvent>();
constructor() {
}
/**
* @ignore
*/
getIconButtonVariantClass(): string {
if (!this.variant || this.variant === 'primary') {
return '';
}
return `${this.ICON_BUTTON_CLASS_NAME}--${this.variant}`;
}
/**
* @ignore
*/
getIconButtonSizeClass(): string {
if (!this.size || this.size === 'xs') {
return '';
}
return `${this.ICON_BUTTON_CLASS_NAME}--${this.size}`;
}
}