diff --git a/angular-tour-of-heroes/src/app/heroes/heroes.component.html b/angular-tour-of-heroes/src/app/heroes/heroes.component.html index 5c5084d..7450040 100644 --- a/angular-tour-of-heroes/src/app/heroes/heroes.component.html +++ b/angular-tour-of-heroes/src/app/heroes/heroes.component.html @@ -9,9 +9,18 @@

My Heroes

\ No newline at end of file + + +
+

{{selectedHero.name}} Details

+
id: {{selectedHero.id}}
+
+ + +
+
\ No newline at end of file diff --git a/angular-tour-of-heroes/src/app/heroes/heroes.component.scss b/angular-tour-of-heroes/src/app/heroes/heroes.component.scss index e69de29..9b8b843 100644 --- a/angular-tour-of-heroes/src/app/heroes/heroes.component.scss +++ b/angular-tour-of-heroes/src/app/heroes/heroes.component.scss @@ -0,0 +1,66 @@ +/* HeroesComponent's private CSS styles */ +.heroes { + margin: 0 0 2em 0; + list-style-type: none; + padding: 0; + width: 15em; +} + +.heroes li { + display: flex; +} + +.heroes button { + flex: 1; + cursor: pointer; + position: relative; + left: 0; + background-color: #EEE; + margin: .5em; + padding: 0; + border-radius: 4px; + display: flex; + align-items: stretch; + height: 1.8em; +} + +.heroes button:hover { + color: #2c3a41; + background-color: #e6e6e6; + left: .1em; +} + +.heroes button:active { + background-color: #525252; + color: #fafafa; +} + +.heroes button.selected { + background-color: black; + color: white; +} + +.heroes button.selected:hover { + background-color: #505050; + color: white; +} + +.heroes button.selected:active { + background-color: black; + color: white; +} + +.heroes .badge { + display: inline-block; + font-size: small; + color: white; + padding: 0.8em 0.7em 0 0.7em; + background-color: #405061; + line-height: 1em; + margin-right: .8em; + border-radius: 4px 0 0 4px; +} + +.heroes .name { + align-self: center; +} \ No newline at end of file diff --git a/angular-tour-of-heroes/src/app/heroes/heroes.component.ts b/angular-tour-of-heroes/src/app/heroes/heroes.component.ts index 98651ad..276de05 100644 --- a/angular-tour-of-heroes/src/app/heroes/heroes.component.ts +++ b/angular-tour-of-heroes/src/app/heroes/heroes.component.ts @@ -1,13 +1,13 @@ import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { NgFor } from '@angular/common'; +import { NgFor, NgIf } from '@angular/common'; import { Hero } from '../hero' import { HEROES } from '../mock-heroes'; @Component({ selector: 'app-heroes', - imports: [FormsModule, NgFor], + imports: [FormsModule, NgFor, NgIf], templateUrl: './heroes.component.html', styleUrl: './heroes.component.scss' }) @@ -17,4 +17,8 @@ export class HeroesComponent { name: 'Windstorm' }; heroes = HEROES; + selectedHero?: Hero; + onSelect(hero: Hero): void { + this.selectedHero = hero; + } }