aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/todo/todo-item
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-03-06 23:29:12 +0800
committerGitHub <noreply@github.com>2019-03-06 23:29:12 +0800
commit4b37c96de2c7d3fe046a6f342d2da8ef03d3c807 (patch)
treee5618cddfa6f637d7033ae5b52e6da825eb53c63 /Timeline/ClientApp/src/app/todo/todo-item
parentaca753fba19a221f1aec65030ba4aec4bc34f576 (diff)
parentb5e01c4571061cbaf5915aa4c0f1b7126ef1ed18 (diff)
downloadtimeline-4b37c96de2c7d3fe046a6f342d2da8ef03d3c807.tar.gz
timeline-4b37c96de2c7d3fe046a6f342d2da8ef03d3c807.tar.bz2
timeline-4b37c96de2c7d3fe046a6f342d2da8ef03d3c807.zip
Merge pull request #3 from crupest/user
Develop user dialog.
Diffstat (limited to 'Timeline/ClientApp/src/app/todo/todo-item')
-rw-r--r--Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.css25
-rw-r--r--Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.html9
-rw-r--r--Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.spec.ts46
-rw-r--r--Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.ts13
4 files changed, 93 insertions, 0 deletions
diff --git a/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.css b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.css
new file mode 100644
index 00000000..dcf25fd8
--- /dev/null
+++ b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.css
@@ -0,0 +1,25 @@
+.item-card {
+ padding: 0;
+ display: flex;
+ overflow: hidden;
+}
+
+.item-body-box {
+ margin: 5px!important
+}
+
+.item-color-block {
+ width: 15px;
+ align-self: stretch;
+ flex: 0 0 auto;
+}
+
+.item-title {
+ vertical-align: middle;
+}
+
+.item-detail-button {
+ width: unset;
+ height: unset;
+ line-height: unset;
+}
diff --git a/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.html b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.html
new file mode 100644
index 00000000..6f76e73b
--- /dev/null
+++ b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.html
@@ -0,0 +1,9 @@
+<mat-card class="mat-elevation-z2 item-card">
+ <span class="item-color-block" [class.color-block-closed]="item.isClosed" [class.color-block-open]="!item.isClosed"></span>
+ <div class="mat-h3 item-body-box">
+ <span class="item-title">{{ item.number }}. {{ item.title }}</span>
+ <a mat-icon-button class="item-detail-button" [href]="item.detailUrl">
+ <mat-icon>arrow_forward</mat-icon>
+ </a>
+ </div>
+</mat-card>
diff --git a/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.spec.ts b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.spec.ts
new file mode 100644
index 00000000..239ffc42
--- /dev/null
+++ b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.spec.ts
@@ -0,0 +1,46 @@
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+
+import { TodoItem } from '../todo-item';
+import { TodoItemComponent } from '../todo-item/todo-item.component';
+
+describe('TodoItemComponent', () => {
+ let component: TodoItemComponent;
+ let fixture: ComponentFixture<TodoItemComponent>;
+
+ const mockTodoItem: TodoItem = {
+ number: 1,
+ title: 'Title',
+ isClosed: true,
+ detailUrl: '/detail',
+ };
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [TodoItemComponent],
+ schemas: [NO_ERRORS_SCHEMA]
+ }).compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(TodoItemComponent);
+ component = fixture.componentInstance;
+ component.item = mockTodoItem;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('should set title', () => {
+ expect((fixture.debugElement.query(By.css('span.item-title')).nativeElement as HTMLSpanElement).textContent).toBe(
+ mockTodoItem.number + '. ' + mockTodoItem.title
+ );
+ });
+
+ it('should set detail link', () => {
+ expect(fixture.debugElement.query(By.css('a.item-detail-button')).properties['href']).toBe(mockTodoItem.detailUrl);
+ });
+});
diff --git a/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.ts b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.ts
new file mode 100644
index 00000000..2ea6997a
--- /dev/null
+++ b/Timeline/ClientApp/src/app/todo/todo-item/todo-item.component.ts
@@ -0,0 +1,13 @@
+import { Component, Input } from '@angular/core';
+import { TodoItem } from '../todo-item';
+
+@Component({
+ selector: 'app-todo-item',
+ templateUrl: './todo-item.component.html',
+ styleUrls: ['./todo-item.component.css', '../todo-list-color-block.css']
+})
+export class TodoItemComponent {
+
+ @Input() item: TodoItem;
+
+}