Skip to content

Commit ed5479c

Browse files
authored
docs: add remaining component overviews (#2338)
* snackbar overview * menu overview * list overview * slide-toggle * sidenav overview * progress overview * radio overview * toolbar overview * slider overview * select overview * nav-tabs * chips * consistency * input edits * fix typo in radio * correct radio overview example name * mention hammer, fix typos
1 parent 3f2db27 commit ed5479c

File tree

21 files changed

+641
-52
lines changed

21 files changed

+641
-52
lines changed

src/demo-app/chips/chips-demo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ <h4>Stacked Chips</h4>
6262
</md-chip-list>
6363
</md-card-content>
6464
</md-card>
65-
</div>
65+
</div>

src/lib/button-toggle/OVERVIEW.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Button-toggles are on/off toggles with the appearance of a button. These toggles can be configured
2-
to behave as either radio-buttons or checkboxes. While they can be standalone, they are typically
3-
part of a `md-button-toggle-group`.
1+
`<md-button-toggle>` are on/off toggles with the appearance of a button. These toggles can be
2+
configured to behave as either radio-buttons or checkboxes. While they can be standalone, they are
3+
typically part of a `md-button-toggle-group`.
44

55

66
<!-- example(button-toggle-overview) -->

src/lib/card/OVERVIEW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Cards are content containers for text, photos, and actions. Cards are intended to provide
1+
`<md-card>` is a content container for text, photos, and actions. Cards are intended to provide
22
information on a single subject.
33

44
<!-- example(card-overview) -->

src/lib/checkbox/OVERVIEW.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
`<md-checkbox>` provides the same functionality as a native `<input type="checkbox">`
2-
enhanced Material Design styling and animations.
2+
enhanced with Material Design styling and animations.
33

44
<!-- example(checkbox-overview) -->
55

src/lib/chips/OVERVIEW.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
`<md-chip-list>` displays a list of values as individual chips.
2+
3+
<!-- example(chips-overview) -->
4+
5+
_Note: chips are still early in their development and more features are being actively worked on._
6+
7+
```html
8+
<md-chip-list>
9+
<md-chip>Papadum</md-chip>
10+
<md-chip>Naan</md-chip>
11+
<md-chip>Dal</md-chip>
12+
</md-chip-list>
13+
```
14+
15+
### Unstyled chips
16+
By default, `<md-chip>` has Material Design styles applied. For a chip with no styles applied,
17+
use `<md-basic-chip>`. You can then customize the chip appearance by adding your own CSS.
18+
19+
### Selection
20+
Chips can be selected via the `selected` property. Selection can be disabled by setting
21+
`selectable` to `false` on the `<md-chip-list>`.
22+
23+
### Keyboard interation
24+
Users can move through the chips using the arrow keys and select them with the space.
25+
26+
27+
### Theming
28+
The color of an `<md-chip>` can be changed by using the `color` property. By default, chips
29+
use a neutral background color based on the current theme (light or dark). This can be changed to
30+
`'primary'`, `'accent'`, or `'warn'`.

src/lib/grid-list/OVERVIEW.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# md-grid-list
2-
3-
`md-grid-list` is an alternative list view that arranges cells into grid-based layout.
1+
`md-grid-list` is a two-dimensional list view that arranges cells into grid-based layout.
42
See Material Design spec [here](https://www.google.com/design/spec/components/grid-lists.html).
53

64
<!-- example(grid-list-overview) -->
75

8-
## Usage
9-
106
### Setting the number of columns
117

128
An `md-grid-list` must specify a `cols` attribute which sets the number of columns in the gird. The

src/lib/icon/OVERVIEW.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
# md-icon
2-
31
`md-icon` makes it easier to use _vector-based_ icons in your app. This directive supports both
42
icon fonts and SVG icons, but not bitmap-based formats (png, jpg, etc.).
53

64
<!-- example(icon-example) -->
75

8-
## Usage
9-
10-
### Registering new icons
6+
### Registering icons
117

128
`MdIconRegistry` is an injectable service that allows you to associate icon names with SVG URLs and
139
define aliases for CSS font classes. Its methods are discussed below and listed in the API summary.
1410

15-
In order to prevent XSS vulnerabilities, any URLs passed to the `MdIconRegistry` must be marked as
16-
trusted resource URLs by using Angular's `DomSanitizer` service.
17-
18-
### Font icons
19-
20-
#### Ligatures
11+
### Font icons with ligatures
2112

2213
Some fonts are designed to show icons by using
2314
[ligatures](https://en.wikipedia.org/wiki/Typographic_ligature), for example by rendering the text
@@ -31,7 +22,7 @@ You can specify a different font by setting the `fontSet` input to either the CS
3122
use the desired font, or to an alias previously registered with
3223
`MdIconRegistry.registerFontClassAlias`.
3324

34-
#### Font icons via CSS
25+
### Font icons with CSS
3526

3627
Fonts can also display icons by defining a CSS class for each icon glyph, which typically uses a
3728
`:before` selector to cause the icon to appear.
@@ -48,14 +39,17 @@ explicitly set by calling `MdIconRegistry.setDefaultFontSetClass`.
4839
When an `md-icon` component displays an SVG icon, it does so by directly inlining the SVG content
4940
into the page as a child of the component. (Rather than using an <img> tag or a div background
5041
image). This makes it easier to apply CSS styles to SVG icons. For example, the default color of the
51-
SVG content is the CSS [currentColor](http://www.quirksmode.org/css/color/currentcolor.html) value.
52-
This makes SVG icons by default have the same color as surrounding text, and allows you to change
53-
the color by setting the "color" style on the `md-icon` element.
42+
SVG content is the CSS
43+
[currentColor](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentColor_keyword)
44+
value. This makes SVG icons by default have the same color as surrounding text, and allows you to
45+
change the color by setting the "color" style on the `md-icon` element.
5446

55-
#### Icons from URLs
47+
In order to prevent XSS vulnerabilities, any SVG URLs passed to the `MdIconRegistry` must be
48+
marked as trusted resource URLs by using Angular's `DomSanitizer` service.
5649

57-
SVG icons can be used either by directly specifying the icon's URL, or by associating an icon name
58-
with a URL and then referring to the name. To use a URL directly, set the `svgSrc` input.
50+
Also note that all SVG icons are fetched via XmlHttpRequest, and due to the same-origin policy,
51+
their URLs must be on the same domain as the containing page, or their servers must be configured
52+
to allow cross-domain access.
5953

6054
#### Named icons
6155

@@ -78,14 +72,11 @@ as for individually registered icons.
7872
Multiple icon sets can be registered in the same namespace. Requesting an icon whose id appears in
7973
more than one icon set, the icon from the most recently registered set will be used.
8074

81-
Note that all SVG icons are fetched via XmlHttpRequest, and due to the same-origin policy their URLs
82-
must be on the same domain as the containing page, or their servers must be configured to allow
83-
cross-domain access.
84-
8575
### Theming
8676

87-
Icons can be themed to match your "primary" palette, your "accent" palette, or your "warn" palette
88-
using the `color` attribute. Simply pass in the desired palette name.
77+
By default, icons will use the current font color (`currentColor`). this color can be changed to
78+
match the current theme's colors using the `color` attribute. This can be changed to
79+
`'primary'`, `'accent'`, or `'warn'`.
8980

9081
### Accessibility
9182

src/lib/input/OVERVIEW.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
1-
# md-input-container
1+
`<md-input-container>` is a wrapper for native `input` and `textarea` elements. This container
2+
applies Material Design styles and behavior while still allowing direct access to the underlying
3+
native element.
24

3-
Inputs are the basic input component of Material 2. The spec can be found
4-
[here](https://www.google.com/design/spec/components/text-fields.html). `md-input-container` acts as
5-
a wrapper for native `input` and `textarea` elements that is used to add material design styles and
6-
behavior. The native element wrapped by the `md-input-container` must be marked with the `md-input`
7-
directive.
5+
The native element wrapped by the `md-input-container` must be marked with the `mdInput` directive.
86

97
<!-- example(input-overview) -->
108

11-
## Usage
12-
139
### `input` and `textarea` attributes
1410

1511
All of the attributes that can be used with normal `input` and `textarea` elements can be used on
16-
elements within the `md-input-container` as well. This includes angular specific ones such as
12+
elements inside `md-input-container` as well. This includes Angular directives such as
1713
`ngModel` and `formControl`.
1814

1915
The only limitations are that the `type` attribute can only be one of the values supported by
2016
`md-input-container` and the native element cannot specify a `placeholder` attribute if the
2117
`md-input-container` also contains a `md-placeholder` element.
2218

23-
#### Supported `input` types
19+
### Supported `input` types
2420

25-
The following [input types](http://www.w3schools.com/TAGs/att_input_type.asp) can be used with
26-
`md-input-container`:
21+
The following [input types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) can
22+
be used with `md-input-container`:
2723
* date
2824
* datetime-local
2925
* email

src/lib/list/OVERVIEW.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
`<md-list>` is a container component that wraps and formats a series of line items. As the base
2+
list component, it provides Material Design styling, but no behavior of its own.
3+
4+
<!-- example(list-overview) -->
5+
6+
7+
### Simple lists
8+
9+
An `<md-list>` element contains a number of `<md-list-item>` elements.
10+
11+
```html
12+
<md-list>
13+
<md-list-item> Pepper </md-list-item>
14+
<md-list-item> Salt </md-list-item>
15+
<md-list-item> Paprika </md-list-item>
16+
</md-list>
17+
```
18+
19+
### Navigation lists
20+
21+
Use `md-nav-list` tags for navigation lists (i.e. lists that have anchor tags).
22+
23+
Simple navigation lists can use the `md-list-item` attribute on anchor tag elements directly:
24+
25+
```html
26+
<md-nav-list>
27+
<a md-list-item href="..." *ngFor="let link of links"> {{ link }} </a>
28+
</md-nav-list>
29+
```
30+
31+
For more complex navigation lists (e.g. with more than one target per item), wrap the anchor
32+
element in an `<md-list-item>`.
33+
34+
```html
35+
<md-nav-list>
36+
<md-list-item *ngFor="let link of links">
37+
<a md-line href="...">{{ link }}</a>
38+
<button md-icon-button (click)="showInfo(link)">
39+
<md-icon>info</md-icon>
40+
</button>
41+
</md-list-item>
42+
</md-nav-list>
43+
```
44+
45+
### Multi-line lists
46+
For lists that require multiple lines per item, annotate each line with an `md-line` attribute.
47+
Whichever heading tag is appropriate for your DOM hierarchy should be used (not necesarily `<h3>`
48+
as shown in the example).
49+
50+
```html
51+
<!-- two line list -->
52+
<md-list>
53+
<md-list-item *ngFor="let message of messages">
54+
<h3 md-line> {{message.from}} </h3>
55+
<p md-line>
56+
<span> {{message.subject}} </span>
57+
<span class="demo-2"> -- {{message.content}} </span>
58+
</p>
59+
</md-list-item>
60+
</md-list>
61+
62+
<!-- three line list -->
63+
<md-list>
64+
<md-list-item *ngFor="let message of messages">
65+
<h3 md-line> {{message.from}} </h3>
66+
<p md-line> {{message.subject}} </p>
67+
<p md-line class="demo-2"> {{message.content}} </p>
68+
</md-list-item>
69+
</md-list>
70+
```
71+
72+
### Lists with avatars
73+
To include an avatar, add an image tag with an `md-list-avatar` attribute.
74+
75+
```html
76+
<md-list>
77+
<md-list-item *ngFor="let message of messages">
78+
<img md-list-avatar src="..." alt="...">
79+
<h3 md-line> {{message.from}} </h3>
80+
<p md-line>
81+
<span> {{message.subject}} </span>
82+
<span class="demo-2"> -- {{message.content}} </span>
83+
</p>
84+
</md-list-item>
85+
</md-list>
86+
```
87+
88+
### Dense lists
89+
Lists are also available in "dense layout" mode, which shrinks the font size and height of the list
90+
to suit UIs that may need to display more information. To enable this mode, add a `dense` attribute
91+
to the main `md-list` tag.
92+
93+
94+
```html
95+
<md-list dense>
96+
<md-list-item> Pepper </md-list-item>
97+
<md-list-item> Salt </md-list-item>
98+
<md-list-item> Paprika </md-list-item>
99+
</md-list>
100+
```
101+
102+
103+
### Lists with multiple sections
104+
105+
Subheader can be added to a list by annotating a heading tag with an `md-subheader` attribute.
106+
To add a divider, use `<md-divider>`.
107+
108+
```html
109+
<md-list>
110+
<h3 md-subheader>Folders</h3>
111+
<md-list-item *ngFor="let folder of folders">
112+
<md-icon md-list-avatar>folder</md-icon>
113+
<h4 md-line>{{folder.name}}</h4>
114+
<p md-line class="demo-2"> {{folder.updated}} </p>
115+
</md-list-item>
116+
<md-divider></md-divider>
117+
<h3 md-subheader>Notes</h3>
118+
<md-list-item *ngFor="let note of notes">
119+
<md-icon md-list-avatar>note</md-icon>
120+
<h4 md-line>{{note.name}}</h4>
121+
<p md-line class="demo-2"> {{note.updated}} </p>
122+
</md-list-item>
123+
</md-list>
124+
```

src/lib/menu/OVERVIEW.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
`<md-menu>` is a floating panel containing list of options.
2+
3+
<!-- example(menu-overview) -->
4+
5+
By itself, the `<md-menu>` element does not render anything. The menu is attached to and opened
6+
via application of the `mdMenuTriggerFor` directive:
7+
```ts
8+
<md-menu #appMenu="mdMenu">
9+
<button md-menu-item> Settings </button>
10+
<button md-menu-item> Help </button>
11+
</md-menu>
12+
13+
<button md-icon-button [mdMenuTriggerFor]="appMenu">
14+
<md-icon>more_vert</md-icon>
15+
</button>
16+
```
17+
18+
### Toggling the menu programmatically
19+
The menu exposes an API to open/close programmatically. Please note that in this case, an
20+
`mdMenuTriggerFor` directive is still necessary to attach the menu to a trigger element in the DOM.
21+
22+
```ts
23+
class MyComponent {
24+
@ViewChild(MdMenuTrigger) trigger: MdMenuTrigger;
25+
26+
someMethod() {
27+
this.trigger.openMenu();
28+
}
29+
}
30+
```
31+
32+
### Icons
33+
Menus support displaying `md-icon` elements before the menu item text.
34+
35+
*my-comp.html*
36+
```html
37+
<md-menu #menu="mdMenu">
38+
<button md-menu-item>
39+
<md-icon> dialpad </md-icon>
40+
<span> Redial </span>
41+
</button>
42+
<button md-menu-item disabled>
43+
<md-icon> voicemail </md-icon>
44+
<span> Check voicemail </span>
45+
</button>
46+
<button md-menu-item>
47+
<md-icon> notifications_off </md-icon>
48+
<span> Disable alerts </span>
49+
</button>
50+
</md-menu>
51+
```
52+
53+
### Customizing menu position
54+
55+
By default, the menu will display after and below its trigger. The position can be changed
56+
using the `x-position` (`before | after`) and `y-position` (`above | below`) attributes.
57+
58+
59+
### Keyboard interaction
60+
- <kbd>DOWN_ARROW</kbd>: Focuses the next menu item
61+
- <kbd>UP_ARROW</kbd>: Focuses previous menu item
62+
- <kbd>ENTER</kbd>: Activates the focused menu item

0 commit comments

Comments
 (0)