coreui-angular-ex-dev
Version:
CoreUI Components Library for Angular
56 lines (47 loc) • 1.35 kB
text/typescript
import { booleanAttribute, Directive, HostBinding, Input } from '@angular/core';
export class ImgDirective {
/**
* Set the horizontal aligment.
* @type {'' | 'start' | 'end' | 'center'}
*/
align: '' | 'start' | 'end' | 'center' = '';
/**
* Make image responsive.
* @type boolean
*/
fluid: string | boolean = false;
/**
* Make image rounded.
* @type boolean
*/
rounded: string | boolean = false;
/**
* Give an image a rounded 1px border appearance.
* @type boolean
*/
thumbnail: string | boolean = false;
/**
* Color for image placeholder.
*/
placeholderColor = 'transparent';
get getStyles(): any {
return { backgroundColor: this.placeholderColor };
}
get hostClasses(): any {
const align = this.align;
return {
[`float-${align}`]: align === 'start' || align === 'end',
'd-block': align === 'center',
'mx-auto': align === 'center',
'img-fluid': this.fluid,
'rounded': this.rounded,
'img-thumbnail': this.thumbnail
};
}
}