-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathcard.component.ts
More file actions
62 lines (56 loc) · 1.91 KB
/
card.component.ts
File metadata and controls
62 lines (56 loc) · 1.91 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { NgOptimizedImage } from '@angular/common';
import { Component, input, output, TemplateRef } from '@angular/core';
import { CardType } from '../../model/card.model';
import { ListItemComponent } from '../list-item/list-item.component';
@Component({
selector: 'app-card',
template: `
<div
class="flex w-fit flex-col gap-3 rounded-md border-2 border-black p-4"
[class]="customClass()">
<ng-content select="[card-image]" />
<!-- @if (type() === CardType.TEACHER) {-->
<!-- <img ngSrc="assets/img/teacher.png" width="200" height="200" />-->
<!-- }-->
<!-- @if (type() === CardType.STUDENT) {-->
<!-- <img ngSrc="assets/img/student.webp" width="200" height="200" />-->
<!-- }-->
<section>
@for (item of list(); track item) {
<app-list-item
[item]="item"
[itemTemplate]="itemTemplateRef()"></app-list-item>
}
</section>
<button
class="rounded-sm border border-blue-500 bg-blue-300 p-2"
(click)="addNewItem()">
Add
</button>
</div>
`,
imports: [ListItemComponent, NgOptimizedImage],
})
export class CardComponent {
// private teacherStore = inject(TeacherStore);
// private studentStore = inject(StudentStore);
readonly list = input<any[] | null>(null);
// readonly type = input.required<CardType>();
readonly customClass = input('');
listItemDeleted = output<any>();
readonly itemTemplateRef = input.required<TemplateRef<any>>();
itemAdded = output();
CardType = CardType;
addNewItem() {
this.itemAdded.emit();
// const type = this.type();
// if (type === CardType.TEACHER) {
// this.teacherStore.addOne(randTeacher());
// } else if (type === CardType.STUDENT) {
// this.studentStore.addOne(randStudent());
// }
}
deleteListItem(item: any) {
this.listItemDeleted.emit(item);
}
}