src/app/app.component.ts
| selector | app-root |
| styleUrls | ./app.component.css |
| templateUrl | ./app.component.html |
Properties |
Methods |
| clearAll |
clearAll()
|
|
Defined in src/app/app.component.ts:165
|
|
Returns :
void
|
| deleteTodo | ||||||
deleteTodo(id: number)
|
||||||
|
Defined in src/app/app.component.ts:161
|
||||||
|
Parameters :
Returns :
void
|
| selectByStatus | ||||||
selectByStatus(status: string)
|
||||||
|
Defined in src/app/app.component.ts:147
|
||||||
|
Parameters :
Returns :
void
|
| selectedTodos | ||||||
selectedTodos(status: string)
|
||||||
|
Defined in src/app/app.component.ts:151
|
||||||
|
Parameters :
Returns :
any
|
| setValue |
setValue()
|
|
Defined in src/app/app.component.ts:136
|
|
Returns :
void
|
| newTodo |
Type : string
|
Default value : ''
|
|
Defined in src/app/app.component.ts:135
|
| statusSelected |
Type : string
|
Default value : 'all'
|
|
Defined in src/app/app.component.ts:146
|
| title |
Type : string
|
Default value : 'todo-app'
|
|
Defined in src/app/app.component.ts:10
|
| todos |
Type : Todo[]
|
Default value : [
{
id: 1,
todo: 'Do something nice for someone I care about',
completed: true,
userId: 26,
},
{
id: 2,
todo: 'Memorize the fifty states and their capitals',
completed: false,
userId: 48,
},
{ id: 3, todo: 'Watch a classic movie', completed: false, userId: 4 },
{
id: 4,
todo: 'Contribute code or a monetary donation to an open-source software project',
completed: false,
userId: 48,
},
{ id: 5, todo: "Solve a Rubik's cube", completed: false, userId: 31 },
{
id: 6,
todo: 'Bake pastries for me and neighbor',
completed: false,
userId: 39,
},
{
id: 7,
todo: 'Go see a Broadway production',
completed: false,
userId: 32,
},
{
id: 8,
todo: 'Write a thank you letter to an influential person in my life',
completed: true,
userId: 13,
},
{
id: 9,
todo: 'Invite some friends over for a game night',
completed: false,
userId: 47,
},
{
id: 10,
todo: 'Have a football scrimmage with some friends',
completed: false,
userId: 19,
},
{
id: 11,
todo: "Text a friend I haven't talked to in a long time",
completed: false,
userId: 39,
},
{ id: 12, todo: 'Organize pantry', completed: true, userId: 39 },
{
id: 13,
todo: 'Buy a new house decoration',
completed: false,
userId: 16,
},
{
id: 14,
todo: "Plan a vacation I've always wanted to take",
completed: false,
userId: 28,
},
{ id: 15, todo: 'Clean out car', completed: false, userId: 33 },
{ id: 16, todo: 'Draw and color a Mandala', completed: true, userId: 24 },
{
id: 17,
todo: 'Create a cookbook with favorite recipes',
completed: false,
userId: 1,
},
{
id: 18,
todo: 'Bake a pie with some friends',
completed: false,
userId: 1,
},
{ id: 19, todo: 'Create a compost pile', completed: true, userId: 5 },
{
id: 20,
todo: 'Take a hike at a local park',
completed: true,
userId: 43,
},
{
id: 21,
todo: 'Take a class at local community center that interests you',
completed: false,
userId: 22,
},
{
id: 22,
todo: 'Research a topic interested in',
completed: false,
userId: 4,
},
{
id: 23,
todo: 'Plan a trip to another country',
completed: true,
userId: 37,
},
{ id: 24, todo: 'Improve touch typing', completed: false, userId: 45 },
{ id: 25, todo: 'Learn Express.js', completed: false, userId: 49 },
{ id: 26, todo: 'Learn calligraphy', completed: false, userId: 50 },
{
id: 27,
todo: 'Have a photo session with some friends',
completed: false,
userId: 14,
},
{ id: 28, todo: 'Go to the gym', completed: false, userId: 15 },
{ id: 29, todo: 'Make own LEGO creation', completed: false, userId: 30 },
{ id: 30, todo: 'Take cat on a walk', completed: false, userId: 15 },
]
|
|
Defined in src/app/app.component.ts:12
|
import { Component } from '@angular/core';
import { Todo } from './Todo';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title: string = 'todo-app';
todos: Todo[] = [
{
id: 1,
todo: 'Do something nice for someone I care about',
completed: true,
userId: 26,
},
{
id: 2,
todo: 'Memorize the fifty states and their capitals',
completed: false,
userId: 48,
},
{ id: 3, todo: 'Watch a classic movie', completed: false, userId: 4 },
{
id: 4,
todo: 'Contribute code or a monetary donation to an open-source software project',
completed: false,
userId: 48,
},
{ id: 5, todo: "Solve a Rubik's cube", completed: false, userId: 31 },
{
id: 6,
todo: 'Bake pastries for me and neighbor',
completed: false,
userId: 39,
},
{
id: 7,
todo: 'Go see a Broadway production',
completed: false,
userId: 32,
},
{
id: 8,
todo: 'Write a thank you letter to an influential person in my life',
completed: true,
userId: 13,
},
{
id: 9,
todo: 'Invite some friends over for a game night',
completed: false,
userId: 47,
},
{
id: 10,
todo: 'Have a football scrimmage with some friends',
completed: false,
userId: 19,
},
{
id: 11,
todo: "Text a friend I haven't talked to in a long time",
completed: false,
userId: 39,
},
{ id: 12, todo: 'Organize pantry', completed: true, userId: 39 },
{
id: 13,
todo: 'Buy a new house decoration',
completed: false,
userId: 16,
},
{
id: 14,
todo: "Plan a vacation I've always wanted to take",
completed: false,
userId: 28,
},
{ id: 15, todo: 'Clean out car', completed: false, userId: 33 },
{ id: 16, todo: 'Draw and color a Mandala', completed: true, userId: 24 },
{
id: 17,
todo: 'Create a cookbook with favorite recipes',
completed: false,
userId: 1,
},
{
id: 18,
todo: 'Bake a pie with some friends',
completed: false,
userId: 1,
},
{ id: 19, todo: 'Create a compost pile', completed: true, userId: 5 },
{
id: 20,
todo: 'Take a hike at a local park',
completed: true,
userId: 43,
},
{
id: 21,
todo: 'Take a class at local community center that interests you',
completed: false,
userId: 22,
},
{
id: 22,
todo: 'Research a topic interested in',
completed: false,
userId: 4,
},
{
id: 23,
todo: 'Plan a trip to another country',
completed: true,
userId: 37,
},
{ id: 24, todo: 'Improve touch typing', completed: false, userId: 45 },
{ id: 25, todo: 'Learn Express.js', completed: false, userId: 49 },
{ id: 26, todo: 'Learn calligraphy', completed: false, userId: 50 },
{
id: 27,
todo: 'Have a photo session with some friends',
completed: false,
userId: 14,
},
{ id: 28, todo: 'Go to the gym', completed: false, userId: 15 },
{ id: 29, todo: 'Make own LEGO creation', completed: false, userId: 30 },
{ id: 30, todo: 'Take cat on a walk', completed: false, userId: 15 },
];
newTodo: string = '';
setValue() {
this.todos.push({
id: !this.todos.length ? 1 : this.todos[this.todos.length - 1].id + 1,
todo: this.newTodo,
completed: false,
userId: 26,
});
this.newTodo = '';
}
statusSelected: string = 'all';
selectByStatus(status: string) {
this.statusSelected = status;
}
selectedTodos(status: string) {
return this.statusSelected == 'all'
? this.todos
: this.todos.filter((todo: Todo) => {
return this.statusSelected == 'pending'
? !todo.completed
: todo.completed;
});
}
deleteTodo(id: number) {
this.todos = this.todos.filter((todo: Todo) => todo.id !== id);
}
clearAll() {
this.todos = [];
}
}
<app-nav-bar></app-nav-bar>
<router-outlet></router-outlet>
<app-footer></app-footer>
./app.component.css
@import "~bootstrap-icons/font/bootstrap-icons.css";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
::selection {
color: #fff;
background: #f12711;
}
.wrapper {
max-width: 405px;
background: #fff;
margin: 137px auto;
border-radius: 7px;
padding: 28px 0 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.task-input {
position: relative;
height: 52px;
padding: 0 25px;
}
.task-input ion-icon {
position: absolute;
top: 50%;
color: #999;
font-size: 25px;
transform: translate(17px, -50%);
}
.task-input input {
height: 100%;
width: 100%;
outline: none;
font-size: 18px;
border-radius: 5px;
padding: 0 20px 0 53px;
border: 1px solid #999;
}
.task-input input:focus,
.task-input input.active {
padding-left: 52px;
border: 2px solid #f12711;
}
.task-input input::placeholder {
color: #bfbfbf;
}
.controls,
li {
display: flex;
align-items: center;
justify-content: space-between;
}
.controls {
padding: 18px 25px;
border-bottom: 1px solid #ccc;
}
.filters span {
margin: 0 8px;
font-size: 17px;
color: #444444;
cursor: pointer;
}
.filters span:first-child {
margin-left: 0;
}
.filters span.active {
color: #f12711;
}
.clear-btn {
border: none;
opacity: 0.6;
outline: none;
color: #fff;
cursor: pointer;
font-size: 13px;
padding: 7px 13px;
border-radius: 4px;
letter-spacing: 0.3px;
transition: transform 0.25s ease;
background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
}
.clear-btn.active {
opacity: 0.9;
pointer-events: auto;
}
.clear-btn:active {
transform: scale(0.93);
}
.task-box {
margin-top: 20px;
margin-right: 5px;
padding: 0 20px 10px 25px;
}
.task-box.overflow {
overflow-y: auto;
max-height: 300px;
}
.task-box::-webkit-scrollbar {
width: 5px;
}
.task-box::-webkit-scrollbar-track {
background: #f12711;
border-radius: 25px;
}
.task-box::-webkit-scrollbar-thumb {
background: #e6e6e6;
border-radius: 25px;
}
@media (max-width: 400px) {
body {
padding: 0 10px;
}
.wrapper {
padding: 20px 0;
}
.filters span {
margin: 0 5px;
}
.task-input {
padding: 0 20px;
}
.controls {
padding: 18px 20px;
}
.task-box {
margin-top: 20px;
margin-right: 5px;
padding: 0 15px 10px 20px;
}
.task label input {
margin-top: 4px;
}
}