├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── browserslist ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.ts │ ├── app.module.ts │ ├── edit-todo-dialog │ │ ├── edit-todo-dialog.component.html │ │ ├── edit-todo-dialog.component.scss │ │ └── edit-todo-dialog.component.ts │ ├── shared │ │ ├── data.service.ts │ │ ├── todo.model.ts │ │ ├── tool-tip-singleton.directive.ts │ │ └── tool-tip.directive.ts │ ├── todo-item │ │ ├── todo-item.component.html │ │ ├── todo-item.component.scss │ │ └── todo-item.component.ts │ └── todos │ │ ├── todos.component.html │ │ ├── todos.component.scss │ │ └── todos.component.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss └── test.ts ├── tsconfig.app.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AngularTodoApp 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.6. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-todo-app": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss", 11 | "skipTests": true 12 | }, 13 | "@schematics/angular:class": { 14 | "skipTests": true 15 | }, 16 | "@schematics/angular:directive": { 17 | "skipTests": true 18 | }, 19 | "@schematics/angular:guard": { 20 | "skipTests": true 21 | }, 22 | "@schematics/angular:interceptor": { 23 | "skipTests": true 24 | }, 25 | "@schematics/angular:module": { 26 | "skipTests": true 27 | }, 28 | "@schematics/angular:pipe": { 29 | "skipTests": true 30 | }, 31 | "@schematics/angular:service": { 32 | "skipTests": true 33 | } 34 | }, 35 | "root": "", 36 | "sourceRoot": "src", 37 | "prefix": "app", 38 | "architect": { 39 | "build": { 40 | "builder": "@angular-devkit/build-angular:browser", 41 | "options": { 42 | "outputPath": "dist/angular-todo-app", 43 | "index": "src/index.html", 44 | "main": "src/main.ts", 45 | "polyfills": "src/polyfills.ts", 46 | "tsConfig": "tsconfig.app.json", 47 | "aot": true, 48 | "assets": [ 49 | "src/favicon.ico", 50 | "src/assets" 51 | ], 52 | "styles": [ 53 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 54 | "src/styles.scss" 55 | ], 56 | "scripts": [] 57 | }, 58 | "configurations": { 59 | "production": { 60 | "fileReplacements": [ 61 | { 62 | "replace": "src/environments/environment.ts", 63 | "with": "src/environments/environment.prod.ts" 64 | } 65 | ], 66 | "optimization": true, 67 | "outputHashing": "all", 68 | "sourceMap": false, 69 | "extractCss": true, 70 | "namedChunks": false, 71 | "extractLicenses": true, 72 | "vendorChunk": false, 73 | "buildOptimizer": true, 74 | "budgets": [ 75 | { 76 | "type": "initial", 77 | "maximumWarning": "2mb", 78 | "maximumError": "5mb" 79 | }, 80 | { 81 | "type": "anyComponentStyle", 82 | "maximumWarning": "6kb", 83 | "maximumError": "10kb" 84 | } 85 | ] 86 | } 87 | } 88 | }, 89 | "serve": { 90 | "builder": "@angular-devkit/build-angular:dev-server", 91 | "options": { 92 | "browserTarget": "angular-todo-app:build" 93 | }, 94 | "configurations": { 95 | "production": { 96 | "browserTarget": "angular-todo-app:build:production" 97 | } 98 | } 99 | }, 100 | "extract-i18n": { 101 | "builder": "@angular-devkit/build-angular:extract-i18n", 102 | "options": { 103 | "browserTarget": "angular-todo-app:build" 104 | } 105 | }, 106 | "test": { 107 | "builder": "@angular-devkit/build-angular:karma", 108 | "options": { 109 | "main": "src/test.ts", 110 | "polyfills": "src/polyfills.ts", 111 | "tsConfig": "tsconfig.spec.json", 112 | "karmaConfig": "karma.conf.js", 113 | "assets": [ 114 | "src/favicon.ico", 115 | "src/assets" 116 | ], 117 | "styles": [ 118 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 119 | "src/styles.scss" 120 | ], 121 | "scripts": [] 122 | } 123 | }, 124 | "lint": { 125 | "builder": "@angular-devkit/build-angular:tslint", 126 | "options": { 127 | "tsConfig": [ 128 | "tsconfig.app.json", 129 | "tsconfig.spec.json", 130 | "e2e/tsconfig.json" 131 | ], 132 | "exclude": [ 133 | "**/node_modules/**" 134 | ] 135 | } 136 | }, 137 | "e2e": { 138 | "builder": "@angular-devkit/build-angular:protractor", 139 | "options": { 140 | "protractorConfig": "e2e/protractor.conf.js", 141 | "devServerTarget": "angular-todo-app:serve" 142 | }, 143 | "configurations": { 144 | "production": { 145 | "devServerTarget": "angular-todo-app:serve:production" 146 | } 147 | } 148 | } 149 | } 150 | } 151 | }, 152 | "defaultProject": "angular-todo-app" 153 | } -------------------------------------------------------------------------------- /browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | baseUrl: 'http://localhost:4200/', 20 | framework: 'jasmine', 21 | jasmineNodeOpts: { 22 | showColors: true, 23 | defaultTimeoutInterval: 30000, 24 | print: function() {} 25 | }, 26 | onPrepare() { 27 | require('ts-node').register({ 28 | project: require('path').join(__dirname, './tsconfig.json') 29 | }); 30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 31 | } 32 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('angular-todo-app app is running!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo(): Promise { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/angular-todo-app'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-todo-app", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~9.1.7", 15 | "@angular/cdk": "^9.2.4", 16 | "@angular/common": "~9.1.7", 17 | "@angular/compiler": "~9.1.7", 18 | "@angular/core": "~9.1.7", 19 | "@angular/forms": "~9.1.7", 20 | "@angular/material": "^9.2.4", 21 | "@angular/platform-browser": "~9.1.7", 22 | "@angular/platform-browser-dynamic": "~9.1.7", 23 | "@angular/router": "~9.1.7", 24 | "bulma": "^0.9.0", 25 | "rxjs": "~6.5.4", 26 | "tippy.js": "^6.2.6", 27 | "tslib": "^1.10.0", 28 | "zone.js": "~0.10.2" 29 | }, 30 | "devDependencies": { 31 | "@angular-devkit/build-angular": "~0.901.6", 32 | "@angular/cli": "~9.1.6", 33 | "@angular/compiler-cli": "~9.1.7", 34 | "@types/node": "^12.11.1", 35 | "@types/jasmine": "~3.5.0", 36 | "@types/jasminewd2": "~2.0.3", 37 | "codelyzer": "^5.1.2", 38 | "jasmine-core": "~3.5.0", 39 | "jasmine-spec-reporter": "~4.2.1", 40 | "karma": "~5.0.0", 41 | "karma-chrome-launcher": "~3.1.0", 42 | "karma-coverage-istanbul-reporter": "~2.1.0", 43 | "karma-jasmine": "~3.0.1", 44 | "karma-jasmine-html-reporter": "^1.4.2", 45 | "protractor": "~5.4.3", 46 | "ts-node": "~8.3.0", 47 | "tslint": "~6.1.0", 48 | "typescript": "~3.8.3" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { TodosComponent } from './todos/todos.component'; 4 | 5 | 6 | const routes: Routes = [ 7 | { path: '', component: TodosComponent } 8 | ]; 9 | 10 | @NgModule({ 11 | imports: [RouterModule.forRoot(routes)], 12 | exports: [RouterModule] 13 | }) 14 | export class AppRoutingModule { } 15 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devstackr/angular-todo-app/94f8fc92b8487bdd98b62911456ce9ab6cd51116/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'angular-todo-app'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | 5 | import { AppRoutingModule } from './app-routing.module'; 6 | import { AppComponent } from './app.component'; 7 | import { TodosComponent } from './todos/todos.component'; 8 | import { TodoItemComponent } from './todo-item/todo-item.component'; 9 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 10 | import { EditTodoDialogComponent } from './edit-todo-dialog/edit-todo-dialog.component'; 11 | 12 | import { MatDialogModule } from '@angular/material/dialog'; 13 | import { ToolTipDirective } from './shared/tool-tip.directive'; 14 | import { ToolTipSingletonDirective } from './shared/tool-tip-singleton.directive'; 15 | 16 | @NgModule({ 17 | declarations: [ 18 | AppComponent, 19 | TodosComponent, 20 | TodoItemComponent, 21 | EditTodoDialogComponent, 22 | ToolTipDirective, 23 | ToolTipSingletonDirective 24 | ], 25 | imports: [ 26 | BrowserModule, 27 | AppRoutingModule, 28 | FormsModule, 29 | BrowserAnimationsModule, 30 | MatDialogModule 31 | ], 32 | providers: [], 33 | bootstrap: [AppComponent] 34 | }) 35 | export class AppModule { } 36 | -------------------------------------------------------------------------------- /src/app/edit-todo-dialog/edit-todo-dialog.component.html: -------------------------------------------------------------------------------- 1 |

Edit Todo

2 |
3 | 4 |
5 |
6 |
7 | 16 |
17 | 18 |
19 |

Please enter the text of your todo

20 |

Todo text must be at least 2 characters

21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | 36 |
37 |
38 |
39 | 40 |
-------------------------------------------------------------------------------- /src/app/edit-todo-dialog/edit-todo-dialog.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devstackr/angular-todo-app/94f8fc92b8487bdd98b62911456ce9ab6cd51116/src/app/edit-todo-dialog/edit-todo-dialog.component.scss -------------------------------------------------------------------------------- /src/app/edit-todo-dialog/edit-todo-dialog.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Inject } from '@angular/core'; 2 | import { NgForm } from '@angular/forms'; 3 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 4 | import { Todo } from '../shared/todo.model'; 5 | 6 | @Component({ 7 | selector: 'app-edit-todo-dialog', 8 | templateUrl: './edit-todo-dialog.component.html', 9 | styleUrls: ['./edit-todo-dialog.component.scss'] 10 | }) 11 | export class EditTodoDialogComponent implements OnInit { 12 | 13 | constructor( 14 | public dialogRef: MatDialogRef, 15 | @Inject(MAT_DIALOG_DATA) public todo: Todo) { } 16 | 17 | ngOnInit(): void { 18 | } 19 | 20 | close() { 21 | this.dialogRef.close() 22 | } 23 | 24 | onFormSubmit(form: NgForm) { 25 | if (form.invalid) return 26 | 27 | const updatedTodo = { 28 | ...this.todo, 29 | ...form.value 30 | } 31 | 32 | this.dialogRef.close(updatedTodo) 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/app/shared/data.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Todo } from './todo.model'; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class DataService { 8 | 9 | todos: Todo[] = [ 10 | // new Todo('this is a test!', false), 11 | // new Todo('Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit voluptates dolorem alias dolores deserunt, qui, amet odio facilis tempora unde sequi numquam explicabo nihil iste labore beatae ea rerum expedita.', true) 12 | ] 13 | 14 | constructor() { } 15 | 16 | getAllTodos() { 17 | return this.todos 18 | } 19 | 20 | addTodo(todo: Todo) { 21 | this.todos.push(todo) 22 | } 23 | 24 | updateTodo(index: number, updatedTodo: Todo) { 25 | this.todos[index] = updatedTodo 26 | } 27 | 28 | deleteTodo(index: number) { 29 | this.todos.splice(index, 1) 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/app/shared/todo.model.ts: -------------------------------------------------------------------------------- 1 | export class Todo { 2 | constructor( 3 | public text: string, 4 | public completed: boolean = false 5 | ) {} 6 | } -------------------------------------------------------------------------------- /src/app/shared/tool-tip-singleton.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ContentChildren, QueryList, AfterViewInit } from '@angular/core'; 2 | import { createSingleton } from 'tippy.js'; 3 | import { ToolTipDirective } from './tool-tip.directive'; 4 | 5 | @Directive({ 6 | selector: '[appToolTipSingleton]' 7 | }) 8 | export class ToolTipSingletonDirective implements AfterViewInit { 9 | 10 | @ContentChildren(ToolTipDirective, { descendants: true }) 11 | elementsWithTooltips: QueryList 12 | 13 | singletonInstance: any; 14 | 15 | constructor() { } 16 | 17 | ngAfterViewInit() { 18 | this.singletonInstance = createSingleton(this.getTippyInstances(), { 19 | delay: [200, 0], 20 | moveTransition: 'transform 0.2s ease-out' 21 | }) 22 | 23 | this.elementsWithTooltips.changes.subscribe(() => { 24 | this.singletonInstance.setInstances(this.getTippyInstances()) 25 | }) 26 | } 27 | 28 | getTippyInstances() { 29 | return this.elementsWithTooltips 30 | .toArray() 31 | .map(t => t.tippyInstance) 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/app/shared/tool-tip.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, AfterViewInit, Input, OnChanges, SimpleChanges } from '@angular/core'; 2 | import tippy from 'tippy.js' 3 | 4 | @Directive({ 5 | selector: '[appToolTip]' 6 | }) 7 | export class ToolTipDirective implements AfterViewInit, OnChanges { 8 | 9 | @Input('appToolTip') tooltipContent: string; 10 | 11 | public tippyInstance: any; 12 | 13 | constructor(private elRef: ElementRef) { } 14 | 15 | ngAfterViewInit() { 16 | this.tippyInstance = tippy(this.elRef.nativeElement, { 17 | content: this.tooltipContent 18 | }) 19 | } 20 | 21 | ngOnChanges(changes: SimpleChanges) { 22 | if (changes['tooltipContent']) { // input content has changed 23 | this.updateToolTipContent() 24 | } 25 | } 26 | 27 | updateToolTipContent() { 28 | if (this.tippyInstance) { 29 | this.tippyInstance.setContent(this.tooltipContent) 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/app/todo-item/todo-item.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | check 4 |
5 | 6 |
7 | {{ todo.text }} 8 |
9 | 10 |
11 |
12 | edit 13 |
14 | 15 |
16 | delete 17 |
18 |
19 |
-------------------------------------------------------------------------------- /src/app/todo-item/todo-item.component.scss: -------------------------------------------------------------------------------- 1 | .todo-item { 2 | display: flex; 3 | align-items: center; 4 | 5 | position: relative; 6 | 7 | cursor: pointer; 8 | 9 | font-size: 18px; 10 | 11 | padding: 35px 15px; 12 | 13 | border-bottom: 1px solid #f2f3f5; 14 | 15 | &.completed { 16 | color: #aaa; 17 | } 18 | } 19 | 20 | .todo-item .check-box { 21 | display: flex; 22 | 23 | flex-shrink: 0; 24 | 25 | border: 2px solid #eee; 26 | border-radius: 50%; 27 | 28 | margin-right: 20px; 29 | 30 | height: 28px; 31 | width: 28px; 32 | 33 | transition: background-color 0.2s, border-color 0.2s; 34 | 35 | i.material-icons { 36 | font-size: 20px; 37 | margin: auto; 38 | 39 | color: #333; 40 | 41 | // hide by default 42 | opacity: 0; 43 | 44 | transition: opacity 0.2s; 45 | } 46 | } 47 | 48 | .todo-item:hover .check-box { 49 | background: #eee; 50 | i.material-icons { 51 | opacity: 0.28; 52 | } 53 | } 54 | 55 | .todo-item.completed .check-box { 56 | background: rgb(11, 223, 170); 57 | border-color: rgb(11, 223, 170); 58 | 59 | i.material-icons { 60 | opacity: 1; 61 | } 62 | } 63 | 64 | .todo-item .todo-controls-box { 65 | position: absolute; 66 | bottom: 0; 67 | right: 5px; 68 | 69 | display: flex; 70 | 71 | // hide by default 72 | opacity: 0; 73 | visibility: hidden; 74 | transform: translateY(2px); 75 | 76 | transition: opacity 0.2s, visibility 0.2s, transform 0.2s; 77 | } 78 | 79 | .todo-item:hover .todo-controls-box { 80 | opacity: 1; 81 | visibility: visible; 82 | transition-delay: 0.4s; 83 | 84 | transform: translateY(0); 85 | } 86 | 87 | .todo-controls-box .todo-control-button { 88 | display: flex; 89 | background: #f5f7f8; 90 | 91 | padding: 7px 10px; 92 | 93 | i.material-icons { 94 | color: #555; 95 | font-size: 20px; 96 | } 97 | 98 | &:hover { 99 | background: #eee; 100 | 101 | i.material-icons { 102 | color: #333; 103 | } 104 | } 105 | 106 | &:active { 107 | background: #e5e7e8; 108 | } 109 | 110 | &:first-of-type { 111 | border-top-left-radius: 7px; 112 | } 113 | 114 | &:last-of-type { 115 | border-top-right-radius: 7px; 116 | } 117 | } 118 | 119 | .todo-controls-box .todo-control-button.is-danger:hover i.material-icons { 120 | color: rgb(155, 27, 27); 121 | } 122 | 123 | .todo-controls-box .todo-control-button.is-danger:active i.material-icons { 124 | color: rgb(189, 37, 37); 125 | } -------------------------------------------------------------------------------- /src/app/todo-item/todo-item.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; 2 | import { Todo } from '../shared/todo.model'; 3 | 4 | @Component({ 5 | selector: 'app-todo-item', 6 | templateUrl: './todo-item.component.html', 7 | styleUrls: ['./todo-item.component.scss'] 8 | }) 9 | export class TodoItemComponent implements OnInit { 10 | 11 | @Input() todo: Todo 12 | 13 | @Output() todoClicked: EventEmitter = new EventEmitter() 14 | @Output() editClicked: EventEmitter = new EventEmitter() 15 | @Output() deleteClicked: EventEmitter = new EventEmitter() 16 | 17 | constructor() { } 18 | 19 | ngOnInit(): void { 20 | } 21 | 22 | onTodoClicked() { 23 | this.todoClicked.emit() 24 | } 25 | 26 | onEditClicked() { 27 | this.editClicked.emit() 28 | } 29 | 30 | onDeleteClicked() { 31 | this.deleteClicked.emit() 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/app/todos/todos.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Todos

3 |
4 | 5 |
6 |
7 | 8 |
9 |

New Todo

10 | 11 |
12 |

13 | 14 |

15 |

16 | 20 |

21 |
22 | 23 |
24 |

Please enter the text of your todo

25 |

Todo text must be at least 2 characters

26 |
27 |
28 | 29 |
30 |
31 | 32 |
33 |
34 | 35 |
36 | 37 | 44 | 45 |
46 | 47 |
48 |
-------------------------------------------------------------------------------- /src/app/todos/todos.component.scss: -------------------------------------------------------------------------------- 1 | .heading-section { 2 | background: linear-gradient(to right, rgb(2, 228, 171), rgb(74, 215, 240)); 3 | 4 | padding: 100px; 5 | padding-bottom: 150px; 6 | 7 | h1.title { 8 | font-weight: bold; 9 | color: white; 10 | text-shadow: 0px 1px 2px rgba(black, 0.12); 11 | } 12 | } 13 | 14 | .container { 15 | max-width: 800px; 16 | } 17 | 18 | .add-todo-box-container { 19 | position: sticky; 20 | top: 0; 21 | z-index: 1; 22 | } 23 | 24 | .add-todo-box { 25 | padding: 25px; 26 | background: white; 27 | 28 | border-radius: 4px; 29 | margin-top: -68px; 30 | 31 | box-shadow: 0 4px 12px rgba(black, 0.08); 32 | } -------------------------------------------------------------------------------- /src/app/todos/todos.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { Todo } from '../shared/todo.model'; 3 | import { DataService } from '../shared/data.service'; 4 | import { NgForm } from '@angular/forms'; 5 | import { MatDialog } from '@angular/material/dialog'; 6 | import { EditTodoDialogComponent } from '../edit-todo-dialog/edit-todo-dialog.component'; 7 | 8 | @Component({ 9 | selector: 'app-todos', 10 | templateUrl: './todos.component.html', 11 | styleUrls: ['./todos.component.scss'] 12 | }) 13 | export class TodosComponent implements OnInit { 14 | 15 | todos: Todo[] 16 | showValidationErrors: boolean 17 | 18 | constructor(private dataService: DataService, private dialog: MatDialog) { } 19 | 20 | ngOnInit(): void { 21 | this.todos = this.dataService.getAllTodos() 22 | } 23 | 24 | onFormSubmit(form: NgForm) { 25 | if (form.invalid) return this.showValidationErrors = true 26 | 27 | this.dataService.addTodo(new Todo(form.value.text)) 28 | 29 | this.showValidationErrors = false 30 | form.reset() 31 | } 32 | 33 | toggleCompleted(todo: Todo) { 34 | todo.completed = !todo.completed; 35 | } 36 | 37 | editTodo(todo: Todo) { 38 | const index = this.todos.indexOf(todo) 39 | 40 | let dialogRef = this.dialog.open(EditTodoDialogComponent, { 41 | width: '700px', 42 | data: todo 43 | }); 44 | 45 | dialogRef.afterClosed().subscribe((result) => { 46 | if (result) { 47 | this.dataService.updateTodo(index, result) 48 | } 49 | }) 50 | } 51 | 52 | deleteTodo(todo: Todo) { 53 | const index = this.todos.indexOf(todo) 54 | this.dataService.deleteTodo(index) 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devstackr/angular-todo-app/94f8fc92b8487bdd98b62911456ce9ab6cd51116/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devstackr/angular-todo-app/94f8fc92b8487bdd98b62911456ce9ab6cd51116/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularTodoApp 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | @import '../node_modules/bulma/bulma.sass'; 4 | 5 | @import '@angular/material/prebuilt-themes/indigo-pink.css'; 6 | 7 | @import 'tippy.js/dist/tippy.css'; 8 | 9 | html, body { height: 100%; } 10 | body { margin: 0; } 11 | 12 | .alt-gradient-button { 13 | border: none; 14 | background: linear-gradient(to right, rgb(236, 72, 140), rgb(240, 54, 82)); 15 | color: white; 16 | font-weight: 600; 17 | opacity: 0.92; 18 | 19 | &:hover { 20 | opacity: 1; 21 | color: white; 22 | box-shadow: 0px 0px 0px 4px rgba(black, 0.05); 23 | } 24 | 25 | &:active { 26 | opacity: 0.8; 27 | } 28 | 29 | &:focus { 30 | color: white; 31 | opacity: 1; 32 | } 33 | 34 | i.material-icons { 35 | margin-right: 5px; 36 | margin-left: -3px; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": [ 8 | "src/main.ts", 9 | "src/polyfills.ts" 10 | ], 11 | "include": [ 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "module": "esnext", 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "lib": [ 15 | "es2018", 16 | "dom" 17 | ] 18 | }, 19 | "angularCompilerOptions": { 20 | "fullTemplateTypeCheck": true, 21 | "strictInjectionParameters": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "align": { 5 | "options": [ 6 | "parameters", 7 | "statements" 8 | ] 9 | }, 10 | "array-type": false, 11 | "arrow-return-shorthand": true, 12 | "curly": true, 13 | "deprecation": { 14 | "severity": "warning" 15 | }, 16 | "component-class-suffix": true, 17 | "contextual-lifecycle": true, 18 | "directive-class-suffix": true, 19 | "directive-selector": [ 20 | true, 21 | "attribute", 22 | "app", 23 | "camelCase" 24 | ], 25 | "component-selector": [ 26 | true, 27 | "element", 28 | "app", 29 | "kebab-case" 30 | ], 31 | "eofline": true, 32 | "import-blacklist": [ 33 | true, 34 | "rxjs/Rx" 35 | ], 36 | "import-spacing": true, 37 | "indent": { 38 | "options": [ 39 | "spaces" 40 | ] 41 | }, 42 | "max-classes-per-file": false, 43 | "max-line-length": [ 44 | true, 45 | 140 46 | ], 47 | "member-ordering": [ 48 | true, 49 | { 50 | "order": [ 51 | "static-field", 52 | "instance-field", 53 | "static-method", 54 | "instance-method" 55 | ] 56 | } 57 | ], 58 | "no-console": [ 59 | true, 60 | "debug", 61 | "info", 62 | "time", 63 | "timeEnd", 64 | "trace" 65 | ], 66 | "no-empty": false, 67 | "no-inferrable-types": [ 68 | true, 69 | "ignore-params" 70 | ], 71 | "no-non-null-assertion": true, 72 | "no-redundant-jsdoc": true, 73 | "no-switch-case-fall-through": true, 74 | "no-var-requires": false, 75 | "object-literal-key-quotes": [ 76 | true, 77 | "as-needed" 78 | ], 79 | "quotemark": [ 80 | true, 81 | "single" 82 | ], 83 | "semicolon": { 84 | "options": [ 85 | "always" 86 | ] 87 | }, 88 | "space-before-function-paren": { 89 | "options": { 90 | "anonymous": "never", 91 | "asyncArrow": "always", 92 | "constructor": "never", 93 | "method": "never", 94 | "named": "never" 95 | } 96 | }, 97 | "typedef-whitespace": { 98 | "options": [ 99 | { 100 | "call-signature": "nospace", 101 | "index-signature": "nospace", 102 | "parameter": "nospace", 103 | "property-declaration": "nospace", 104 | "variable-declaration": "nospace" 105 | }, 106 | { 107 | "call-signature": "onespace", 108 | "index-signature": "onespace", 109 | "parameter": "onespace", 110 | "property-declaration": "onespace", 111 | "variable-declaration": "onespace" 112 | } 113 | ] 114 | }, 115 | "variable-name": { 116 | "options": [ 117 | "ban-keywords", 118 | "check-format", 119 | "allow-pascal-case" 120 | ] 121 | }, 122 | "whitespace": { 123 | "options": [ 124 | "check-branch", 125 | "check-decl", 126 | "check-operator", 127 | "check-separator", 128 | "check-type", 129 | "check-typecast" 130 | ] 131 | }, 132 | "no-conflicting-lifecycle": true, 133 | "no-host-metadata-property": true, 134 | "no-input-rename": true, 135 | "no-inputs-metadata-property": true, 136 | "no-output-native": true, 137 | "no-output-on-prefix": true, 138 | "no-output-rename": true, 139 | "no-outputs-metadata-property": true, 140 | "template-banana-in-box": true, 141 | "template-no-negated-async": true, 142 | "use-lifecycle-interface": true, 143 | "use-pipe-transform-interface": true 144 | }, 145 | "rulesDirectory": [ 146 | "codelyzer" 147 | ] 148 | } --------------------------------------------------------------------------------