coreui-angular-ex
Version:
CoreUI Components Library for Angular
94 lines (82 loc) • 2.31 kB
text/typescript
import {
AfterContentInit,
booleanAttribute,
Component,
ContentChildren,
HostBinding,
Input,
QueryList
} from '@angular/core';
import { CardBodyComponent, CardComponent } from '../../card';
import { TemplateIdDirective } from '../../shared';
import { NgClass, NgIf, NgTemplateOutlet } from '@angular/common';
export class WidgetStatCComponent extends CardComponent implements AfterContentInit {
constructor() {
super();
}
/**
* Icon for your component.
* @type string
*/
icon?: string;
/**
* Title of the widget to display
* @type string
*/
title?: string;
/**
* Value for your widget to display
* @type string
*/
value?: string | number;
/**
* Invert colors from their default dark shade.
* @type boolean
*/
inverse: string | boolean = false;
templates: any = {};
contentTemplates!: QueryList<TemplateIdDirective>;
get hostExtendedClass() {
return {
'high-emphasis-inverse': this.inverse
};
}
get iconClasses() {
return {
'mb-4': !this.textColor,
'text-end': true,
'text-medium-emphasis': !this.inverse,
'text-medium-emphasis-inverse': this.inverse,
[`text-${this.textColor}`]: !!this.textColor
};
}
get titleClasses() {
return {
'text-medium-emphasis': !this.inverse,
'text-medium-emphasis-inverse': this.inverse,
[`text-${this.textColor}`]: !!this.textColor
};
}
get valueClasses() {
return {
'fs-4': !this.textColor,
'fw-semibold': true,
'text-high-emphasis': !this.inverse,
'text-high-emphasis-inverse': this.inverse,
[`text-${this.textColor}`]: !!this.textColor
};
}
ngAfterContentInit(): void {
this.contentTemplates.forEach((child: TemplateIdDirective) => {
this.templates[child.id] = child.templateRef;
});
}
}