Skip to content

Commit 60ace86

Browse files
annieywmmalerba
authored andcommitted
refactor: update snippets/embedded example comments in material docs md to reflect new API (badge, toolbar) (#19669)
* badge * toolbar
1 parent 23b9145 commit 60ace86

File tree

7 files changed

+72
-58
lines changed

7 files changed

+72
-58
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
<p>
2+
<!-- #docregion mat-badge-overlap -->
23
<span matBadge="4" matBadgeOverlap="false">Text with a badge</span>
4+
<!-- #enddocregion mat-badge-overlap -->
5+
</p>
6+
7+
<p>
8+
<!-- #docregion mat-badge-size -->
9+
<span matBadge="1" matBadgeSize="large">Text with large badge</span>
10+
<!-- #enddocregion mat-badge-size -->
311
</p>
412

513
<p>
614
Button with a badge on the left
15+
<!-- #docregion mat-badge-position -->
716
<button mat-raised-button color="primary"
817
matBadge="8" matBadgePosition="before" matBadgeColor="accent">
918
Action
1019
</button>
20+
<!-- #enddocregion mat-badge-position -->
21+
</p>
22+
23+
<p>
24+
Button toggles badge visibility
25+
<!-- #docregion mat-badge-hide -->
26+
<button mat-raised-button matBadge="7" [matBadgeHidden]="hidden" (click)="toggleBadgeVisibility()">
27+
Hide
28+
</button>
29+
<!-- #enddocregion mat-badge-hide -->
1130
</p>
1231

1332
<p>
1433
Icon with a badge
34+
<!-- #dorection mat-badge-color -->
1535
<mat-icon matBadge="15" matBadgeColor="warn">home</mat-icon>
36+
<!-- #enddocregion mat-badge-color -->
1637
<!-- Include text description of the icon's meaning for screen-readers -->
1738
<span class="cdk-visually-hidden">
1839
Example with a home icon with overlaid badge showing the number 15
1940
</span>
2041
</p>
2142

43+

src/components-examples/material/badge/badge-overview/badge-overview-example.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ import {Component} from '@angular/core';
88
templateUrl: 'badge-overview-example.html',
99
styleUrls: ['badge-overview-example.css'],
1010
})
11-
export class BadgeOverviewExample {}
11+
export class BadgeOverviewExample {
12+
hidden = false;
13+
14+
toggleBadgeVisibility() {
15+
this.hidden = !this.hidden;
16+
}
17+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.example-icon {
22
padding: 0 14px;
33
}
4-
4+
/* #docregion toolbar-position-content-style */
55
.example-spacer {
66
flex: 1 1 auto;
77
}
8+
/* #enddocregion toolbar-position-content-style */

src/components-examples/material/toolbar/toolbar-multirow/toolbar-multirow-example.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<mat-toolbar color="primary">
2+
<!-- #docregion toolbar-row -->
23
<mat-toolbar-row>
34
<span>Custom Toolbar</span>
45
</mat-toolbar-row>
6+
<!-- #enddocregion toolbar-row -->
57

8+
<!-- #docregion toolbar-position-content -->
69
<mat-toolbar-row>
710
<span>Second Line</span>
811
<span class="example-spacer"></span>
912
<mat-icon class="example-icon" aria-hidden="false" aria-label="Example user verified icon">verified_user</mat-icon>
1013
</mat-toolbar-row>
14+
<!-- #enddocregion toolbar-position-content -->
1115

1216
<mat-toolbar-row>
1317
<span>Third Line</span>

src/components-examples/material/toolbar/toolbar-overview/toolbar-overview-example.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<p>
2+
<!-- #docregion toolbar-simple -->
3+
<mat-toolbar>
4+
<span>My Application</span>
5+
</mat-toolbar>
6+
<!-- #enddocregion toolbar-simple -->
7+
</p>
8+
19
<p>
210
<mat-toolbar>
311
<button mat-icon-button class="example-icon" aria-label="Example icon-button with menu icon">

src/material/badge/badge.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,40 @@ another object.
88
By default, the badge will be placed `above after`. The direction can be changed by defining
99
the attribute `matBadgePosition` follow by `above|below` and `before|after`.
1010

11-
```html
12-
<mat-icon matBadge="22" matBadgePosition="above after">home</mat-icon>
13-
```
11+
<!-- example({"example":"badge-overview",
12+
"file":"badge-overview-example.html",
13+
"region":"mat-badge-position"}) -->
1414

1515
The overlap of the badge in relation to its inner contents can also be defined
1616
using the `matBadgeOverlap` tag. Typically, you want the badge to overlap an icon and not
1717
a text phrase. By default it will overlap.
1818

19-
```html
20-
<h1 matBadge="11" matBadgeOverlap="false">
21-
Email
22-
</h1>
23-
```
19+
<!-- example({"example":"badge-overview",
20+
"file":"badge-overview-example.html",
21+
"region":"mat-badge-overlap"}) -->
2422

2523
### Badge sizing
2624
The badge has 3 sizes: `small`, `medium` and `large`. By default, the badge is set to `medium`.
2725
You can change the size by adding `matBadgeSize` to the host element.
2826

29-
```html
30-
<h1 matBadge="11" matBadgeSize="large">
31-
Email
32-
</h1>
33-
```
27+
<!-- example({"example":"badge-overview",
28+
"file":"badge-overview-example.html",
29+
"region":"mat-badge-size"}) -->
3430

3531
### Badge visibility
3632
The badge visibility can be toggled programmatically by defining `matBadgeHidden`.
3733

38-
```html
39-
<h1 matBadge="11" [matBadgeHidden]="!visible">
40-
Email
41-
</h1>
42-
```
34+
<!-- example({"example":"badge-overview",
35+
"file":"badge-overview-example.html",
36+
"region":"mat-badge-hide"}) -->
4337

4438
### Theming
4539
Badges can be colored in terms of the current theme using the `matBadgeColor` property to set the
4640
background color to `primary`, `accent`, or `warn`.
4741

48-
```html
49-
<mat-icon matBadge="22" matBadgeColor="accent">
50-
home
51-
</mat-icon>
52-
```
42+
<!-- example({"example":"badge-overview",
43+
"file":"badge-overview-example.html",
44+
"region":"mat-badge-color"}) -->
5345

5446
### Accessibility
5547
Badges should be given a meaningful description via `matBadgeDescription`. This description will be

src/material/toolbar/toolbar.md

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,19 @@
77
In the most situations, a toolbar will be placed at the top of your application and will only
88
have a single row that includes the title of your application.
99

10-
```html
11-
<mat-toolbar>
12-
<span>My Application</span>
13-
</mat-toolbar>
14-
```
10+
<!-- example({"example":"toolbar-overview",
11+
"file":"toolbar-overview-example.html",
12+
"region":"toolbar-simple"}) -->
1513

1614
### Multiple rows
1715

1816
The Material Design specifications describe that toolbars can also have multiple rows. Creating
1917
toolbars with multiple rows in Angular Material can be done by placing `<mat-toolbar-row>` elements
2018
inside of a `<mat-toolbar>`.
2119

22-
```html
23-
<mat-toolbar>
24-
<mat-toolbar-row>
25-
<span>First Row</span>
26-
</mat-toolbar-row>
27-
28-
<mat-toolbar-row>
29-
<span>Second Row</span>
30-
</mat-toolbar-row>
31-
</mat-toolbar>
32-
```
20+
<!-- example({"example":"toolbar-multirow",
21+
"file":"toolbar-multirow-example.html",
22+
"region":"toolbar-row"}) -->
3323

3424
**Note**: Placing content outside of a `<mat-toolbar-row>` when multiple rows are specified is not
3525
supported.
@@ -40,23 +30,14 @@ position the content as it suits their application.
4030

4131
A common pattern is to position a title on the left with some actions on the right. This can be
4232
easily accomplished with `display: flex`:
43-
```html
44-
<mat-toolbar color="primary">
45-
<span>Application Title</span>
46-
47-
<!-- This fills the remaining space of the current row -->
48-
<span class="example-fill-remaining-space"></span>
49-
50-
<span>Right Aligned Text</span>
51-
</mat-toolbar>
52-
```
53-
```scss
54-
.example-fill-remaining-space {
55-
/* This fills the remaining space, by using flexbox.
56-
Every toolbar row uses a flexbox row layout. */
57-
flex: 1 1 auto;
58-
}
59-
```
33+
34+
<!-- example({"example":"toolbar-multirow",
35+
"file":"toolbar-multirow-example.html",
36+
"region":"toolbar-position-content"}) -->
37+
38+
<!-- example({"example":"toolbar-multirow",
39+
"file":"toolbar-multirow-example.css",
40+
"region":"toolbar-position-content-style"}) -->
6041

6142
### Theming
6243
The color of a `<mat-toolbar>` can be changed by using the `color` property. By default, toolbars

0 commit comments

Comments
 (0)