|
1 | 1 | # vue-toastr |
2 | 2 |
|
3 | | -> This is master branch vue-toastr which works only with **Vue 2.x**. vue-toastr@**latest** |
| 3 | +## Project setup |
4 | 4 |
|
5 | | -> For the **Vue 1.x** see the [1.0 branch](https://github.com/s4l1h/vue-toastr/tree/1.0). vue-toastr@**1.0.4** |
6 | | -
|
7 | | - |
8 | | -**Note:**:closeOnHover,onMouseOver,onMouseOut works only **2.x** |
9 | | - |
10 | | - |
11 | | -### With npm & babel |
12 | | - |
13 | | -*Add the Toast into the package.json. #for vue **1.x*** |
14 | | - |
15 | | - npm install vue-toastr@^1.0.4 --save |
16 | | - |
17 | | - |
18 | | -*Add the Toast into the package.json. #for vue **2.x*** |
19 | | - |
20 | | - npm install vue-toastr@latest --save |
21 | | - |
22 | | -*Add the toast in application and register component.* |
23 | | - |
24 | | - // import Toastr |
25 | | - import Toastr from 'vue-toastr'; |
26 | | - // import toastr scss file: need webpack sass-loader |
27 | | - require('vue-toastr/src/vue-toastr.scss'); |
28 | | - // Register vue component |
29 | | - Vue.component('vue-toastr',Toastr); |
30 | | -***Plugin** mode (work only vue 2.x)* |
31 | | - |
32 | | - // import Toastr |
33 | | - import Toastr from 'vue-toastr'; |
34 | | - // import toastr scss file: need webpack sass-loader |
35 | | - require('vue-toastr/src/vue-toastr.scss'); |
36 | | - // Register plugin |
37 | | - Vue.use(Toastr, { /* options */ }); |
38 | | -***Plugin** Mode vue **2.x*** |
39 | | - |
40 | | - this.$toastr // use plugin mode autoamatic installed if you use browser. |
41 | | - |
42 | | -*Add component html: for vue **1.x*** |
43 | | - |
44 | | - <vue-toastr v-ref:toastr></vue-toastr> |
45 | | - |
46 | | -*Add component html: for vue **2.x*** |
47 | | - |
48 | | - <vue-toastr ref="toastr"></vue-toastr> |
49 | | - |
50 | | -*Now you can manage toastr* |
51 | | - |
52 | | - // use component |
53 | | - this.$root.$refs.toastr.e("ERRROR MESSAGE"); |
54 | | - this.$root.$refs.toastr.s("SUCCESS MESSAGE"); |
55 | | - // use plugin |
56 | | - this.$toastr.e("ERRROR MESSAGE"); |
57 | | - this.$toastr.s("SUCCESS MESSAGE"); |
58 | | - |
59 | | -### without npm |
60 | | - |
61 | | -http://s4l1h.github.io/vue-toastr/ |
62 | | - |
63 | | -### Development Setup |
64 | | - |
65 | | -``` bash |
66 | | -# install deps |
67 | | -npm install |
68 | | - |
69 | | -# serve examples at http://localhost:8080/ |
70 | | -npm run dev |
71 | | -# build dist/vue-toastr.js dist/vue-toastr.css |
72 | | -npm run build |
73 | | -# build for production min version. dist/vue-toastr.min.js dist/vue-toastr.min.css |
74 | | -npm run build_min |
75 | | -# build for production js+css combine. dist/vue-toastr.combine.min.js |
76 | | -npm run build_combine |
77 | | -# clear All builds.. rm -rf dist/* |
78 | | -npm run clear |
79 | | -#Build all. npm run build && npm run build_min && npm run build_combine |
80 | | -npm run buildAll |
| 5 | +``` |
| 6 | +yarn install |
81 | 7 | ``` |
82 | 8 |
|
83 | | -## Doc # Overwrite Settings |
84 | | - |
85 | | -### Overwrite inside component |
| 9 | +### Compiles and hot-reloads for development |
86 | 10 |
|
87 | | -#### Change Default Toast Timeout |
88 | | -``` |
89 | | -this.$refs.toastr.defaultTimeout = 3000; // default timeout : 5000 |
90 | | -``` |
91 | | -#### Change Default Toast ProgressBar |
92 | | -``` |
93 | | -this.$refs.toastr.defaultProgressBar = false; // default active : true |
94 | | -``` |
95 | | -#### Change Default Toast ProgressBar Manual Value |
96 | 11 | ``` |
97 | | -this.$refs.toastr.defaultProgressBarValue = 0; // default value : null (managed by JS timer) |
98 | | -``` |
99 | | -#### Change Default Toast Type |
100 | | -``` |
101 | | -this.$refs.toastr.defaultType = "error"; // default type : success |
102 | | -``` |
103 | | -#### Change Default Position |
104 | | -``` |
105 | | -this.$refs.toastr.defaultPosition = "toast-bottom-left" // default position: toast-top-right |
106 | | -``` |
107 | | -#### Change Default Close On Mouse Hover |
108 | | -``` |
109 | | -this.$refs.toastr.defaultCloseOnHover = false // default close on hover: true |
110 | | -``` |
111 | | -#### Change Default Style |
112 | | -``` |
113 | | -this.$refs.toastr.defaultStyle = { "background-color": "red" } // default style: { } |
| 12 | +yarn run demo |
114 | 13 | ``` |
115 | 14 |
|
116 | | -### Overwrite via plugin options |
117 | | -*You can also overwrite defaults by passing options object during plugin registration* |
118 | | -``` |
119 | | -Vue.use(Toastr, { |
120 | | - defaultTimeout: 3000, |
121 | | - defaultProgressBar: false, |
122 | | - defaultProgressBarValue: 0, |
123 | | - defaultType: "error", |
124 | | - defaultPosition: "toast-bottom-left", |
125 | | - defaultCloseOnHover: false, |
126 | | - defaultStyle: { "background-color": "red" } |
127 | | -}) |
128 | | -``` |
| 15 | +### Compiles and minifies for production |
129 | 16 |
|
130 | | -## Doc # method |
131 | | -#### New Error Type Toast Message |
132 | | -``` |
133 | | -this.$refs.toastr.e("this.$refs.toastr.e message", "Error"); |
134 | | -``` |
135 | | -#### New Success Type Toast Message |
136 | | -``` |
137 | | -this.$refs.toastr.s("this.$refs.toastr.s message"); |
138 | | -``` |
139 | | -#### New Warning Type Toast Message |
140 | | -``` |
141 | | -this.$refs.toastr.w("this.$refs.toastr.w message", "Warning"); |
142 | 17 | ``` |
143 | | -#### New Information Type Toast Message |
144 | | -``` |
145 | | -this.$refs.toastr.i("this.$refs.toastr.i message", "Information"); |
146 | | -``` |
147 | | -#### Remove Toast Messages by type. |
148 | | -``` |
149 | | -this.$refs.toastr.removeByType("error"); // error, warning, success, info |
150 | | -``` |
151 | | -#### Remove Toast Messages by Name. |
152 | | -``` |
153 | | -this.$refs.toastr.removeByName("UniqueToastName"); |
154 | | -``` |
155 | | -#### New Toast Message with default options. |
156 | | -``` |
157 | | -this.$refs.toastr.Add("Working on the default options"); |
158 | | -``` |
159 | | -#### New Toast Message with options. |
160 | | -``` |
161 | | -this.$root.$refs.toastr.Add({ |
162 | | - name: "UniqueToastName", // Toast Name now you can remove by name |
163 | | - title: "Easy Toast", // Toast Title |
164 | | - msg: "Hi", // Message |
165 | | - clickClose: false, // Click Close Disable |
166 | | - timeout: 0, // Remember defaultTimeout is 5 sec.. |
167 | | - progressBarValue: 0, // Manually update progress bar value later; null (not 0) is default |
168 | | - position: "toast-top-full-width", // Toast Position. |
169 | | - type: "error", // Toast type, |
170 | | - preventDuplicates: true, //Default is false, |
171 | | - style: { backgroundColor: 'blue',width:'150px' } // bind inline style to toast (check [Vue doc](https://vuejs.org/v2/guide/class-and-style.html#Binding-Inline-Styles) for more examples) |
172 | | -}); |
173 | | -``` |
174 | | -## Doc # Options |
175 | | -``` |
176 | | -{ |
177 | | - name: "Name Of The Toast", |
178 | | - title: "Toast Title", |
179 | | - msg: "Toast Msg", |
180 | | - position: Toast position string can be 'toast-top-right', 'toast-bottom-right', 'toast-bottom-left', 'toast-top-left', 'toast-top-full-width', 'toast-bottom-full-width', 'toast-top-center', 'toast-bottom-center' ; default toast-top-right |
181 | | - type: Toast type can be : info,warning,error,success ; default success |
182 | | - timeout: Toast Timeout for auto close can be integer ; default 5000 |
183 | | - progressbar: Progress Bar option need timeout or progressBarValue. can be boolean; default true |
184 | | - progressBarValue: Initial value of the progress bar in percents (0..100), default null which does mean the progress bar is controlled by timeout; use this.$root.$refs.toastr.setProgress(aToast, newValue) later |
185 | | - style: Inline style option should be an object with key: value structure. default { } (empty object) |
186 | | - closeOnHover: On mouse over stop timeout can be boolean; default true |
187 | | - clickClose: On click toast close can be boolean; default false |
188 | | - onCreated: On created toast event can be function |
189 | | - onClicked: On clicked toast event can be function |
190 | | - onClosed: On closed toast event can be function |
191 | | - onMouseOver: On mouse over toast event can be function |
192 | | - onMouseOut: On mouse over toast event can be function |
193 | | -} |
| 18 | +yarn run build |
194 | 19 | ``` |
195 | 20 |
|
196 | | -### Note: |
197 | | -Pls for more details and example: |
198 | | -https://github.com/s4l1h/vue-toastr/blob/master/demo.js |
| 21 | +### Lints and fixes files |
199 | 22 |
|
| 23 | +``` |
| 24 | +yarn run lint |
| 25 | +``` |
200 | 26 |
|
201 | | -Toastr for Vue.js no jquery dependencies https://github.com/s4l1h/vue-toastr |
| 27 | +### Documentation |
202 | 28 |
|
203 | | -Demo: http://s4l1h.github.io/vue-toastr/ |
| 29 | +``` |
| 30 | +yarn run docs |
| 31 | +``` |
204 | 32 |
|
| 33 | +### Customize configuration |
205 | 34 |
|
206 | | -Ported From Jquery Toastr : http://codeseven.github.io/toastr/ |
| 35 | +See [Configuration Reference](https://cli.vuejs.org/config/). |
0 commit comments