Skip to content

Commit 7079f38

Browse files
committed
docs: add temporary docs for cdk
1 parent fde35e4 commit 7079f38

File tree

12 files changed

+192
-95
lines changed

12 files changed

+192
-95
lines changed

guides/getting-started.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ For help getting started with a new Angular app, check out the
33

44
For existing apps, follow these steps to begin using Angular Material.
55

6-
## Step 1: Install Angular Material
6+
## Step 1: Install Angular Material and Angular CDK
77

88
```bash
9-
npm install --save @angular/material
9+
npm install --save @angular/material @angular/cdk
1010
```
1111

1212
## Step 2: Animations
@@ -79,13 +79,14 @@ Whichever approach you use, be sure to import the Angular Material modules _afte
7979

8080
Including a theme is **required** to apply all of the core and theme styles to your application.
8181

82-
To get started with a prebuilt theme, include the following in your app's index.html:
83-
84-
```html
85-
<link href="../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" rel="stylesheet">
82+
To get started with a prebuilt theme, include one of Angular Material's prebuilt themes globally
83+
in your application. If you're using the Angular CLI, you can add this to your `styles.css`:
84+
```css
85+
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
8686
```
8787

88-
Note that your app's project structure may have a different relative location for your node_modules.
88+
If you are not using the Angular CLI, you can include a prebuilt theme via a `<link>` element in
89+
your `index.html`.
8990

9091
For more information on theming and instructions on how to create a custom theme, see the
9192
[theming guide](./theming.md).
@@ -142,6 +143,6 @@ System.config({
142143
```
143144

144145

