Skip to content

Commit

Permalink
added card and list component
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias.wright committed Apr 25, 2023
1 parent fe92fb6 commit 6371b70
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="container">
<h1>{{ title }}</h1>
<app-color-list></app-color-list>
</div>

<router-outlet></router-outlet>
6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ColorCardComponent } from './color-card/color-card.component';
import { ColorListComponent } from './color-list/color-list.component';

@NgModule({
declarations: [
AppComponent
AppComponent,
ColorCardComponent,
ColorListComponent
],
imports: [
BrowserModule,
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions src/app/color-card/color-card.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div [style.background-color]='htmlcolor'>
<p>{{cause}}</p>
<p>{{htmlcolor}}</p>
</div>
23 changes: 23 additions & 0 deletions src/app/color-card/color-card.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ColorCardComponent } from './color-card.component';

describe('ColorCardComponent', () => {
let component: ColorCardComponent;
let fixture: ComponentFixture<ColorCardComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ColorCardComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(ColorCardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
14 changes: 14 additions & 0 deletions src/app/color-card/color-card.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, Input } from '@angular/core';

@Component({
selector: 'app-color-card',
templateUrl: './color-card.component.html',
styleUrls: ['./color-card.component.css']
})
export class ColorCardComponent {
@Input() cause:string = "pink"
@Input() htmlcolor:string ="pink"
constructor() { }


}
Empty file.
6 changes: 6 additions & 0 deletions src/app/color-list/color-list.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul>
<li *ngFor ="let item of list">
<app-color-card [cause]="item.cause" [htmlcolor]="item.htmlcolor"></app-color-card>
</li>
</ul>

23 changes: 23 additions & 0 deletions src/app/color-list/color-list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ColorListComponent } from './color-list.component';

describe('ColorListComponent', () => {
let component: ColorListComponent;
let fixture: ComponentFixture<ColorListComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ColorListComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(ColorListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions src/app/color-list/color-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-color-list',
templateUrl: './color-list.component.html',
styleUrls: ['./color-list.component.css']
})
export class ColorListComponent {
list: {"cause":string, "htmlcolor":string}[] =[{"cause":"Breast Cancer","htmlcolor":"pink"},{"cause":"Birth Parents","htmlcolor":"pink"},{"cause":"Nursing Mothers","htmlcolor":"pink"}]
}

0 comments on commit 6371b70

Please sign in to comment.