From c77dcf8a50cea3634d632bb9d84a856fb6274b44 Mon Sep 17 00:00:00 2001 From: crisbeto Date: Thu, 25 Oct 2018 23:41:31 +0200 Subject: [PATCH] docs: add example for cdk platform 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. --- src/cdk/platform/platform.md | 5 +++- .../cdk-platform-overview-example.css | 1 + .../cdk-platform-overview-example.html | 11 +++++++++ .../cdk-platform-overview-example.ts | 23 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/material-examples/cdk-platform-overview/cdk-platform-overview-example.css create mode 100644 src/material-examples/cdk-platform-overview/cdk-platform-overview-example.html create mode 100644 src/material-examples/cdk-platform-overview/cdk-platform-overview-example.ts diff --git a/src/cdk/platform/platform.md b/src/cdk/platform/platform.md index 0ad007d9982d..5f033dca60c8 100644 --- a/src/cdk/platform/platform.md +++ b/src/cdk/platform/platform.md @@ -1,3 +1,6 @@ ### Platform -A service for determing the current platform. \ No newline at end of file +A set of utilities that gather information about the current +platform and the different features it supports. + + diff --git a/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.css b/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.css new file mode 100644 index 000000000000..7432308753e6 --- /dev/null +++ b/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.css @@ -0,0 +1 @@ +/** No CSS for this example */ diff --git a/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.html b/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.html new file mode 100644 index 000000000000..b130bd12ec02 --- /dev/null +++ b/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.html @@ -0,0 +1,11 @@ +

Platform information:

+

Is Android: {{platform.ANDROID}}

+

Is iOS: {{platform.IOS}}

+

Is Firefox: {{platform.FIREFOX}}

+

Is Blink: {{platform.BLINK}}

+

Is Webkit: {{platform.WEBKIT}}

+

Is Trident: {{platform.TRIDENT}}

+

Is Edge: {{platform.EDGE}}

+

Supported input types: {{supportedInputTypes}}

+

Supports passive event listeners: {{supportsPassiveEventListeners}}

+

Supports scroll behavior: {{supportsScrollBehavior}}

diff --git a/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.ts b/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.ts new file mode 100644 index 000000000000..41fd1998e1e1 --- /dev/null +++ b/src/material-examples/cdk-platform-overview/cdk-platform-overview-example.ts @@ -0,0 +1,23 @@ +import {Component} from '@angular/core'; +import { + getSupportedInputTypes, + Platform, + supportsPassiveEventListeners, + supportsScrollBehavior, +} from '@angular/cdk/platform'; + +/** + * @title Platform overview + */ +@Component({ + selector: 'cdk-platform-overview-example', + templateUrl: 'cdk-platform-overview-example.html', + styleUrls: ['cdk-platform-overview-example.css'], +}) +export class CdkPlatformOverviewExample { + supportedInputTypes = Array.from(getSupportedInputTypes()).join(', '); + supportsPassiveEventListeners = supportsPassiveEventListeners(); + supportsScrollBehavior = supportsScrollBehavior(); + + constructor(public platform: Platform) {} +}