docs: improve accessibility of architecture example (#41314)
PR Close #41314
This commit is contained in:
parent
326884736e
commit
01e546f116
|
@ -88,7 +88,7 @@ async function heroFromDetail(detail: ElementFinder): Promise<Hero> {
|
||||||
// Get hero id from the first <div>
|
// Get hero id from the first <div>
|
||||||
const id = await detail.all(by.css('div')).first().getText();
|
const id = await detail.all(by.css('div')).first().getText();
|
||||||
// Get name from the h2
|
// Get name from the h2
|
||||||
const name = await detail.element(by.css('h4')).getText();
|
const name = await detail.element(by.css('app-hero-detail h2')).getText();
|
||||||
return {
|
return {
|
||||||
id: +id.substr(id.indexOf(' ') + 1),
|
id: +id.substr(id.indexOf(' ') + 1),
|
||||||
name: name.substr(0, name.lastIndexOf(' ')),
|
name: name.substr(0, name.lastIndexOf(' ')),
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { Component } from '@angular/core';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
template: `
|
template: `
|
||||||
|
<h1>Architecture Example</h1>
|
||||||
<app-hero-list></app-hero-list>
|
<app-hero-list></app-hero-list>
|
||||||
<app-sales-tax></app-sales-tax>
|
<app-sales-tax></app-sales-tax>
|
||||||
`
|
`
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<hr>
|
<hr>
|
||||||
<h4>{{hero.name}} Detail</h4>
|
<h2>{{hero.name}} Detail</h2>
|
||||||
<div>Id: {{hero.id}}</div>
|
<div>Id: {{hero.id}}</div>
|
||||||
<label>Name:
|
<label for="hero-name">Name: </label>
|
||||||
<!-- #docregion ngModel -->
|
<!-- #docregion ngModel -->
|
||||||
<input [(ngModel)]="hero.name">
|
<input type="text" id="hero-name" [(ngModel)]="hero.name">
|
||||||
<!-- #enddocregion ngModel -->
|
<!-- #enddocregion ngModel -->
|
||||||
</label>
|
|
||||||
<br />
|
<label for="hero-power">Power: </label>
|
||||||
<label>Power: <input [(ngModel)]="hero.power"></label>
|
<input type="text" for="hero-name" [(ngModel)]="hero.power">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!-- #docregion -->
|
<!-- #docregion -->
|
||||||
<h2>Hero List</h2>
|
<h2>Hero List</h2>
|
||||||
|
|
||||||
<p><i>Pick a hero from the list</i></p>
|
<p><i>Select a hero from the list to see details.</i></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let hero of heroes" (click)="selectHero(hero)">
|
<li *ngFor="let hero of heroes" (click)="selectHero(hero)">
|
||||||
{{hero.name}}
|
{{hero.name}}
|
||||||
|
|
|
@ -7,11 +7,12 @@ import { TaxRateService } from './tax-rate.service';
|
||||||
selector: 'app-sales-tax',
|
selector: 'app-sales-tax',
|
||||||
template: `
|
template: `
|
||||||
<h2>Sales Tax Calculator</h2>
|
<h2>Sales Tax Calculator</h2>
|
||||||
<label>Amount: <input #amountBox (change)="0"></label>
|
<p><i>Enter a number and press enter to calculate tax.</i></p>
|
||||||
|
<label for="amount-input">Amount: </label>
|
||||||
|
<input type="text" id="amount-input" #amountBox (change)="0">
|
||||||
<div *ngIf="amountBox.value">
|
<div *ngIf="amountBox.value">
|
||||||
The sales tax is
|
<p>The sales tax is
|
||||||
{{ getTax(amountBox.value) | currency:'USD':true:'1.2-2' }}
|
{{ getTax(amountBox.value) | currency:'USD':true:'1.2-2' }}</p>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
providers: [SalesTaxService, TaxRateService]
|
providers: [SalesTaxService, TaxRateService]
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
ul {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: aliceblue;
|
||||||
|
border: 1px solid #444;
|
||||||
|
margin-bottom: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
li:hover {
|
||||||
|
background-color: #444;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
padding-bottom: .4rem;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
|
@ -5,7 +5,8 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href="/">
|
<base href="/">
|
||||||
|
<link rel="stylesheet" href="assets/architecture.css">
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue