Skip to content

Commit ab5127b

Browse files
crisbetojelbourn
authored andcommitted
docs: add example for cdk platform (#13821)
Since the overview for `cdk/platform` is pretty bare on the docs site at the moment, these changes add an example that illustrates how the utilities can be used.
1 parent 91d4c0f commit ab5127b

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

src/cdk/platform/platform.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
### Platform
22

3-
A service for determing the current platform.
3+
A set of utilities that gather information about the current
4+
platform and the different features it supports.
5+
6+
<!-- example(cdk-platform-overview) -->
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<h3>Platform information:</h3>
2+
<p>Is Android: {{platform.ANDROID}}</p>
3+
<p>Is iOS: {{platform.IOS}}</p>
4+
<p>Is Firefox: {{platform.FIREFOX}}</p>
5+
<p>Is Blink: {{platform.BLINK}}</p>
6+
<p>Is Webkit: {{platform.WEBKIT}}</p>
7+
<p>Is Trident: {{platform.TRIDENT}}</p>
8+
<p>Is Edge: {{platform.EDGE}}</p>
9+
<p>Supported input types: {{supportedInputTypes}}</p>
10+
<p>Supports passive event listeners: {{supportsPassiveEventListeners}}</p>
11+
<p>Supports scroll behavior: {{supportsScrollBehavior}}</p>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Component} from '@angular/core';
2+
import {
3+
getSupportedInputTypes,
4+
Platform,
5+
supportsPassiveEventListeners,
6+
supportsScrollBehavior,
7+
} from '@angular/cdk/platform';
8+
9+
/**
10+
* @title Platform overview
11+
*/
12+
@Component({
13+
selector: 'cdk-platform-overview-example',
14+
templateUrl: 'cdk-platform-overview-example.html',
15+
styleUrls: ['cdk-platform-overview-example.css'],
16+
})
17+
export class CdkPlatformOverviewExample {
18+
supportedInputTypes = Array.from(getSupportedInputTypes()).join(', ');
19+
supportsPassiveEventListeners = supportsPassiveEventListeners();
20+
supportsScrollBehavior = supportsScrollBehavior();
21+
22+
constructor(public platform: Platform) {}
23+
}

0 commit comments

Comments
 (0)