This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* HeroesComponent's private CSS styles */ | |
.selected { | |
background-color: #CFD8DC !important; | |
color: white; | |
} | |
.heroes { | |
margin: 0 0 2em 0; | |
list-style-type: none; | |
padding: 0; | |
width: 15em; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="heroes"> | |
{this.heroes.map((hero) => | |
<li> | |
<span class="badge">{hero.id}</span> {hero.name} | |
</li> | |
)} | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>{ this.selectedHero.name.toUpperCase() } Details</h2> | |
<div><span>id: </span>{this.selectedHero.id}</div> | |
<div> | |
<label>name: | |
<input type="text" value={this.selectedHero.name} onInput={(event) => this.handleChangeName(event)} placeholder="name" /> | |
</label> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{this.selectedHero ? ( | |
<div> | |
<h2>{ this.selectedHero.name.toUpperCase() } Details</h2> | |
<div><span>id: </span>{this.selectedHero.id}</div> | |
<div> | |
<label>name: | |
<input type="text" value={this.selectedHero.name} onInput={(event) => this.handleChangeName(event)} placeholder="name" /> | |
</label> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from '@stencil/core/testing'; | |
import { HeroDetails } from './hero-details'; | |
describe('app-hero-details', () => { | |
it('should build', () => { | |
expect(new HeroDetails()).toBeTruthy(); | |
}); | |
describe('rendering', () => { | |
beforeEach(async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Prop } from '@stencil/core'; | |
import { Hero } from '../../models/hero'; | |
@Component({ | |
tag: 'app-hero-details', | |
styleUrl: 'hero-details.css' | |
}) | |
export class HeroDetails { | |
@Prop({ mutable: true }) private hero: Hero; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable } from 'rxjs'; | |
import { of } from 'rxjs'; | |
import { Hero } from '../models/hero'; | |
import { HEROES } from './mock-heroes'; | |
export class HeroService { | |
private static _instance: HeroService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private heroService: HeroService; | |
constructor() { | |
this.heroService = HeroService.Instance; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getHeroes(): void { | |
this.heroService.getHeroes() | |
.subscribe(heroes => this.heroes = heroes); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentWillLoad() { | |
this.getHeroes(); | |
} |