@engie-group/fluid-design-system-angular
Version:
Fluid Design System Angular
47 lines (40 loc) • 1.41 kB
text/typescript
import {ChangeDetectionStrategy, Component, Input, ViewEncapsulation} from '@angular/core';
import {IconBaseComponent} from '../icon-base/icon-base.component';
import {IconColor, IconSize} from './icon.model';
export class IconComponent extends IconBaseComponent {
private ICON_MATERIAL_CLASS = 'nj-icon-material';
/**
* Icon size
*/
size: IconSize = 'md';
/**
* Icon variant theme
*/
variant: IconColor;
protected getClassName(): string {
const sizeClass = this.size ? `${this.ICON_MATERIAL_CLASS}--${this.classModifier(this.size, 'size-inherit')}` : '';
const variantClass = this.variant ? `${this.ICON_MATERIAL_CLASS}--${this.classModifier(this.variant, 'color-inherit')}` : '';
const className = this.className ? this.className : '';
return `${this.ICON_MATERIAL_CLASS} ${sizeClass} ${variantClass} ${className}`;
}
private classModifier<T extends string, U>(
variant: T,
inheritClass: U
): Exclude<T, 'inherit'> | U {
switch (variant) {
case 'inherit':
return inheritClass;
default:
return variant as Exclude<T, 'inherit'>;
}
}
}