Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 7d77385

Browse files
committed
docs(cb-a11y): Building examples - Form controls
1 parent e296779 commit 7d77385

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

public/docs/_examples/cb-a11y/ts/app/a11y-form-controls.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ <h3>Explicit labeling</h3>
3939
<h3>Hiding labels</h3>
4040
<hr>
4141
</header>
42+
43+
<a11y-hidden-labels [label1]="'Search:'"
44+
[label2]="'Filter:'">
45+
</a11y-hidden-labels>
46+
4247
</section>
4348
<section class="row well">
4449
<header>

public/docs/_examples/cb-a11y/ts/app/a11y-form-controls.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {A11yHelper} from "./services/a11y-helper.service";
77
import {A11yRadiobuttons} from "./a11y-radiobuttons.component";
88
import {A11ySelect} from "./a11y-select.component";
99
import {A11yTextarea} from "./a11y-textarea.component";
10+
import {A11yHiddenLabels} from "./a11y-hidden-labels.component";
1011

1112
@Component({
1213
selector: 'a11y-form-controls',
@@ -19,7 +20,8 @@ import {A11yTextarea} from "./a11y-textarea.component";
1920
A11yCheckboxes,
2021
A11yRadiobuttons,
2122
A11ySelect,
22-
A11yTextarea
23+
A11yTextarea,
24+
A11yHiddenLabels
2325
]
2426
})
2527
export class A11yFormControls implements OnInit {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
label {
2+
border: 0;
3+
clip: rect(0 0 0 0);
4+
height: 1px;
5+
margin: -1px;
6+
overflow: hidden;
7+
padding: 0;
8+
position: absolute;
9+
width: 1px;
10+
}
11+
12+
input {
13+
margin-bottom: 1em;
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div class="form-group">
2+
3+
<label [attr.for]="uniqueId">
4+
{{label1}}
5+
</label>
6+
<input [id]="uniqueId"
7+
placeholder="Search... (Label hidden with style)"
8+
class="form-control">
9+
10+
<input placeholder="Filter... (Labelled with aria-label)"
11+
[attr.aria-label]="label2"
12+
class="form-control">
13+
14+
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {Component, OnInit, Input} from "angular2/core";
2+
import {A11yHelper} from "./services/a11y-helper.service";
3+
4+
@Component({
5+
selector: 'a11y-hidden-labels',
6+
templateUrl: './app/a11y-hidden-labels.component.html',
7+
styleUrls: ['./app/a11y-hidden-labels.component.css']
8+
})
9+
export class A11yHiddenLabels implements OnInit{
10+
@Input()
11+
label1:string;
12+
@Input()
13+
label2: string;
14+
15+
uniqueId:string;
16+
17+
constructor(private _a11yHelper:A11yHelper){}
18+
19+
ngOnInit(){
20+
this.uniqueId = this._a11yHelper.generateUniqueIdString();
21+
}
22+
}

0 commit comments

Comments
 (0)