Skip to content

Commit 67a63a9

Browse files
committed
update readme to use outsourced spinneras
1 parent c5af5e1 commit 67a63a9

File tree

5 files changed

+83
-26
lines changed

5 files changed

+83
-26
lines changed

README.md

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -405,22 +405,32 @@ In this example above, the **tab gets data from back-end**, and the **table load
405405

406406
```html
407407
<template lang='pug'>
408-
div
409-
v-wait(for='fetching tabs')
410-
template(slot='waiting')
411-
b-tabs
412-
template(slot='tabs')
413-
b-nav-item(active disabled)
414-
v-icon(name='circle-o-notch', spin)
415-
b-tabs
416-
template(slot='tabs')
417-
b-nav-item(v-for='tab in tabs') {{ tab.name }}
418-
419-
v-wait(for='fetching data')
420-
table-gradient-spinner(slot='waiting')
421-
table
422-
tr(v-for='row in data')
423-
// ...
408+
<div>
409+
<v-wait for="fetching tabs">
410+
<template slot="waiting">
411+
<b-tabs>
412+
<template slot="tabs">
413+
<b-nav-item active="active" disabled>
414+
<v-icon name="circle-o-notch" spin="spin" />
415+
</b-nav-item>
416+
</template>
417+
</b-tabs>
418+
</template>
419+
<b-tabs>
420+
<template slot="tabs">
421+
<b-nav-item v-for="tab in tabs">{{ tab.name }}</b-nav-item>
422+
</template>
423+
</b-tabs>
424+
</v-wait>
425+
<v-wait for="fetching data">
426+
<table-gradient-spinner slot="waiting" />
427+
<table>
428+
<tr v-for="row in data">
429+
<!-- ...-->
430+
</tr>
431+
</table>
432+
</v-wait>
433+
</div>
424434
</template>
425435
```
426436

@@ -435,11 +445,11 @@ You may want to design your own reusable loader for your project. You better cre
435445
loading: Loading...
436446
</i18n>
437447

438-
<template lang="pug">
439-
div.loading-spinner
440-
//- Uses vue-awesome spinner
441-
v-icon(name='refresh', spin)
442-
span {{ $t('loading') }}
448+
<template>
449+
<div class="loading-spinner">
450+
<v-icon name="refresh" spin="spin" />
451+
<span>{{ $t('loading') }}</span>
452+
</div>
443453
</template>
444454

445455
<style scoped lang="scss">
@@ -459,13 +469,41 @@ Now you can use your spinner everywhere using `slot='waiting'` attribute:
459469

460470
```html
461471
<template lang="pug">
462-
v-wait(for='fetching data')
463-
my-waiter(slot='waiting')
464-
div
465-
p My main content after fetching data...
472+
<v-wait for="fetching data">
473+
<my-waiter slot="waiting" />
474+
<div>
475+
<p>My main content after fetching data...</p>
476+
</div>
477+
</v-wait>
466478
</template>
467479
```
468480

481+
## 📦 Using with external spinner libraries
482+
483+
You can use `vue-wait` with another spinner libraries like [epic-spinners](/https://github.com/epicmaxco/epic-spinners) or other libraries. You just need to add `slot="waiting"` to the component and Vue handles rest of the work.
484+
485+
First register the component,
486+
```js
487+
import { OrbitSpinner } from 'epic-spinners';
488+
Vue.component('orbit-spinner', OrbitSpinner);
489+
```
490+
491+
Then use it in your as a `v-wait`'s `waiting` slot.
492+
```html
493+
<v-wait for='something to load'>
494+
<orbit-spinner
495+
slot='waiting'
496+
:animation-duration="1500"
497+
:size="64"
498+
:color="'#ff1d5e'"
499+
/>
500+
</v-wait>
501+
```
502+
503+
... and done!
504+
505+
For other libraries you can use, please see [Loaders section of **vuejs/awesome-vue**](https://github.com/vuejs/awesome-vue#loader).
506+
469507
## 🚌 Run example
470508

471509
Use `npm run dev-vuex`, `npm run dev-vue` or `npm run dev-wrap` commands.

examples/vue-example/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import Vue from 'vue';
22
import VueWait from '../../src/vue-wait';
3+
import { OrbitSpinner } from 'epic-spinners';
34

45
import main from './main.vue';
56

67
Vue.use(VueWait);
78

9+
Vue.component('orbit-spinner', OrbitSpinner);
10+
811
new Vue({
912
el: '#app',
1013
wait: new VueWait({ registerComponents: false }),

examples/vue-example/main.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
This will be shown after load.
99
</v-wait>
1010
</div>
11+
<v-wait for='writing code' message='You can also use outsourced spinners like epic-spinners'>
12+
<orbit-spinner
13+
style="display: block; margin: 0 auto;"
14+
slot='waiting'
15+
:animation-duration="1500"
16+
:size="64"
17+
:color="'#ff1d5e'"
18+
/>
19+
</v-wait>
1120
<button @click='writeCode()' v-wait:disabled='"writing code"'>
1221
<v-wait for='writing code' message='Writing Code...'>
1322
<template slot='waiting'>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"babel-loader": "^8.0.0-beta.3",
5252
"cross-env": "^5.1.3",
5353
"css-loader": "^0.28.11",
54+
"epic-spinners": "^1.0.3",
5455
"eslint": "^4.2.0",
5556
"husky": "^0.14.3",
5657
"lint-staged": "^7.1.3",

yarn.lock

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,12 @@ entities@~1.1.1:
23822382
version "1.1.1"
23832383
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
23842384

2385+
epic-spinners@^1.0.3:
2386+
version "1.0.3"
2387+
resolved "https://registry.yarnpkg.com/epic-spinners/-/epic-spinners-1.0.3.tgz#f8ec3c59a4132de74acfe4edc0a8e1ce8b0c8312"
2388+
dependencies:
2389+
vue "2.5.16"
2390+
23852391
errno@^0.1.3, errno@~0.1.7:
23862392
version "0.1.7"
23872393
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618"
@@ -6892,7 +6898,7 @@ vue-template-es2015-compiler@^1.6.0:
68926898
version "1.6.0"
68936899
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
68946900

6895-
vue@^2.5.13:
6901+
vue@2.5.16, vue@^2.5.13:
68966902
version "2.5.16"
68976903
resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.16.tgz#07edb75e8412aaeed871ebafa99f4672584a0085"
68986904

0 commit comments

Comments
 (0)