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

Commit 95db2f1

Browse files
committed
doc(cb-a11y): Labelling form controls: content
1 parent ed88b77 commit 95db2f1

File tree

2 files changed

+17
-177
lines changed

2 files changed

+17
-177
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ <h3>Implicit labeling</h3>
2121
<!-- #docregion cb-a11y-form-controls-textarea-implicit -->
2222
<div class="form-group">
2323
<label>Type some text:
24-
<input class="form-control"
25-
[(ngModel)]="textModel">
24+
<textarea class="form-control"
25+
[(ngModel)]="textModel"></textarea>
2626
</label>
2727
</div>
2828
<!-- #enddocregion -->
@@ -47,7 +47,7 @@ <h3>Implicit labeling</h3>
4747
<!-- #docregion cb-a11y-form-controls-radiobuttons-implicit -->
4848
<fieldset class="form-group row">
4949
<legend class="col-xs-12">
50-
Choose your favourite Angular 2 language
50+
Choose your favourite Angular 2 language:
5151
</legend>
5252
<div *ngFor="#radiobutton of radioButtons"
5353
class="radio col-xs-12">

public/docs/ts/latest/cookbook/a11y.jade

Lines changed: 14 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ include ../_util-fns
6464
that element instead of writing your own.
6565

6666
:marked
67-
So, for example, if you want to accept user text input, use the `INPUT` element instead of contructing something new.
67+
So, for example, if you want to accept user text input, use the `input` element instead of contructing something new.
6868

6969
This way you have to think less about things like focus management, tabindex, etc. and have more time to think about
7070
your code.
@@ -166,194 +166,34 @@ code-example(language="html" escape="html").
166166
</label>
167167

168168
:marked
169-
Easy, isn't it? Of course, here the `INPUT` element can be any native `HTML` form element.
169+
Easy, isn't it? Of course, here the `input` element can be any native `HTML` form element.
170170

171171
Let us now explore how we can use `implicit labelling` to decorate the commonly used native `HTML` form elements
172172
in our Angular&nbsp;2 components.
173173

174174
:marked
175-
#### Inputs
175+
#### Inputs and textareas
176176

177-
Component template:
178-
179-
+makeExample('cb-a11y/ts/app/form-controls/a11y-input.component.html')
180-
181-
:marked
182-
User writes:
183-
184-
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-input-usage')
185-
186-
:marked
187-
Rendered out:
188-
189-
code-example(language="html" escape="html" format="linenums").
190-
<a11y-input>
191-
<div class="form-group ">
192-
<label>
193-
Type something:
194-
<input class="form-control">
195-
</label>
196-
</div>
197-
</a11y-input>
198-
199-
:marked
200-
#### Textareas
201-
202-
Component template:
203-
204-
+makeExample('cb-a11y/ts/app/form-controls/a11y-textarea.component.html')
205-
206-
:marked
207-
User writes:
208-
209-
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-textarea-usage')
210-
211-
:marked
212-
Rendered out:
213-
214-
code-example(language="html" escape="html" format="linenums").
215-
<a11y-textarea>
216-
<div class="form-group">
217-
<label>Type some text:
218-
<textarea class="form-control"></textarea>
219-
</label>
220-
</div>
221-
</a11y-textarea>
222-
223-
:marked
224-
#### Checkboxes
225-
226-
.l-sub-section
227-
:marked
228-
Because of the many `input` fields making up a `checkbox group`, the usual rule applies for each input but the
229-
entire group also needs labelled and this is done by using `fieldset` and `legend`.
230-
231-
:marked
232-
Component template:
233-
234-
+makeExample('cb-a11y/ts/app/form-controls/a11y-checkboxes.component.html')
235-
236-
:marked
237-
User writes:
238-
239-
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-checkboxes-usage')
177+
+makeTabs('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html, cb-a11y/ts/app/form-controls/a11y-form-controls.component.html',
178+
'cb-a11y-form-controls-input-implicit,cb-a11y-form-controls-textarea-implicit',
179+
'Implicitly labelled input,Implicitly labelled textarea')
240180

