UNPKG

4.81 kBMarkdownView Raw
1# ng2 - flashbox
2[![npm version](https://img.shields.io/npm/v/ng2-flashbox.svg)](https://www.npmjs.com/package/ng2-flashbox) [![npm downloads-monthly](https://img.shields.io/npm/dm/ng2-flashbox.svg)](https://www.npmjs.com/package/ng2-flashbox) [![npm downloads-total](https://img.shields.io/npm/dt/ng2-flashbox.svg)](https://www.npmjs.com/package/ng2-flashbox)
3
4FlashBox component is angular2 component provided to display simple user information messages.
5
6GitHub repository for component module can be found here [ng2-flashbox](https://github.com/vladimirpavk/ng2-flashbox/).
7
8GitHub repository for sample application(Angular4, SystemJS) can be found here [Angular4-FlashBoxComponent](https://github.com/vladimirpavk/Angular4-FlashBoxComponent).
9
10Online sample application can be found at github pages [online-demo](https://vladimirpavk.github.io/Angular4-FlashBoxComponent/).
11
12### Dependencies
13FlashBox is angular2 component dependent on only **@angular/core** and **@angular/platform-browser** modules.
14
15### Installation
16```
17npm install ng2-flashbox --save
18```
19
20### How to use FlashBox component
21FlashBox component is (for now only) part of the CommonComponents module.
22
23In order to use the module you must configure your module loader. In case you use **systemjs** module loader add the following mapings:
24```
25System.config({
26 ...
27 paths: {
28 ...
29 'npm:': 'node_modules/'
30 ...
31 },
32 map: {
33 ...
34 'ng2-flashbox': 'npm:ng2-flashbox'
35 ...
36 },
37 packages: {
38 ...
39 'ng2-flashbox': {
40 main: 'index',
41 defaultExtension: 'js'
42 }
43 ...
44 }
45 ...
46})
47```
48
49In your application module definition file import CommonComponents module.
50```
51...
52Import { CommonComponentsModule } from 'ng2-flashbox';
53...
54@NgModule({
55 ...
56 imports: [ ...
57 CommonComponentsModule
58 ...
59 ],
60 ...
61})
62```
63
64Now we can use FlashBox component in our module declared components templates with ```<flash-box>``` element.
65Place your HTML based user information message inside element.
66
67```
68<flash-box>
69 <!-- HTML Message -->
70 <div style="border-type: solid; border-width:2px">
71 <label style="color: rgb(0,0,0); text-decoration: underline;">Information message</label>
72 <label>
73 Any message
74 </label>
75 </div>
76</flash-box>
77
78```
79
80### Attributes
81
82```
83<flash-box type="type_value" position="position_value" max-width="maxwidth_value" setTimeout="setTimeout_value">
84 <!-- HTML message -->
85</flash-box>
86```
87
881. **type_value**: *string*, default: **primary**
89Specify FlashBox type.
90
91Available types: **default**, **primary**, **success**, **info**, **warning**, **danger**
92based on default bootstrap label types
93
942. **position_value**: *string*, default: **tr**.
95Specify FlashBox position.
96
97Available values:
98 * **tr** - top-right,
99 * **tm** - top-middle,
100 * **tl** - top-left,
101 * **cr** - center-right,
102 * **cm** - center-middle,
103 * **cl** - center-left,
104 * **br** - bottom-right,
105 * **bm** - bottom-middle,
106 * **bl** - bottom-left
107
1083. **max-width_value**: *string*, default: **300px**
109Specify FlashBox component maximum width.
110
1114. **setTimeout_value**: *number*, default: **2000**
112Specify the amount of time the component is visible in *ms*. Default is **2 sec**.
113
114
115### Actions
116
117In order to cause an flashbox control action use angular2 template local variable system or controler method invokation.
118
119#### **Template local variable example**
120```
121 <flash-box .... #tlv_name>
122 ....
123 </flash-box>
124
125 <button (click)="tlv_name.available_action()">Cause flashbox action</button>
126```
127
128#### **Controller method invokation example**
129
130reference component source
131```
132 import { FlashBoxComponent } from 'ng2-flashbox';
133```
134
135reference component from template local variable using
136```
137 @ViewChild("tlv_name") tlv:FlashBoxComponent;
138 tlv.available_action();
139```
140
141##### **Available actions(available_action())**:
1421. **flashOnce():void** - Show flashbox only once for **setTimeout** amount of time
1432. **show():void** - Make control visible for unlimited amount of time (or untill some other action happens)
1443. **hide():void** - Make control hidden for unlimited amount of time (or untill some other action happens)
1454. **startFlashing():void** - Start flashing for unlimited amount of time (or untill some other action happens).
146Transition period from unvisible to visible is set to **0,5 sec** and is currently unconfigurable. The flashbox control us shown for **setTimeout** amount of time.
1475. **stopFlashing():void** - Stop flashing
1486. **toogle():void** - Toggle show/hide control
\No newline at end of file