Use of ng-content: Use shared UI component. Here, card.component.
All checks were successful
Deploying Website / build (push) Successful in 1m4s

This commit is contained in:
Maxime Delporte 2025-04-22 06:29:32 -03:00
parent c9aa8f647e
commit 1e0a493bf3
10 changed files with 47 additions and 27 deletions

View File

@ -0,0 +1,5 @@
div {
border-radius: 6px;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
overflow: hidden;
}

View File

@ -0,0 +1,3 @@
<div>
<ng-content />
</div>

View File

@ -0,0 +1,11 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-card',
imports: [],
templateUrl: './card.component.html',
styleUrl: './card.component.css'
})
export class CardComponent {
}

View File

@ -2,7 +2,6 @@ article {
padding: 1rem; padding: 1rem;
color: #25113d; color: #25113d;
background-color: #bf9ee5; background-color: #bf9ee5;
border-radius: 8px;
} }
h2 { h2 {

View File

@ -1,8 +1,10 @@
<article> <app-card>
<article>
<h2>{{ task.title }}</h2> <h2>{{ task.title }}</h2>
<time>Date: {{ task.dueDate }}</time> <time>Date: {{ task.dueDate }}</time>
<p>{{ task.summary }}</p> <p>{{ task.summary }}</p>
<p class="actions"> <p class="actions">
<button (click)="onCompleteTask()">Complete</button> <button (click)="onCompleteTask()">Complete</button>
</p> </p>
</article> </article>
</app-card>

View File

@ -1,9 +1,12 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import { Task } from './task.model'; import { Task } from './task.model';
import {CardComponent} from '../shared/card/card.component';
@Component({ @Component({
selector: 'app-task', selector: 'app-task',
imports: [], imports: [
CardComponent
],
templateUrl: './task.component.html', templateUrl: './task.component.html',
styleUrl: './task.component.css' styleUrl: './task.component.css'
}) })

View File

@ -1,6 +1,6 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import {User} from '../user/user.model'; import { type User} from '../user/user.model';
import {NewTaskData, Task} from '../task/task.model'; import { type NewTaskData, type Task } from '../task/task.model';
import {TaskComponent} from '../task/task.component'; import {TaskComponent} from '../task/task.component';
import {NewTaskComponent} from './new-task/new-task.component'; import {NewTaskComponent} from './new-task/new-task.component';
@ -55,18 +55,17 @@ export class TasksComponent {
this.isAddingTask = false; this.isAddingTask = false;
} }
onAddTask(taskContent: NewTaskData) { onAddTask(taskData: NewTaskData) {
let nextTaskId = this.tasks.length + 1; let nextTaskId = this.tasks.length + 1;
let taskId = 't' + (nextTaskId).toString(); let taskId = 't' + (nextTaskId).toString();
let task: Task = { this.tasks.push({
id: taskId, id: taskId,
userId: this.user.id, userId: this.user.id,
title: taskContent.title, title: taskData.title,
summary: taskContent.summary, summary: taskData.summary,
dueDate: taskContent.date, dueDate: taskData.date,
}; });
this.tasks.push(task);
this.onCancelAddTask() this.onCancelAddTask()
} }

View File

@ -1,9 +1,3 @@
div {
border-radius: 6px;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
button { button {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -1,4 +1,4 @@
<div> <app-card>
<button <button
[class.active]="selected" [class.active]="selected"
(click)="onSelectUser()" (click)="onSelectUser()"
@ -9,4 +9,4 @@
/> />
<span>{{ user.name }}</span> <span>{{ user.name }}</span>
</button> </button>
</div> </app-card>

View File

@ -1,10 +1,14 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import { User } from './user.model'; import { User } from './user.model';
import {CardComponent} from '../shared/card/card.component';
@Component({ @Component({
selector: 'app-user', selector: 'app-user',
standalone: true, standalone: true,
templateUrl: './user.component.html', templateUrl: './user.component.html',
imports: [
CardComponent
],
styleUrl: './user.component.css' styleUrl: './user.component.css'
}) })
export class UserComponent { export class UserComponent {