coreui-angular-ex
Version:
CoreUI Components Library for Angular
58 lines (53 loc) • 1.59 kB
text/typescript
import { Component, HostBinding, Input } from '@angular/core';
import { BadgePositions, Colors, Shapes } from '../coreui.types';
export class BadgeComponent {
/**
* Sets the color context of the component to one of CoreUI’s themed colors.
* @type Colors
*/
color?: Colors;
/**
* Position badge in one of the corners of a link or button.
* @type BadgePositions
*/
position?: BadgePositions;
/**
* Select the shape of the component.
* @type Shapes
*/
shape?: Shapes;
/**
* Size the component small.
*/
size?: 'sm';
/**
* Sets the text color of the component to one of CoreUI’s themed colors.
* @type TextColors
*/
textColor?: string;
constructor() {}
get hostClasses(): any {
const positionClasses = {
'position-absolute': !!this.position,
'translate-middle': !!this.position,
'top-0': this.position?.includes('top'),
'top-100': this.position?.includes('bottom'),
'start-100': this.position?.includes('end'),
'start-0': this.position?.includes('start')
};
return Object.assign({
badge: true,
[`bg-${this.color}`]: !!this.color,
[`text-${this.textColor}`]: !!this.textColor,
[`badge-${this.size}`]: !!this.size,
[`${this.shape}`]: !!this.shape
}, !!this.position ? positionClasses : {}
);
}
}