Skip to content

Commit 1071680

Browse files
jelbournjosephperrott
authored andcommitted
docs: add badge example and fix some tree docs formatting (#11104)
1 parent 376cb66 commit 1071680

File tree

7 files changed

+71
-33
lines changed

7 files changed

+71
-33
lines changed

src/cdk/tree/tree.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ list of items from hierarchical data. The "level" of each tree node is read thro
1616
method of the `TreeControl`; this level can be used to style the node such that it is indented to
1717
the appropriate level.
1818

19-
```
19+
```html
2020
<cdk-tree>
21-
<cdk-tree-node> parent node </cdk-tree-node>
22-
<cdk-tree-node> -- child node1 </cdk-tree-node>
23-
<cdk-tree-node> -- child node2 </cdk-tree-node>
21+
<cdk-tree-node> parent node </cdk-tree-node>
22+
<cdk-tree-node> -- child node1 </cdk-tree-node>
23+
<cdk-tree-node> -- child node2 </cdk-tree-node>
2424
</cdk-tree>
2525

2626
```
@@ -36,13 +36,13 @@ variations, such as infinite or virtual scrolling.
3636
In nested tree, children nodes are placed inside their parent node in DOM. The parent node contains
3737
a node outlet into which children are projected.
3838

39-
```
39+
```html
4040
<cdk-tree>
41-
<cdk-nested-tree-node>
42-
parent node
43-
<cdk-nested-tree-node> -- child node1 </cdk-tree-node>
44-
<cdk-nested-tree-node> -- child node2 </cdk-tree-node>
45-
</cdk-nested-tree-node>
41+
<cdk-nested-tree-node>
42+
parent node
43+
<cdk-nested-tree-node> -- child node1 </cdk-tree-node>
44+
<cdk-nested-tree-node> -- child node2 </cdk-tree-node>
45+
</cdk-nested-tree-node>
4646
</cdk-tree>
4747
```
4848

@@ -61,9 +61,9 @@ nested children nodes.
6161
A node definition is specified via any element with `cdkNodeDef`. This directive exports the node
6262
data to be used in any bindings in the node template.
6363

64-
```
64+
```html
6565
<cdk-tree-node *cdkNodeDef=“let node”>
66-
{{node.key}}: {{node.value}}
66+
{{node.key}}: {{node.value}}
6767
</cdk-tree-node>
6868
```
6969

@@ -79,10 +79,10 @@ Spacing can be added either by applying the `cdkNodePadding` directive or by app
7979
When using nested tree nodes, the node template must contain a `cdkTreeNodeOutlet`, which marks
8080
where the children of the node will be rendered.
8181

82-
```
82+
```html
8383
<cdk-nested-tree-node *cdkNodeDef=“let node”>
84-
{{node.value}}
85-
<ng-container cdkTreeNodeOutlet></ng-container>
84+
{{node.value}}
85+
<ng-container cdkTreeNodeOutlet></ng-container>
8686
</cdk-nested-tree-node>
8787

8888
```
@@ -93,7 +93,7 @@ A `cdkTreeNodeToggle` can be added in the tree node template to expand/collapse
9393
The toggle toggles the expand/collapse functions in TreeControl and is able to expand/collapse
9494
a tree node recursively by setting `[cdkTreeNodeToggleRecursive]` to true.
9595

96-
```
96+
```html
9797
<cdk-tree-node *cdkNodeDef=“let node” cdkTreeNodeToggle [cdkTreeNodeToggleRecursive]="true">
9898
{{node.value}}
9999
</cdk-tree-node>
@@ -103,7 +103,7 @@ The toggle can be placed anywhere in the tree node, and is only toggled by click
103103
For best accessibility, `cdkTreeNodeToggle` should be on a button element and have an appropriate
104104
`aria-label`.
105105

106-
```
106+
```html
107107
<cdk-tree-node *cdkNodeDef=“let node”>
108108
<button cdkTreeNodeToggle aria-label="toggle tree node" [cdkTreeNodeToggleRecursive]="true">
109109
<mat-icon>expand</mat-icon>
@@ -117,9 +117,9 @@ For best accessibility, `cdkTreeNodeToggle` should be on a button element and ha
117117
The cdkTreeNodePadding can be placed in a flat tree's node template to display the level
118118
information of a flat tree node.
119119

120-
```
120+
```html
121121
<cdk-tree-node *cdkNodeDef=“let node” cdkNodePadding>
122-
{{node.value}}
122+
{{node.value}}
123123
</cdk-tree-node>
124124

125125
```
@@ -133,12 +133,12 @@ The tree may include multiple node templates, where a template is chosen
133133
for a particular data node via the `when` predicate of the template.
134134

135135

136-
```
136+
```html
137137
<cdk-tree-node *cdkNodeDef=“let node” cdkTreeNodePadding>
138-
{{node.value}}
138+
{{node.value}}
139139
</cdk-tree-node>
140140
<cdk-tree-node *cdkNodeDef=“let node; when: isSpecial” cdkTreeNodePadding>
141-
[ A special node {{node.value}} ]
141+
[ A special node {{node.value}} ]
142142
</cdk-tree-node>
143143
```
144144

src/lib/badge/badge.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Badges are small status descriptors for UI elements. A badge consists of a small circle,
2-
typically containing a number or other short set of characters, that appears in proximity to another object.
2+
typically containing a number or other short set of characters, that appears in proximity to
3+
another object.
4+
5+
<!-- example(badge-overview) -->
36

47
### Badge position
58
By default, the badge will be placed `above after`. The direction can be changed by defining
@@ -50,4 +53,9 @@ background color to `primary`, `accent`, or `warn`.
5053

5154
### Accessibility
5255
Badges should be given a meaningful description via `matBadgeDescription`. This description will be
53-
applied, via `aria-describedby` to the element decorated by `matBadge`.
56+
applied, via `aria-describedby` to the element decorated by `matBadge`.
57+
58+
When applying a badge to a `<mat-icon>`, it is important to know that the icon is marked as
59+
`aria-hidden` by default. If the combination of icon and badge communicates some meaningful
60+
information, that information should be surfaced in another way. [See the guidance on indicator
61+
icons for more information](https://material.angular.io/components/icon/overview#indicator-icons).

src/lib/tree/tree.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ node is read through the `getLevel` method of the `TreeControl`; this level can
1616
used to style the node such that it is indented to the appropriate level.
1717

1818

19-
```
19+
```html
2020
<mat-tree>
21-
<mat-tree-node> parent node </mat-tree-node>
22-
<mat-tree-node> -- child node1 </mat-tree-node>
23-
<mat-tree-node> -- child node2 </mat-tree-node>
21+
<mat-tree-node> parent node </mat-tree-node>
22+
<mat-tree-node> -- child node1 </mat-tree-node>
23+
<mat-tree-node> -- child node2 </mat-tree-node>
2424
</mat-tree>
2525
```
2626

@@ -35,12 +35,12 @@ scrolling variations, such as infinite or virtual scrolling
3535
In Nested tree, children nodes are placed inside their parent node in DOM. The parent node has an
3636
outlet to keep all the children nodes.
3737

38-
```
38+
```html
3939
<mat-tree>
4040
<mat-nested-tree-node>
41-
parent node
42-
<mat-nested-tree-node> -- child node1 </mat-tree-node>
43-
<mat-nested-tree-node> -- child node2 </mat-tree-node>
41+
parent node
42+
<mat-nested-tree-node> -- child node1 </mat-tree-node>
43+
<mat-nested-tree-node> -- child node2 </mat-tree-node>
4444
</mat-nested-tree-node>
4545
</mat-tree>
4646
```

src/material-examples/autocomplete-optgroup/autocomplete-optgroup-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface StateGroup {
1616
styleUrls: ['./autocomplete-optgroup-example.css'],
1717
})
1818

19-
export class AutocompleteOptionGroupExample implements OnInit {
19+
export class AutocompleteOptgroupExample implements OnInit {
2020
stateForm: FormGroup = this.fb.group({
2121
stateGroup: '',
2222
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<p>
2+
<span matBadge="4" matBadgeOverlap="false">Text with a badge</span>
3+
</p>
4+
5+
<p>
6+
Button with a badge on the left
7+
<button mat-raised-button color="primary"
8+
matBadge="8" matBadgePosition="before" matBadgeColor="accent">
9+
Action
10+
</button>
11+
</p>
12+
13+
<p>
14+
Icon with a badge
15+
<mat-icon matBadge="15" matBadgeColor="warn">home</mat-icon>
16+
</p>
17+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {Component} from '@angular/core';
2+
3+
4+
/**
5+
* @title Badge overview
6+
*/
7+
@Component({
8+
selector: 'badge-overview-example',
9+
templateUrl: 'badge-overview-example.html',
10+
styleUrls: ['badge-overview-example.css']
11+
})
12+
export class BadgeOverviewExample { }

0 commit comments

Comments
 (0)