@@ -100,7 +100,7 @@ After upgrading to v15, you can run the migration tool to switch from the legacy
100
100
implementations to the new MDC-based ones.
101
101
102
102
``` shell
103
- ng generate # TODO(wagnermaciel): Insert command here.
103
+ ng generate @angular/material:mdc-migration
104
104
```
105
105
106
106
This command updates your TypeScript, styles, and templates to the new implementations, updating as
@@ -109,12 +109,13 @@ much as it can automatically.
109
109
#### Running a Partial Migration
110
110
111
111
Depending on the size and complexity of your application, you may want to migrate a single component
112
- (or small group of components) at a time, rather than all at once.
113
- TODO(wagnermaciel): Add details on this: script params, which components need to move together
112
+ or small group of components at a time, rather than all components at once.
114
113
115
114
You may also want to migrate your app one module at a time instead of all together. You can use both
116
115
the old implementation and new implementation in the same application, as long as they aren't used
117
- in the same ` NgModule ` . TODO(wagnermaciel): Add detail on this: script params.
116
+ in the same ` NgModule ` .
117
+
118
+ The script will prompt you for the directory and components you want to migrate.
118
119
119
120
### 3. Check for TODOs left by the migration tool.
120
121
@@ -123,12 +124,11 @@ attempt to add comments for a human to follow up. These TODO comments follow a c
123
124
they can be easily identified.
124
125
125
126
``` ts
126
- // TODO(wagnermaciel ): Do we have a common format for all TODOs the script adds?
127
+ // TODO(mdc-migration ): ...
127
128
```
128
129
129
- To search for all comments left by the migration tool, search for ` TODO(...): ` in your IDE.
130
-
131
- TODO(amysorto): Can we have the schematic generate a CSV of TODOs that can be imported into Jira
130
+ To search for all comments left by the migration tool, search for ` TODO(mdc-migration): ` in your
131
+ IDE.
132
132
133
133
### 4. Verify Your Application
134
134
@@ -150,32 +150,16 @@ DOM and CSS of the components, you may need to tweak some of your application's
150
150
* Component size, color, spacing, shadows, and animations all change slightly across the board.
151
151
These changes generally improve spec-compliance and accessibility.
152
152
153
- * CSS classes applied to components use the ` mat-mdc ` prefix, whereas before it was simply a ` mat `
153
+ * The DOM structure of components has changed to allow for improved accessibility and compliance
154
+ with the Material Design spec.
155
+
156
+ * CSS classes applied to components use the ` mat-mdc- ` prefix, whereas before it was simply a ` mat- `
154
157
prefix. Elements that roughly correspond to element in the old implementation have been given the
155
158
same class name (aside from the prefix). For example, the button’s host class is ` mat-mdc-button `
156
159
instead of ` mat-button ` . However, not all elements in the previous implementation have an
157
160
equivalent element in the new implementation.
158
161
159
- ### Core Styles & Theming
160
-
161
- * ` mat.core() ` no longer includes component typography styles. If your application was relying on
162
- this, you may need to add typography styles explicitly now. This can be done all at once:
163
-
164
- ``` scss
165
- @import ' @angular/material' as mat ;
166
-
167
- @include mat .all-component-typographies ();
168
- ```
169
-
170
- or individually for components your application uses:
171
-
172
- ``` scss
173
- @import ' @angular/material' as mat ;
174
-
175
- @include mat .button-typography ();
176
- @include mat .card-typography ();
177
- // ...
178
- ```
162
+ ### Theming
179
163
180
164
* Default typography levels defined by ` mat.define-typography-config ` have been updated to reflect
181
165
changes to the Material Design spec.
@@ -195,6 +179,7 @@ DOM and CSS of the components, you may need to tweak some of your application's
195
179
```
196
180
197
181
If you prefer a different default density level, you can set it in your theme config:
182
+ <!-- TODO(wagnermaciel): link to density docs for more info once they exist. -->
198
183
199
184
``` scss
200
185
$theme : mat .define-light-theme ((
@@ -203,8 +188,6 @@ DOM and CSS of the components, you may need to tweak some of your application's
203
188
));
204
189
```
205
190
206
- TODO(mmalerba): link to density docs once they exist.
207
-
208
191
### Autocomplete
209
192
210
193
* Long options now wrap instead of truncating.
@@ -254,31 +237,49 @@ TODO(mmalerba): link to density docs once they exist.
254
237
255
238
* ` <mat-card-content> ` no longer sets any typography styles, users are free to add whatever
256
239
typography styles make sense for their application, either to ` <mat-card-content> ` itself or any
257
- child elements as appropriate.
240
+ child elements as appropriate. For example:
241
+
242
+ ``` scss
243
+ @use ' @angular/material' as mat ;
244
+ @include mat .typography-hierarchy ();
245
+ ```
246
+
247
+ ``` html
248
+ <mat-card >
249
+ <mat-card-content class =" mat-body-1" >...</mat-card-content >
250
+ </mat-card >
251
+ ```
258
252
259
253
### Checkbox
260
254
261
255
* Clicks on the checkbox now trigger directly on the native checkbox element rather than a shim div.
262
256
Native checkboxes have bizarre behavior when calling ` preventDefault ` on their ` click ` event, so
263
257
users should not call ` preventDefault ` on ` click ` .
264
258
265
- * Accessibility: Checkbox touch targets are larger, now 40px instead of 16px, which is more
266
- accessible.
259
+ * Checkbox touch targets are larger, now 40px instead of 16px, which is more accessible. Be sure to
260
+ allow enough space in your layout so that the touch target does not overlap other components. If
261
+ you are not concerned with accessibility you can match the previous size by using density -5 for
262
+ the checkbox.
263
+
264
+ ``` scss
265
+ @use ' @angular/material' as mat ;
266
+ @include mat .checkbox-density (-5px );
267
+ ```
267
268
268
269
* Checkbox color may be changed to white or black due to a change in heuristics based on the
269
270
application’s theme. Previously, the check’s color would be set to the theme’s background color.
270
271
With MDC, it is determined by whether white or black has the most contrast against the primary
271
272
color.
272
273
273
- * Accessibility: Focus state is slightly darker, improving contrast ratio
274
-
275
- * Many checkboxes on the page may cause the animation to seem slow
274
+ * Focus state is slightly darker, improving contrast ratio.
276
275
277
- * Text styles will not be inherited; you will need to specifically target the checkbox’s ` label ` .
276
+ * Text styles will not be inherited; you will need to specifically target the checkbox’s ` label ` to
277
+ override typography properties.
278
278
279
279
* After toggling a checkbox with the mouse, the ripple will remain visible instead of animating out.
280
280
281
281
### Chips
282
+ <!-- TODO(zarend): review -->
282
283
283
284
* The chips component has been split into multiple variants corresponding with more appropriate
284
285
interaction patterns for accessibility. The original ` mat-chip-list ` used ` role="listbox" ` , but
@@ -304,7 +305,7 @@ TODO(mmalerba): link to density docs once they exist.
304
305
305
306
* The ` .mat-dialog-container ` does not contain a 24px padding anymore. Instead, the inner dialog
306
307
directives are responsible for adding the right padding. This will be apparent if your dialog does
307
- not use any of the directives like ` mat-dialog-content ` .
308
+ not use any of the directives like ` < mat-dialog-content> ` .
308
309
309
310
* ` mat-dialog-content ` uses the font-settings specified by the Material Design spec, which includes
310
311
a rather roomy line-height. If you have an information-dense dialog that doesn't look good with
@@ -344,6 +345,9 @@ TODO(mmalerba): link to density docs once they exist.
344
345
behaved like a placeholder. If you need this behavior, use the ` placeholder ` property on ` <input> `
345
346
instead.
346
347
348
+ * Custom form field controls may need their styles adjusted to account for the fact that the
349
+ surrounding form field DOM and styles have changed.
350
+
347
351
### Input
348
352
349
353
* MatInput must be inside ` <mat-form-field> ` . Previously it was (unintentionally) possible to use an
@@ -353,11 +357,11 @@ TODO(mmalerba): link to density docs once they exist.
353
357
` <input matInput type="date"> ` , if you want this indicator to appear for your inputs, use the
354
358
following styles:
355
359
356
- ``` scss
357
- .mat-mdc-input-element ::-webkit-calendar-picker-indicator {
358
- display : block ;
359
- }
360
- ```
360
+ ``` scss
361
+ .mat-mdc-input-element ::-webkit-calendar-picker-indicator {
362
+ display : block ;
363
+ }
364
+ ```
361
365
362
366
### List
363
367
@@ -381,9 +385,9 @@ TODO(mmalerba): link to density docs once they exist.
381
385
</mat-list-item >
382
386
```
383
387
384
- * The amount of lines is automatically inferred. e.g. in the snippet above the list item will
385
- acquire space for two lines. With the new API you can now set an explicit number of lines on the
386
- ` <mat-list-item> ` to activate wrapping.
388
+ * The amount of lines is automatically inferred. For example, in the snippet above the list item
389
+ will acquire space for two lines. With the new API you can now set an explicit number of lines on
390
+ the ` <mat-list-item> ` to activate wrapping.
387
391
388
392
``` html
389
393
<mat-list-item lines =" 3" >
@@ -420,7 +424,7 @@ TODO(mmalerba): link to density docs once they exist.
420
424
` <mat-icon> ` use ` ngProjectAs="mat-icon" ` to project it into the icon slot.
421
425
422
426
* If you need your icon to appear at the end of the item (not officially supported by the spec)
423
- you can wrap both the text and your icon in a span, e.g.
427
+ you can wrap both the text and your icon in a span, for example:
424
428
425
429
``` html
426
430
<span >
@@ -439,6 +443,8 @@ TODO(mmalerba): link to density docs once they exist.
439
443
440
444
* Long options now wrap instead of truncating with an ellipsis.
441
445
446
+ * Option heights are no longer capped at `48px`.
447
+
442
448
### Paginator
443
449
444
450
* The form-field inside of `mat-paginator` only supports the `appearance` options offered by the new
@@ -464,16 +470,14 @@ TODO(mmalerba): link to density docs once they exist.
464
470
465
471
* Labels are smaller and further away from the radio button to align with the Material Design spec.
466
472
467
- * Accessibility: The touch target is much larger than the radio button; to match the legacy size,
468
- you can provide a `-5` density to the radio button's theme mixin:
469
-
470
- ```scss
471
- @use '@angular/material' as mat;
473
+ * The touch target is now much larger and more accessible. Be sure to allow enough space in your
474
+ layout so that the touch target does not overlap other components. If you are not concerned with
475
+ accessibility you can match the previous size by using density -5 for the radio.
472
476
473
- @include mat.radio-theme(
474
- map-merge($theme, (density: -5))
475
- );
476
- ```
477
+ ```scss
478
+ @use '@angular/material' as mat;
479
+ @include mat.radio-density(-5px );
480
+ ```
477
481
478
482
### Select
479
483
@@ -491,47 +495,46 @@ TODO(mmalerba): link to density docs once they exist.
491
495
is the same width as the form-field
492
496
493
497
### Slide Toggle
498
+ <!-- TODO(zarend): review -->
494
499
495
- * Accessibility: MDC-based version uses ` <button role="switch"> ` to represent the toggle rather than
496
- ` <input type="checkbox"> `
500
+ * To improve accessibility, the MDC-based version uses ` <button role="switch"> ` to represent the
501
+ toggle rather than ` <input type="checkbox"> ` .
497
502
498
- * Accessibility: The touch target is much larger than the slide toggle; to match the legacy size,
499
- you can provide a ` -5 ` density to the slide toggle’s theme mixin:
503
+ * The touch target is much larger and more accessible. Be sure to allow enough space in your
504
+ layout so that the touch target does not overlap other components. If you are not concerned with
505
+ accessibility you can match the previous size by using density -5 for the slide-toggle.
500
506
501
507
``` scss
502
508
@use ' @angular/material' as mat ;
503
-
504
- @include mat .slide-toggle-theme (
505
- map-merge ($theme , (density: -5 ))
506
- );
509
+ @include mat .slide-toggle-density (-5px );
507
510
```
508
511
509
512
* The label is closer to the enabled toggle
510
513
511
514
### Slider
515
+ <!-- TODO(wagnermaciel): review -->
512
516
513
- * Accessibility: sliders now work with mobile device screen readers.
517
+ * Sliders now work with mobile device screen readers.
514
518
515
519
* To accommodate range sliders, the implementation has changed from the ` <mat-slider> ` element being
516
520
the form control to the ` <mat-slider> ` element containing 1-2 ` <input> ` elements (the slider
517
521
"thumbs") that act as the form control(s). The value, associated events (` input ` , ` change ` ), and
518
522
labels (` aria-label ` ) now live on the ` <input> ` elements instead.
519
523
520
524
* Vertical sliders and inverted sliders are no longer supported, as they are no longer part of the
521
- Material Design spec. TODO(jelbourn): should we add a note that vertical sliders are likely to
522
- return in a future version?
525
+ Material Design spec.
523
526
524
- * Range sliders are now supported. TODO(wagnermaciel): add more about this.
527
+ * Range sliders are now supported. <!-- TODO(wagnermaciel): add more about this. -->
525
528
526
529
### Snack Bar
527
530
528
531
* For simple, text-based snack-bars, there are no significant changes.
529
532
530
533
* For simple snack-bars with an action button, they use the MDC-based mat-button, so your
531
- application will need to include the Sass theming mixin for the MDC-based button
534
+ application will need to include the Sass theming mixin for the MDC-based button.
532
535
533
- * For snack-bars that use custom structured content (i.e. calls to ` MatSnackBar.openFromComponent `
534
- and ` MatSnackBar.openFromTemplate ` ), you should use the following new directives to annotate your
536
+ * For snack-bars that use custom structured content (if you call ` MatSnackBar.openFromComponent ` or
537
+ ` MatSnackBar.openFromTemplate ` ), you should use the following new directives to annotate your
535
538
content:
536
539
* ` matSnackBarLabel ` to mark the text displayed to users
537
540
* ` matSnackBarActions ` to mark the element containing the action buttons
@@ -545,22 +548,25 @@ TODO(mmalerba): link to density docs once they exist.
545
548
546
549
### Table
547
550
548
- * All cells have a ` 16px ` left and right padding instead of just the leftmost and rightmost cells having a padding of ` 24px ` .
551
+ * All cells have a ` 16px ` left and right padding instead of just the leftmost and rightmost cells
552
+ having a padding of ` 24px ` .
549
553
550
- * Header cells have the same color and text size as the data rows instead of having more grayish and smaller text.
554
+ * Header cells have the same color and text size as the data rows instead of having more grayish and
555
+ smaller text.
551
556
552
- * Cell text no longer wraps by default. Cell wrapping can be enabled by applying ` white-space: normal ` to
553
- the table cells.
557
+ * Cell text no longer wraps by default. Cell wrapping can be enabled by applying
558
+ ` white-space: normal ` to the table cells.
554
559
555
560
* Row height is ` 52px ` instead of ` 48px ` .
556
561
557
562
* Cell box-sizing is ` border-box ` instead of ` content-box ` . This may affect custom width styles.
558
563
559
- * The table's last row does not include a bottom border row because the table is expected to have a border.
564
+ * The table's last row does not include a bottom border row because the table is expected to have a
565
+ border.
560
566
561
- * The paginator property of the ` MatTableDataSource ` has a generic interface that matches most of
562
- the paginator API. You may need to explicitly type the paginator to access the full API, e.g.
563
- ` new MatTableDataSource<MyData, MatPaginator>(); `
567
+ * The paginator property of the ` MatTableDataSource ` has a generic interface that matches most, but
568
+ not all of the paginator API. You may need to explicitly type the paginator to access the full
569
+ API, for example: ` new MatTableDataSource<MyData, MatPaginator>(); `
564
570
565
571
* Flex tables (` <mat-table> ` ) display a border on the cells instead of rows.
566
572
@@ -573,18 +579,18 @@ TODO(mmalerba): link to density docs once they exist.
573
579
* Header labels stretch to fill the container's width. This can be turned off by
574
580
setting the ` <mat-tab-group> ` input ` mat-stretch-tabs ` to ` false ` .
575
581
576
- * The ` <mat-tab-nav-bar> ` requires a reference to a ` <mat-tab-nav-panel> ` using the ` tabPanel ` input.
577
- The ` <mat-tab-nav-panel> ` must wrap the content connected to the nav-bar. This allows
578
- the component to provide correct labeling for assistive technology.
582
+ * The ` <mat-tab-nav-bar> ` requires a reference to a ` <mat-tab-nav-panel> ` using the ` tabPanel `
583
+ input. The ` <mat-tab-nav-panel> ` must wrap the content connected to the nav-bar. This allows the
584
+ component to provide correct labeling for assistive technology.
579
585
580
- ``` html
581
- <!-- Before -->
582
- <mat-tab-nav-bar >...</mat-tab-nav-bar >
586
+ ``` html
587
+ <!-- Before -->
588
+ <mat-tab-nav-bar >...</mat-tab-nav-bar >
583
589
584
- <!-- After -->
585
- <mat-tab-nav-bar [tabPanel] =" tabPanel" >...</mat-tab-nav-bar >
586
- <mat-tab-nav-panel #tabPanel >...</mat-tab-nav-panel >
587
- ```
590
+ <!-- After -->
591
+ <mat-tab-nav-bar [tabPanel] =" tabPanel" >...</mat-tab-nav-bar >
592
+ <mat-tab-nav-panel #tabPanel >...</mat-tab-nav-panel >
593
+ ```
588
594
589
595
### Tooltip
590
596
0 commit comments