145-
## Sample Angular Material projects
146-
- [Material Sample App](https://github.com/jelbourn/material2-app)
147-
- [Angular Connect 2016 Demo](https://github.com/kara/leashed-in)
146+
## Example Angular Material projects
147+
- [material.angular.io](https://material.angular.io) -
148+
We build our own documentation with Angular Material!

src/cdk/a11y/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/cdk/a11y/focus-trap.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### FocusTrap
2+
The `cdkFocusTrap` directive traps Tab key focus within an element. This is intended to be used to
3+
create components like [modal dialogs](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal).
4+
5+
This directive is declared in `A11yModule`.
6+
7+
#### Example
8+
```
9+
<div class="my-inner-dialog-content" cdkFocusTrap>
10+
<!-- Tab and Shift + Tab will not leave this element. -->
11+
</div>
12+
```

src/cdk/a11y/interactivity-checker.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### InteractivityChecker
2+
`InteractivityChecker` is used to check the interactivity of an element, capturing disabled,
3+
visible, tabbable, and focusable states for accessibility purposes.
4+
5+
#### Methods
6+
7+
##### `isDisabled(element: HTMLElement): boolean`
8+
Whether the given element is disabled.
9+
10+
##### `isVisible(element: HTMLElement): boolean`
11+
Whether the given element is visible.
12+
13+
This will capture states like `display: none` and `visibility: hidden`,
14+
but not things like being clipped by an `overflow: hidden` parent or being outside the viewport.
15+
16+
##### `isFocusable(element: HTMLElement): boolean`
17+
Gets whether an element can be focused by the user.
18+
19+
##### `isTabbable(element: HTMLElement): boolean`
20+
Gets whether an element can be reached via Tab key.
21+
Assumes that the element has already been checked with isFocusable.

src/cdk/a11y/list-key-manager.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
### ListKeyManager
2+
`ListKeyManager` manages the focus in a list of items based on keyboard interaction. Intended to be
3+
used with components that correspond to a `role="menu"` or `role="listbox"` pattern.
4+
5+
#### Properties
6+
7+
##### `activeItemIndex`
8+
Index of the currently active item
9+
10+
##### `activeItem`
11+
The active item
12+
13+
#### `tabOut`
14+
Observable that emits any time the TAB key is pressed, so components can react when focus is
15+
shifted off of the list.
16+
17+
#### Methods
18+
19+
##### `withWrap(): this`
20+
Turns on wrapping mode, which ensures that the active item will wrap to
21+
the other end of list when there are no more items in the given direction.
22+
23+
##### `setActiveItem(index: number): void`
24+
Sets the active item to the item at the index specified.
25+
26+
##### `onKeydown(event: KeyboardEvent): void`
27+
Sets the active item depending on the key event passed in.
28+
29+
##### `setFirstItemActive(): void`
30+
Sets the active item to the first enabled item in the list.
31+
32+
##### `setLastItemActive(): void`
33+
Sets the active item to the last enabled item in the list.
34+
35+
##### `setNextItemActive(): void`
36+
Sets the active item to the next enabled item in the list.
37+
38+
##### `setPreviousItemActive(): void`
39+
Sets the active item to a previous enabled item in the list.
40+

src/cdk/a11y/list-key-manager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface CanDisable {
2626
export class ListKeyManager<T extends CanDisable> {
2727
private _activeItemIndex: number = -1;
2828
private _activeItem: T;
29-
private _tabOut = new Subject<null>();
29+
private _tabOut = new Subject<void>();
3030
private _wrap: boolean = false;
3131

3232
constructor(private _items: QueryList<T>) { }
@@ -66,7 +66,7 @@ export class ListKeyManager<T extends CanDisable> {
6666
break;
6767
case TAB:
6868
// Note that we shouldn't prevent the default action on tab.
69-
this._tabOut.next(null);
69+
this._tabOut.next();
7070
return;
7171
default:
7272
return;
@@ -75,12 +75,12 @@ export class ListKeyManager<T extends CanDisable> {
7575
event.preventDefault();
7676
}
7777

78-
/** Returns the index of the currently active item. */
78+
/** Index of the currently active item. */
7979
get activeItemIndex(): number | null {
8080
return this._activeItemIndex;
8181
}
8282

83-
/** Returns the currently active item. */
83+
/** The active item. */
8484
get activeItem(): T | null {
8585
return this._activeItem;
8686
}
@@ -118,7 +118,7 @@ export class ListKeyManager<T extends CanDisable> {
118118
* Observable that emits any time the TAB key is pressed, so components can react
119119
* when focus is shifted off of the list.
120120
*/
121-
get tabOut(): Observable<null> {
121+
get tabOut(): Observable<void> {
122122
return this._tabOut.asObservable();
123123
}
124124

src/cdk/a11y/live-announcer.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### LiveAnnouncer
2+
`LiveAnnouncer` is used to announce messages for screen-reader users using an `aria-live` region.
3+
See [the W3C's WAI-ARIA](https://www.w3.org/TR/wai-aria/states_and_properties#aria-live)
4+
for more information on aria-live regions.
5+
6+
#### Methods
7+
8+
##### `announce(message: string, politeness?: 'off' | 'polite' | 'assertive'): void`
9+
Announce the given message via aria-live region. The politeness argument determines the
10+
`aria-live` attribute on the announcer element, defaulting to 'polite'.
11+
12+
#### Examples
13+
The LiveAnnouncer is injected in a component:
14+
```ts
15+
@Component({
16+
selector: 'my-component'
17+
providers: [LiveAnnouncer]
18+
})
19+
export class MyComponent {
20+
21+
constructor(liveAnnouncer: LiveAnnouncer) {
22+
liveAnnouncer.announce("Hey Google");
23+
}
24+
25+
}
26+
```

src/cdk/bidi/bidi.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### BidiModule
2+
3+
When including the CDK's `BidiModule`, components can inject `Directionality` to get the current
4+
text direction (RTL or LTR);
5+
6+
#### Example
7+
```ts
8+
@Component({ ... })
9+
export class MyWidget {
10+
private isRtl: boolean;
11+
12+
constructor(dir: Directionality) {
13+
this.isRtl = dir.value === 'rtl';
14+
15+
dir.change.subscribe(() => {
16+
this.flipDirection();
17+
});
18+
}
19+
}
20+
```
21+

src/cdk/portal/README.md renamed to src/cdk/portal/portal.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
# Portals
2-
3-
### Overview
4-
1+
### Portals
52
A `Portal `is a piece of UI that can be dynamically rendered to an open slot on the page.
63

7-
The "piece of UI" can be either a `Component` or a `TemplateRef`.
4+
The "piece of UI" can be either a `Component` or a `TemplateRef` and the "open slot" is
5+
a `PortalHost`.
86

9-
The "open slot" is a `PortalHost`.
10-
11-
Portals and PortalHosts are low-level building blocks that other concepts, such as overlays, can
12-
be built upon.
7+
Portals and PortalHosts are low-level building blocks that other concepts, such as overlays, are
8+
built upon.
139

1410
##### `Portal<T>`
1511
| Method | Description |
@@ -27,14 +23,10 @@ be built upon.
2723
| `hasAttached: boolean` | Whether a portal is attached to the host. |
2824

2925

30-
31-
32-
### Using portals
33-
34-
26+
### Portals in practice
3527

3628
##### `TemplatePortalDirective`
37-
Used to get a portal from a `<ng-template>`. `TemplatePortalDirectives` *is* a `Portal`.
29+
Used to get a portal from an `<ng-template>`. `TemplatePortalDirectives` *is* a `Portal`.
3830

3931
Usage:
4032
```html
@@ -45,7 +37,7 @@ Usage:
4537
<!-- OR -->
4638

4739
<!-- This result here is identical to the syntax above -->
48-
<p *cdk-portal>
40+
<p *cdkPortal>
4941
The content of this template is captured by the portal.
5042
</p>
5143
```
@@ -54,7 +46,8 @@ A component can use `@ViewChild` or `@ViewChildren` to get a reference to a
5446
`TemplatePortalDirective`.
5547

5648
##### `ComponentPortal`
57-
Used to create a portal from a component type.
49+
Used to create a portal from a component type. When a component is dynamically created using
50+
portals, it must be included in the `entryComponents` of its `NgModule`.
5851

5952
Usage:
6053
```ts
@@ -68,5 +61,5 @@ Used to add a portal host to a template. `PortalHostDirective` *is* a `PortalHos
6861
Usage:
6962
```html
7063
<!-- Attaches the `userSettingsPortal` from the previous example. -->
71-
<ng-template [cdk-portalHost]="userSettingsPortal"></ng-template>
64+
<ng-template [cdkPortalHost]="userSettingsPortal"></ng-template>
7265
```

tools/dgeni/index.js

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const typescriptPackage = require('dgeni-packages/typescript');
1111

1212
// Project configuration.
1313
const projectRootDir = path.resolve(__dirname, '../..');
14-
const sourceDir = path.resolve(projectRootDir, 'src/lib');
14+
const sourceDir = path.resolve(projectRootDir, 'src');
1515
const outputDir = path.resolve(projectRootDir, 'dist/docs/api');
1616
const templateDir = path.resolve(__dirname, './templates');
1717

@@ -82,33 +82,42 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
8282
// Entry points for docs generation. All publically exported symbols found through these
8383
// files will have docs generated.
8484
readTypeScriptModules.sourceFiles = [
85-
'autocomplete/index.ts',
86-
'button/index.ts',
87-
'button-toggle/index.ts',
88-
'card/index.ts',
89-
'checkbox/index.ts',
90-
'chips/index.ts',
91-
'core/index.ts',
92-
'datepicker/index.ts',
93-
'dialog/index.ts',
94-
'expansion/index.ts',
95-
'grid-list/index.ts',
96-
'icon/index.ts',
97-
'input/index.ts',
98-
'list/index.ts',
99-
'menu/index.ts',
100-
'paginator/index.ts',
101-
'progress-bar/index.ts',
102-
'progress-spinner/index.ts',
103-
'radio/index.ts',
104-
'select/index.ts',
105-
'sidenav/index.ts',
106-
'slide-toggle/index.ts',
107-
'slider/index.ts',
108-
'snack-bar/index.ts',
109-
'tabs/index.ts',
110-
'toolbar/index.ts',
111-
'tooltip/index.ts',
85+
// @angular/cdk
86+
'cdk/a11y/index.ts',
87+
'cdk/bidi/index.ts',
88+
'cdk/coercion/index.ts',
89+
'cdk/platform/index.ts',
90+
'cdk/portal/index.ts',
91+
'cdk/table/index.ts',
92+
93+
// @angular/material
94+
'lib/autocomplete/index.ts',
95+
'lib/button/index.ts',
96+
'lib/button-toggle/index.ts',
97+
'lib/card/index.ts',
98+
'lib/checkbox/index.ts',
99+
'lib/chips/index.ts',
100+
'lib/core/index.ts',
101+
'lib/datepicker/index.ts',
102+
'lib/dialog/index.ts',
103+
'lib/expansion/index.ts',
104+
'lib/grid-list/index.ts',
105+
'lib/icon/index.ts',
106+
'lib/input/index.ts',
107+
'lib/list/index.ts',
108+
'lib/menu/index.ts',
109+
'lib/paginator/index.ts',
110+
'lib/progress-bar/index.ts',
111+
'lib/progress-spinner/index.ts',
112+
'lib/radio/index.ts',
113+
'lib/select/index.ts',
114+
'lib/sidenav/index.ts',
115+
'lib/slide-toggle/index.ts',
116+
'lib/slider/index.ts',
117+
'lib/snack-bar/index.ts',
118+
'lib/tabs/index.ts',
119+
'lib/toolbar/index.ts',
120+
'lib/tooltip/index.ts',
112121
];
113122
})
114123

@@ -145,3 +154,7 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
145154

146155

147156
module.exports = apiDocsPackage;
157+
158+
159+
const docs = new Dgeni([apiDocsPackage]);
160+
docs.generate();

0 commit comments

Comments
 (0)