@@ -64,7 +64,7 @@ include ../_util-fns
64
64
that element instead of writing your own.
65
65
66
66
: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.
68
68
69
69
This way you have to think less about things like focus management, tabindex, etc. and have more time to think about
70
70
your code.
@@ -166,194 +166,34 @@ code-example(language="html" escape="html").
166
166
</label >
167
167
168
168
: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.
170
170
171
171
Let us now explore how we can use `implicit labelling` to decorate the commonly used native `HTML` form elements
172
172
in our Angular 2 components.
173
173
174
174
:marked
175
- #### Inputs
175
+ #### Inputs and textareas
176
176
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' )
240
180
241
181
: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
279
183
280
184
.l-sub-section
281
185
: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`.
283
188
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' )
329
192
330
193
:marked
331
194
#### Select lists
332
195
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' )
357
197
358
198
:marked
359
199
### Explicit labelling
@@ -371,7 +211,7 @@ code-example(language="html" escape="html" format="linenums").
371
211
template, will need a way ensure that its elements are uniquely labelled, unless it is certain that the component
372
212
will only be used once per page.
373
213
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`
375
215
section can then easily be adjusted to use this syntax.
376
216
377
217
.l-sub-section
0 commit comments