@@ -3,73 +3,92 @@ layout: content
3
3
title: Notification
4
4
seoTitle: Notifications UI example based on ESL web components
5
5
name: Notification
6
- tags: examples
6
+ tags: [ examples, playground]
7
7
icon: examples/notification.svg
8
8
aside:
9
9
components:
10
10
- esl-alert
11
11
---
12
- {% import ' lorem.njk' as lorem %}
13
12
14
13
<section class =" row" >
15
14
<div class =" col-12" >
16
- <h2 >Triggers</h2 >
17
- <div class =" btn-container" >
18
- <button type =" button" class =" btn btn-sec-blue esl-alert-show"
19
- data-text =" Global Alert Long" data-cls =" alert alert-warning" >Show Long
20
- </button >
21
- <button type =" button" class =" btn btn-sec-blue esl-alert-show"
22
- data-text =" Global Alert Short" data-delay =" 1500" data-cls =" alert alert-info" >Show Quick
23
- </button >
24
- <button type =" button" class =" btn btn-sec-blue esl-alert-hide" >Hide</button >
25
- </div >
26
- </div >
27
- </section >
28
-
29
- <section class =" row" >
30
- <div class =" col-12" >
31
- <h2 >Triggers Encapsulated</h2 >
32
- <div class =" border p-3" style =" min-height : 210px " >
33
- <div class =" btn-container" >
15
+ <uip-root >
16
+ <script type =" text/html"
17
+ label =" Show Long"
18
+ uip-snippet
19
+ uip-snippet-js =" js-snippet-alert-registration" >
34
20
<button type =" button" class =" btn btn-sec-orange esl-alert-show"
35
- data-cls =" alert alert-success"
36
- data-html =" Inner <h2>Alert</h2> Long" >Show Long
21
+ onclick =" ESL.EventUtils.dispatch(document.body, 'esl:alert:show', {
22
+ detail: {
23
+ text: 'Global Alert Long',
24
+ cls: 'alert alert-warning',
25
+ }
26
+ })" >
27
+ Show Long
37
28
</button >
29
+ </script >
30
+
31
+ <!-- Show Quick and Hide Alert -->
32
+ <script type =" text/html"
33
+ label =" Show Short"
34
+ uip-snippet
35
+ uip-snippet-js =" js-snippet-alert-registration" >
38
36
<button type =" button" class =" btn btn-sec-orange esl-alert-show"
39
- data-cls =" alert alert-danger"
40
- data-text =" Inner Alert Short" data-delay =" 1500" >Show Quick
37
+ onclick =" ESL.EventUtils.dispatch(document.body, 'esl:alert:show', {
38
+ detail: {
39
+ html: 'Inner <h2>Alert</h2> Short',
40
+ cls: 'alert alert-info',
41
+ hideDelay: 1500
42
+ }
43
+ })" >
44
+ Show Shot
45
+ </button >
46
+ <button type =" button" class =" btn btn-sec-blue esl-alert-hide"
47
+ onclick =" ESL.EventUtils.dispatch(document.body, 'esl:alert:hide')" >
48
+ Hide
41
49
</button >
42
- <button type =" button" class =" btn btn-sec-orange esl-alert-hide" >Hide</button >
43
- </div >
50
+ </script >
44
51
45
- <esl-alert default-params =" {cls: 'bg-warn'}" ></esl-alert >
46
- </div >
47
- </div >
48
- </section >
52
+ <script id =" js-snippet-alert-registration" type =" text/plain" >
53
+ import {ESLEventUtils , ESLAlert } from ' @exadel/esl' ;
54
+ ESLAlert .register ();
55
+ ESLAlert .init ();
56
+ </script >
57
+
58
+ <!-- Triggers Encapsulated -->
59
+ <script type =" text/html"
60
+ label =" Triggers Encapsulated"
61
+ uip-snippet
62
+ uip-snippet-js =" js-snippet-alert-registration-n-handler"
63
+ uip-isolated >
64
+ <div class =" border p-3" style =" min-height : 310px " >
65
+ <button type =" button" id =" showAlertButton" class =" btn btn-sec-orange esl-alert-show" >
66
+ Show Long
67
+ </button >
68
+ <esl-alert default-params =" {cls: 'alert alert-info'}" ></esl-alert >
69
+ </div >
70
+ </script >
71
+
72
+ <script id =" js-snippet-alert-registration-n-handler" type =" text/plain" >
73
+ import {ESLEventUtils , ESLAlert } from ' @exadel/esl' ;
74
+ ESLAlert .register ();
75
+ ESLAlert .init ();
49
76
50
- <script type =" text/javascript" >
51
- document .body .addEventListener (' click' , function (e ) {
52
- /** @type HTMLElement */
53
- var el = e .target ;
54
- var params = {};
77
+ const showAlertButton = document .getElementById (' showAlertButton' );
78
+ showAlertButton .addEventListener (' click' , () => {
79
+ ESLEventUtils .dispatch (document .body , ' esl:alert:show' , {
80
+ detail: {
81
+ cls: ' alert alert-info' ,
82
+ html: ' Inner <h2>Alert</h2> Long'
83
+ }})
84
+ });
85
+ </script >
55
86
56
- if (el && el .matches (' .esl-alert-show' )) {
57
- if (el .dataset .cls ) {
58
- params .cls = el .dataset .cls ;
59
- }
60
- if (el .dataset .text ) {
61
- params .text = el .dataset .text ;
62
- }
63
- if (el .dataset .html ) {
64
- params .html = el .dataset .html ;
65
- }
66
- if (el .dataset .delay ) {
67
- params .hideDelay = + el .dataset .delay ;
68
- }
69
- el .dispatchEvent (new CustomEvent (` esl:alert:show` , {bubbles: true , detail: params}));
70
- }
71
- if (el && el .matches (' .esl-alert-hide' )) {
72
- el .dispatchEvent (new CustomEvent (` esl:alert:hide` , {bubbles: true }));
73
- }
74
- });
75
- </script >
87
+
88
+ <uip-snippets class =" uip-toolbar" dropdown-view =" @xs" ></uip-snippets >
89
+ <uip-preview resizable ></uip-preview >
90
+ <uip-editor label =" Source code (HTML)" collapsible copy ></uip-editor >
91
+ <uip-editor source =" js" label =" JavaScript" collapsible copy ></uip-editor >
92
+ </uip-root >
93
+ </div >
94
+ </section >
0 commit comments