241181
:marked
242-
Rendered out:
243-
244-
code-example(language="html" escape="html" format="linenums").
245-
<a11y-checkboxes>
246-
<fieldset class="form-group row">
247-
<legend class="col-xs-12">
248-
What do you like most about Angular 2?
249-
</legend>
250-
<div class="checkbox col-xs-12">
251-
<label>
252-
<input type="checkbox" value="0" name="likes">
253-
Template syntax
254-
</label>
255-
</div>
256-
<div class="checkbox col-xs-12">
257-
<label>
258-
<input type="checkbox" value="1" name="likes">
259-
Observables
260-
</label>
261-
</div>
262-
<div class="checkbox col-xs-12">
263-
<label>
264-
<input type="checkbox" value="2" name="likes">
265-
Components
266-
</label>
267-
</div>
268-
<div class="checkbox col-xs-12">
269-
<label>
270-
<input type="checkbox" value="3" name="likes">
271-
Forms
272-
</label>
273-
</div>
274-
</fieldset>
275-
</a11y-checkboxes>
276-
277-
:marked
278-
#### Radiobuttons
182+
#### Checkboxes and radiobuttons
279183

280184
.l-sub-section
281185
:marked
282-
As with the `checkbox group`, a `radiobutton group`, is also labelled using `fieldset` and `legend`.
186+
Because of the many `input` fields making up a `checkbox group` or `radiobutton group`, the usual rule applies
187+
for each input but the entire group also needs labelled and this is done by using `fieldset` and `legend`.
283188

284-
:marked
285-
Component template:
286-
287-
+makeExample('cb-a11y/ts/app/form-controls/a11y-radiobuttons.component.html')
288-
289-
:marked
290-
User writes:
291-
292-
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-radiobuttons-usage')
293-
294-
:marked
295-
Rendered out:
296-
297-
code-example(language="html" escape="html" format="linenums").
298-
<a11y-radiobuttons>
299-
<fieldset class="form-group row">
300-
<legend class="col-xs-12">
301-
Choose your favourite Angular 2 language:
302-
</legend>
303-
<div class="radio col-xs-12">
304-
<label>
305-
<input type="radio" value="0" name="language">
306-
TypeScript
307-
</label>
308-
</div>
309-
<div class="radio col-xs-12">
310-
<label>
311-
<input type="radio" value="1" name="language">
312-
JavaScript
313-
</label>
314-
</div>
315-
<div class="radio col-xs-12">
316-
<label>
317-
<input type="radio" value="2" name="language">
318-
ES6
319-
</label>
320-
</div>
321-
<div class="radio col-xs-12">
322-
<label>
323-
<input type="radio" value="3" name="language">
324-
Dart
325-
</label>
326-
</div>
327-
</fieldset>
328-
</a11y-radiobuttons>
189+
+makeTabs('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html, cb-a11y/ts/app/form-controls/a11y-form-controls.component.html',
190+
'cb-a11y-form-controls-checkboxes-implicit,cb-a11y-form-controls-radiobuttons-implicit',
191+
'Implicitly labelled Checkboxes,Implicitly labelled Radiobuttons')
329192

330193
:marked
331194
#### Select lists
332195

333-
Component template:
334-
335-
+makeExample('cb-a11y/ts/app/form-controls/a11y-select.component.html')
336-
337-
:marked
338-
User writes:
339-
340-
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-select-usage')
341-
342-
:marked
343-
Rendered out:
344-
345-
code-example(language="html" escape="html" format="linenums").
346-
<a11y-select>
347-
<div class="form-group">
348-
<label>Why are you interested in a11y?
349-
<select class="form-control">
350-
<option value="0">Curiosity</option>
351-
<option value="1">Increased userbase</option>
352-
<option value="2">Legal reasons</option>
353-
</select>
354-
</label>
355-
</div>
356-
</a11y-select>
196+
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-select-implicit')
357197

358198
:marked
359199
### Explicit labelling
@@ -371,7 +211,7 @@ code-example(language="html" escape="html" format="linenums").
371211
template, will need a way ensure that its elements are uniquely labelled, unless it is certain that the component
372212
will only be used once per page.
373213

374-
As an example, we will only look at adding an `explicit label` to an `INPUT`. The examples under the `implicit labelling`
214+
As an example, we will only look at adding an `explicit label` to an `input`. The examples under the `implicit labelling`
375215
section can then easily be adjusted to use this syntax.
376216

377217
.l-sub-section

0 commit comments

Comments
 (0)