You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+58-5Lines changed: 58 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,9 @@ Simple customizeable page loader component with self state manager module for Vu
7
7
8
8
## 🎉 version 1 released 🎈
9
9
10
-
## How to use
10
+
---
11
+
12
+
## First steps
11
13
### 1. Instalation
12
14
Install package in your project with this command
13
15
@@ -16,19 +18,33 @@ npm i -S sadrix-vue-page-loader
16
18
```
17
19
18
20
### 2. Import
19
-
Import package inside your Vuejs application config file and let you global `Vue` instance use it as a plugin:
21
+
Import package inside your Vuejs application config file and let you global **`Vue`** instance use it as a plugin.
22
+
23
+
>The only **important notice** is this plugin use **`Vuex`** package as state manager and you need to import this package first and config it, then pass you store param as an option property with name of **`store`** (with small `s`) and plugin will automaticaly add needed mutaction, states and actions under namespace of **`pageLoader`**.
20
24
21
25
```javascript
22
26
importSadrixPageLoaderfrom'sadrix-page-loader';
23
27
importVuefrom'vue';
24
-
25
-
Vue.use(SadrixPageLoader);
28
+
importstorefrom'./store/store';
29
+
importrouterfrom'./core/router';
30
+
importPagefrom'./layouts/page';
31
+
32
+
// Let Vue use our plugin
33
+
Vue.use(SadrixPageLoader, { store });
34
+
35
+
// Create app
36
+
newVue({
37
+
el:'#app',
38
+
router,
39
+
store,
40
+
render:h=>h(Page)
41
+
});
26
42
```
27
43
28
44
### 3. Component
29
45
Your done! Now easily can use `<page-loader/>` component any where inside your application.
30
46
31
-
**example: in your `.vue` template file**
47
+
***example: in your `.vue` template file**
32
48
33
49
```html
34
50
<div>
@@ -68,6 +84,43 @@ Its easy! just pass `:rtl="true"`.
68
84
<page-loader:rtl="true"/>
69
85
</div>
70
86
```
87
+
---
88
+
## How to use
89
+
For faster and easier usage and control on this loader, We add some custom property to `Vue` main module.
90
+
You just need to call `showPageLoader(timeout)` when want loader show and how much it take (timeout) to fill window width in `milisecounds` (optionl). default timeout is `10 secounds` or `10000ms`.
91
+
And when you want to hide loader easily type `hidePageLoader()`.
92
+
93
+
***example: show/hide page loader for and api request**
94
+
```html
95
+
<script>
96
+
importaxiosfrom'axios';
97
+
98
+
exportdefault {
99
+
methods: {
100
+
callApi() {
101
+
// for example before making request we want
102
+
// to show the page loader and max in 6 secounds timeout
103
+
this.$showPageLoader();
104
+
105
+
// make request
106
+
axios.get('https://someurl.com')
107
+
// on success
108
+
.then(data=> {
109
+
// here we hide page loader
110
+
this.$hidePageLoader();
111
+
})
112
+
// on error
113
+
.catch(error=> {
114
+
// here we hide page loader
115
+
this.$hidePageLoader();
116
+
});
117
+
}
118
+
}
119
+
}
120
+
</script>
121
+
```
122
+
123
+
---
71
124
72
125
73
126
build your amasing app with a beautiful page loader! 😉
0 commit comments