import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { CommonModule } from '@angular/common'; export type CardVariant = 'elevated' | 'filled' | 'outlined'; export type CardSize = 'sm' | 'md' | 'lg'; export type CardElevation = 'none' | 'sm' | 'md' | 'lg' | 'xl'; export type CardRadius = 'none' | 'sm' | 'md' | 'lg' | 'full'; export type GlassVariant = 'translucent' | 'light' | 'medium' | 'heavy' | 'frosted'; @Component({ selector: 'ui-card', standalone: true, imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
@if (hasBackgroundLayer) {
}
@if (hasHeader) {
}
@if (hasFooter) { }
@if (glass) {
} @if (clickable && !disabled) {
}
`, styleUrl: './card.component.scss' }) export class CardComponent { @Input() variant: CardVariant = 'elevated'; @Input() size: CardSize = 'md'; @Input() elevation: CardElevation = 'sm'; @Input() radius: CardRadius = 'md'; @Input() disabled: boolean = false; @Input() clickable: boolean = false; @Input() glass: boolean = false; @Input() glassVariant: GlassVariant = 'medium'; @Input() backgroundImage?: string; @Input() hasBackgroundLayer: boolean = false; @Input() hasHeader: boolean = false; @Input() hasFooter: boolean = false; @Input() class: string = ''; @Output() cardClick = new EventEmitter(); get cardClasses(): string { return [ 'ui-card', `ui-card--${this.variant}`, `ui-card--${this.size}`, `ui-card--elevation-${this.elevation}`, `ui-card--radius-${this.radius}`, this.disabled ? 'ui-card--disabled' : '', this.clickable ? 'ui-card--clickable' : '', this.glass ? 'ui-card--glass' : '', this.glass ? `ui-card--glass-${this.glassVariant}` : '', this.hasBackgroundLayer ? 'ui-card--with-background' : '', this.class ].filter(Boolean).join(' '); } handleClick(event: Event): void { if (this.clickable && !this.disabled) { this.cardClick.emit(event); } } }