All files / app/features/picture/components/picture-card picture-card.component.ts

100% Statements 16/16
100% Branches 6/6
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 293x                 3x 24x 24x 24x 24x   24x 24x   24x     4x 1x   3x 3x      
import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';
import { Picture } from '@drevo-web/shared';
 
@Component({
    selector: 'app-picture-card',
    templateUrl: './picture-card.component.html',
    styleUrl: './picture-card.component.scss',
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PictureCardComponent {
    readonly picture = input.required<Picture>();
    readonly width = input.required<number>();
    readonly height = input.required<number>();
    readonly rowHeight = input.required<number>();
 
    readonly isCapped = computed(() => this.height() < this.rowHeight());
    readonly detailUrl = computed(() => `/pictures/${this.picture().id}`);
 
    readonly pictureClick = output<Picture>();
 
    onClick(event: MouseEvent): void {
        if (event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {
            return;
        }
        event.preventDefault();
        this.pictureClick.emit(this.picture());
    }
}