-
Notifications
You must be signed in to change notification settings - Fork 1
/
angular2.html
executable file
·385 lines (349 loc) · 17.8 KB
/
angular2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!DOCTYPE html>
<html lang="en">
<head>
<title>Patternfly Web Components</title>
<!-- Meta -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="favicon.ico">
<!-- Global CSS -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/patternfly/3.18.1/css/patternfly.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/patternfly/3.18.1/css/patternfly-additions.min.css">
<link rel="stylesheet" href="//rawgit.com/patternfly-webcomponents/patternfly-webcomponents/master-dist/dist/css/patternfly-webcomponents.css">
<!-- Plugins CSS -->
<link rel="stylesheet" href="assets/plugins/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="assets/css/custom.css">
<link rel="stylesheet" href="assets/css/sidebar.css">
</head>
<body class="body-blue">
<header id="header">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img class="navbar-brand-icon" alt="brand" src="assets/images/logo-alt.svg"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="index.html">Home</a></li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Frameworks <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="angular.html">Angular</a></li>
<li class="active"><a href="angular2.html">Angular2<span class="sr-only">(current)</span></a></li>
<li><a href="react.html">React</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="components.html">Components</a></li>
<li><a href="https://github.com/patternfly-webcomponents/patternfly-webcomponents">Github</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</header>
<div class="doc-wrapper">
<div class="container">
<div id="doc-header" class="doc-header text-center">
<h1 class="doc-title">Angular2 Components</h1>
</div>
<!--//doc-header-->
<div class="doc-body">
<div class="doc-content">
<div class="content-inner">
<!-- Overview -->
<section id="overview" class="doc-section">
<h2 class="section-title">Overview</h2>
<div class="section-block">
<p>Angular 2 Component extensions (shims) for Patternfly web components are implemented to enhance the Angular
2 experience and ease consumption in the Angular 2 framework.</p>
<p> Angular 2 Components require the core component dependencies mentioned in <a href="components.html">Components</a> along with the following extension <a href="https://github.com/patternfly-webcomponents/angular2-patternfly-shims">library</a>:</p>
<pre class="language-bash"><code class="language-bash">npm install --save angular2-patternfly-shims</code></pre>
<p> Add the Custom Elements schema to your <code>@NgModule</code>:</p>
<pre class="language-javascript"><code class="language-javascript">import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@NgModule({
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
</code></pre>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<!-- Alerts -->
<section id="alerts" class="doc-section">
<h2 class="section-title">Alerts</h2>
<div class="section-block">
<div class="docs-example">
<pf-alert type="info" persistent="true">Well done <strong>John</strong>! You successfully read this important alert message.
</pf-alert>
</div>
<pre class=" language-html"><code class=" language-html"><pf-alert type="info" [persistent]="isPersistent">
Well done <strong>{{user.name}}</strong>! You successfully read this important alert message.
</pf-alert>
</code></pre>
<pre class=" language-typescript"><code class=" language-typescript">import { Component } from '@angular/core';
@Component({
selector: 'example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css']
})
export class ExampleComponent {
constructor() {
this.user = {name: 'John'};
this.isPersistent = true;
}
}
</code></pre>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<!-- Charts -->
<section id="charts" class="doc-section">
<h2 class="section-title">Charts</h2>
<div id="utilization-bar" class="section-block">
<h3 class="block-title">Utilization Bar Chart</h3>
<p>The Utilization Bar Chart depicts the percentage utilization ratio between used and available.</p>
<div class="docs-example">
<label class="example-label-title">Thresholds</label>
<pf-utilization-bar-chart id="thresholdExample1" chart-title="RAM Usage" used="10" total="100" units="MB" threshold-warning="60"
threshold-error="85"></pf-utilization-bar-chart>
</div>
<pre class=" language-html"><code class=" language-html"><pf-utilization-bar-chart (thresholdSet)="thresholdSet($event)" #thresholdExample chart-title="RAM Usage" [used]="used" total="100" units="MB" threshold-warning="60" threshold-error="85"></pf-utilization-bar-chart>
</code></pre>
<pre class=" language-javascript"><code class=" language-javascript">import { Component, OnInit } from '@angular/core';
@Component({
selector: 'example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css']
})
export class ExampleComponent implements OnInit {
constructor() {}
ngOnInit() {
this.used = 10;
setInterval(() => {
if(this.used > 100){
this.used = 10;
} else {
this.used += 10;
}
});
}
thresholdSet(event: Event){
//monitor threshold here!
let threshold = event.detail.threshold;
}
}
</code></pre>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<!-- Tabs -->
<section id="tabs" class="doc-section">
<h2 class="section-title">Tabs</h2>
<div class="section-block">
<div class="docs-example">
<pf-tabs id="pf-tabs">
<pf-tab tabTitle="Cupcakes">
<p>Cupcake ipsum dolor. Sit amet topping. Jelly-o cake ice cream jujubes marshmallow cotton candy.</p>
</pf-tab>
<pf-tab tabTitle="Caramels">
<p>Candy caramels sweet roll macaroon pastry cupcake liquorice. Cookie I love topping I love cookie toffee
chocolate bar. Jelly-o sweet roll I love dessert powder.</p>
</pf-tab>
</pf-tabs>
<script>
var pfTabs = document.querySelector('#pf-tabs');
pfTabs.setActiveTab('Caramels');
</script>
</div>
<pre class=" language-html"><code class=" language-html"><pf-tabs #pfTabs class="nav nav-tabs" (tabChanged)="onTabChanged($event)">
<pf-tab tabTitle="Cupcakes">
<p>Cupcake ipsum dolor. Sit amet topping. Jelly-o cake ice cream jujubes marshmallow cotton candy.</p>
</pf-tab>
<pf-tab tabTitle="Caramels">
<p>Candy caramels sweet roll macaroon pastry cupcake liquorice. Cookie I love topping I love cookie toffee chocolate bar. Jelly-o sweet roll I love dessert powder.</p>
</pf-tab>
</pf-tabs>
</code></pre>
<pre class="language-javascript"><code class="language-javascript">import { Component, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
@Component({
selector: 'example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css']
})
export class ExampleComponent implements AfterViewInit {
@ViewChild('pfTabs') pfTabs:ElementRef;
constructor() {}
onTabChanged(event: Event) {
//active tab is now: event.detail
}
ngAfterViewInit() {
//programmatically changes the active tab
this.pfTabs.nativeElement.setActiveTab('Caramels');
}
}
</code></pre>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<!-- Tooltips -->
<section id="tooltips" class="doc-section">
<h2 class="section-title">Tooltips</h2>
<div class="section-block">
<div class="docs-example">
<pf-tooltip id="tooltip-left" placement="left" target-selector="#btn-left">
Look Ma!
</pf-tooltip>
<button id="btn-left" type="button" class="btn btn-primary btn-lg" aria-describedby="tooltip-left">Left</button>
<pf-tooltip id="tooltip-top" placement="top" target-selector="#btn-top">
It still binds!
</pf-tooltip>
<button id="btn-top" type="button" class="btn btn-default btn-lg" aria-describedby="tooltip-top">Top</button>
<pf-tooltip id="tooltip-bottom" placement="bottom" target-selector="#btn-bottom">
Oh, that's great!
</pf-tooltip>
<button id="btn-bottom" type="button" class="btn btn-warning btn-lg" aria-describedby="tooltip-bottom">Bottom</button>
<pf-tooltip id="tooltip-right" placement="right" target-selector="#btn-right">
Must be an observer.
</pf-tooltip>
<button id="btn-right" type="button" class="btn btn-danger btn-lg" aria-describedby="tooltip-right">Right</button>
</div>
<pre class=" language-html"><code class=" language-html"><pf-tooltip id="tooltip-left" placement="left" target-selector="#btn-left">{{tooltipLeft}}</pf-tooltip>
<button id="btn-left" type="button" class="btn btn-primary btn-lg" aria-describedby="tooltip-left">Left</button>
<pf-tooltip id="tooltip-top" placement="top" target-selector="#btn-top">{{tooltipTop}}</pf-tooltip>
<button id="btn-top" type="button" class="btn btn-default btn-lg" aria-describedby="tooltip-top">Top</button>
<pf-tooltip id="tooltip-bottom" placement="bottom" target-selector="#btn-bottom">{{tooltipBottom}}</pf-tooltip>
<button id="btn-bottom" type="button" class="btn btn-warning btn-lg" aria-describedby="tooltip-bottom">Bottom</button>
<pf-tooltip id="tooltip-right" placement="right" target-selector="#btn-right">{{tooltipRight}}</pf-tooltip>
<button id="btn-right" type="button" class="btn btn-danger btn-lg" aria-describedby="tooltip-right">Right</button>
</code></pre>
<p> Import the <code>Tooltip</code> extension into your component's module: </p>
<pre class="language-javascript"><code class="language-javascript">import { TooltipComponent } from 'angular2-patternfly-shims/lib/Tooltip';
@NgModule({
declarations: [
TooltipComponent
]
})
export class AppModule { }
</code></pre>
<p> Add bindings in your component: </p>
<pre class="language-javascript"><code class="language-javascript">import { Component } from '@angular/core';
@Component({
selector: 'example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css']
})
export class ExampleComponent {
constructor() {
this.tooltipLeft = "Look Ma!";
this.tooltipTop = "It still binds!";
this.tooltipBottom = "Oh, that's great.";
this.tooltipRight = "Must be an observer.";
}
}
</code></pre>
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
<section id="demo-apps" class="doc-section">
<h2 class="section-title">Demo Apps</h2>
<div class="section-block">
<p>The following <a href="https://angular2-cli-webcomponents.firebaseapp.com/">app</a> demonstrates use of Angular
2 with Patternfly web components.</p>
<div class="row">
<div class="col-md-4 col-sm-5 col-xs-12">
<h6>Components List</h6>
<ul class="list list-unstyled">
<li><a href="angular2.html#tabs"><i class="fa fa-check"></i> Tabs</a></li>
<li><a href="angular2.html#tooltips"><i class="fa fa-check"></i> Tooltips</a></li>
</ul>
<br/>
<h6>Github Project</h6>
<a href="https://github.com/patternfly-webcomponents/angular2-cli-webcomponents">Link to Project</a>
</div>
<div class="col-md-8 col-sm-5 col-xs-12">
<h6>Screenshot</h6>
<div class="screenshot-holder">
<a href="https://angular2-cli-webcomponents.firebaseapp.com/" target="_blank"><img class="img-responsive" src="assets/images/demo/angular2-demo.png" alt="screenshot" /></a>
</div>
</div>
</div>
<!--//row-->
</div>
<!--//section-block-->
</section>
<!--//doc-section-->
</div>
<!--//content-inner-->
</div>
<!--//doc-content-->
<div class="doc-sidebar">
<nav id="doc-nav">
<ul id="doc-menu" class="nav doc-menu hidden-xs" data-spy="affix">
<li><a class="scrollto" href="#overview">Overview</a></li>
<li><a class="scrollto" href="#alerts">Alerts</a></li>
<li>
<a class="scrollto" href="#charts">Charts</a>
<ul class="nav doc-sub-menu">
<li><a class="scrollto" href="#utilization-bar">Utilization Bar</a></li>
</ul>
<!--//nav-->
</li>
<li><a class="scrollto" href="#tabs">Tabs</a></li>
<li><a class="scrollto" href="#tooltips">Tooltips</a></li>
<li><a class="scrollto" href="#demo-apps">Demo Apps</a></li>
</ul>
<!--//doc-menu-->
</nav>
</div>
<!--//doc-sidebar-->
</div>
<!--//doc-body-->
</div>
<!--//container-->
</div>
<!--//doc-wrapper-->
<footer id="footer">
<div class="container">
<div class="row">
<div class="text-center col">
<p class="social">
<iframe src="https://ghbtns.com/github-btn.html?user=patternfly-webcomponents&repo=patternfly-webcomponents&type=star&count=true"
frameborder="0" scrolling="0" width="80" height="30px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=patternfly-webcomponents&repo=patternfly-webcomponents&type=fork&count=true"
frameborder="0" scrolling="0" width="80" height="30px"></iframe>
</p>
</div>
</div>
</div>
</footer>
<!-- Main Javascript -->
<script src="assets/plugins/jquery-1.12.3.min.js"></script>
<script src="assets/js/prism.js"></script>
<script type="text/javascript" src="assets/plugins/jquery-scrollTo/jquery.scrollTo.min.js"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/scripts.js"></script>
<!-- web components -->
<script src="//cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.0/webcomponents-lite.js"></script>
<script src="//rawgit.com/webcomponents/custom-elements/master/src/native-shim.js"></script>
<script src="//rawgit.com/patternfly-webcomponents/patternfly-webcomponents/master-dist/dist/js/patternfly.js"></script>
</body>
</html>