Use of ng-content: Use shared UI component. Here, card.component.
All checks were successful
Deploying Website / build (push) Successful in 1m4s
All checks were successful
Deploying Website / build (push) Successful in 1m4s
This commit is contained in:
parent
c9aa8f647e
commit
1e0a493bf3
5
src/app/shared/card/card.component.css
Normal file
5
src/app/shared/card/card.component.css
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
div {
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
3
src/app/shared/card/card.component.html
Normal file
3
src/app/shared/card/card.component.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<div>
|
||||||
|
<ng-content />
|
||||||
|
</div>
|
11
src/app/shared/card/card.component.ts
Normal file
11
src/app/shared/card/card.component.ts
Normal 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 {
|
||||||
|
|
||||||
|
}
|
@ -2,7 +2,6 @@ article {
|
|||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
color: #25113d;
|
color: #25113d;
|
||||||
background-color: #bf9ee5;
|
background-color: #bf9ee5;
|
||||||
border-radius: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<app-card>
|
||||||
<article>
|
<article>
|
||||||
<h2>{{ task.title }}</h2>
|
<h2>{{ task.title }}</h2>
|
||||||
<time>Date: {{ task.dueDate }}</time>
|
<time>Date: {{ task.dueDate }}</time>
|
||||||
@ -6,3 +7,4 @@
|
|||||||
<button (click)="onCompleteTask()">Complete</button>
|
<button (click)="onCompleteTask()">Complete</button>
|
||||||
</p>
|
</p>
|
||||||
</article>
|
</article>
|
||||||
|
</app-card>
|
||||||
|
@ -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'
|
||||||
})
|
})
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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>
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user