-
Notifications
You must be signed in to change notification settings - Fork 47
/
card.component.ts
43 lines (40 loc) · 1.3 KB
/
card.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
@Component({
selector: 'ag-card',
template: `<div [ngClass]="classes">
<ng-content></ng-content>
</div>`,
styleUrls: ['./card.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CardComponent {
@Input() css?: string;
@Input() type?: "success" | "info" | "warning" | "error";
@Input() isAnimated?: boolean;
@Input() isSkinned?: boolean = true;
@Input() isStacked?: boolean;
@Input() isShadow?: boolean;
@Input() isRounded?: boolean;
@Input() isBorder?: boolean;
public get classes(): string {
// classes() {
const baseClass = this.isSkinned ? 'card' : 'card-base';
const isAnimatedClass = this.isAnimated ? 'card-animated' : '';
const isStackedClass = this.isStacked ? 'card-stacked' : '';
const isShadowClass = this.isShadow ? 'card-shadow' : '';
const isRoundedClass = this.isRounded ? 'card-rounded' : '';
const isBorderClass = this.isBorder ? 'card-border' : '';
const typeClass = this.type ? `card-${this.type}` : '';
const overrides = this.css ? `${this.css}` : '';
return [
baseClass,
typeClass,
isAnimatedClass,
isStackedClass,
isShadowClass,
isRoundedClass,
isBorderClass,
overrides,
].join(' ');
}
}