-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
110 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,9 @@ | |
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>VuePromised</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/siimple.min.css"> | ||
<title>VuePromised</title> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/siimple.min.css"> | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/themes/prism.css"> | ||
|
||
<style> | ||
figure { | ||
|
@@ -29,14 +30,19 @@ | |
display: flex; | ||
align-items: center; | ||
} | ||
[v-cloak] { | ||
display: none; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | ||
<script src="https://unpkg.com/vue"></script> | ||
<script src="https://unpkg.com/vue-promised"></script> | ||
<script src="https://unpkg.com/vue-promised/dist/vue-promised.min.js"></script> | ||
<script src="https://unpkg.com/[email protected]/prism.js"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/vue-prism-component.min.js"></script> | ||
|
||
<div id="app"> | ||
|
||
|
@@ -51,53 +57,61 @@ | |
</div> | ||
</div> | ||
|
||
<div class="siimple-content--medium"> | ||
<div class="siimple-box siimple-box--white"> | ||
<h2 class="siimple-h2 text-center">Single promise</h2> | ||
<div class="siimple-content--medium" v-cloak> | ||
<div class="siimple-box siimple-box--white text-center"> | ||
<h2 class="siimple-h2">Single promise</h2> | ||
|
||
<div class="siimple-content--fluid text-center"> | ||
<div class="siimple-content--fluid"> | ||
<button class="siimple-btn siimple-btn--blue" @click="trySuccess">Fetch a new comic</button> | ||
<button class="siimple-btn siimple-btn--red" @click="tryError">Purposely fail</button> | ||
</div> | ||
|
||
<div class="space"></div> | ||
|
||
<Promised :promise="promise"> | ||
<div class="siimple-spinner siimple-spinner--teal"></div> | ||
<figure class="text-center" slot-scope="data"> | ||
<img :alt="data.transcript" :src="data.img"/> | ||
<figcaption>#{{ data.num }} - {{ data.title }}</figcaption> | ||
</figure> | ||
<div slot="catch" slot-scope="error" class="siimple-alert siimple-alert--orange"> | ||
Error: {{ error.message }} | ||
</div> | ||
</Promised> | ||
<demo-code :code="samples.single"> | ||
<Promised :promise="promise"> | ||
<div class="siimple-spinner siimple-spinner--teal"></div> | ||
<figure class="text-center" slot-scope="data"> | ||
<img :alt="data.transcript" :src="data.img"/> | ||
<figcaption>#{{ data.num }} - {{ data.title }}</figcaption> | ||
</figure> | ||
<div slot="catch" slot-scope="error" class="siimple-alert siimple-alert--orange"> | ||
Error: {{ error.message }} | ||
</div> | ||
</Promised> | ||
</demo-code> | ||
|
||
</div> | ||
|
||
<div class="siimple-box siimple-box--white text-center"> | ||
<h2 class="siimple-h2">Multiple promises</h2> | ||
|
||
<a class="siimple-link siimple-small" target="_blank" href="https://github.com/posva/vue-promised/issues/4">psst, I need help to improve the API, see #4 to help</a> | ||
<br/> | ||
|
||
<button class="siimple-btn siimple-btn--blue" @click="tryMultipleSuccess">Add another image</button> | ||
<button class="siimple-btn siimple-btn--red" @click="tryMultipleError">Fail one promise</button> | ||
<button class="siimple-btn siimple-btn--navy" @click="resetMultiple">Reset promises</button> | ||
<!-- <button class="siimple-btn siimple-btn-purple" @click="resetErrors">Reset errors</button> --> | ||
|
||
<div class="space"></div> | ||
|
||
<Promised :promises="promises" ref="multiplePromised"> | ||
<div class="siimple-spinner siimple-spinner--teal"></div> | ||
<div slot-scope="items"> | ||
<h3>{{ items.length }} promises resolved</h3> | ||
<figure v-for="item in items"> | ||
<img :alt="item.transcript" :src="item.img"/> | ||
<figcaption>#{{ item.num }} - {{ item.title }}</figcaption> | ||
</figure> | ||
</div> | ||
<div slot="catch" slot-scope="errors" class="siimple-tip siimple-tip--exclamation siimple-tip--red"> | ||
Failed {{ errors.length }} promises | ||
</div> | ||
</Promised> | ||
<demo-code :code="samples.multiple"> | ||
<Promised :promises="promises" ref="multiplePromised"> | ||
<div class="siimple-spinner siimple-spinner--teal"></div> | ||
<div slot-scope="items"> | ||
<h3>{{ items.length }} promises resolved</h3> | ||
<figure v-for="item in items" :key="item.num"> | ||
<img :alt="item.transcript" :src="item.img"/> | ||
<figcaption>#{{ item.num }} - {{ item.title }}</figcaption> | ||
</figure> | ||
</div> | ||
<div slot="catch" slot-scope="errors" class="siimple-tip siimple-tip--exclamation siimple-tip--red"> | ||
Failed {{ errors.length }} promises | ||
</div> | ||
</Promised> | ||
</demo-code> | ||
|
||
</div> | ||
|
||
<div class="siimple-footer" align="center"> | ||
|
@@ -107,6 +121,20 @@ <h3>{{ items.length }} promises resolved</h3> | |
</div> | ||
</div> | ||
|
||
<script type="text/x-template" id="demo-code"> | ||
<div> | ||
<h5> | ||
<a class="siimple-link" href="#" role="button" @click.prevent="showCode = !showCode">{{ seeLabel }}</a> | ||
</h5> | ||
<div class="demo__demo" v-if="!showCode"> | ||
<slot/> | ||
</div> | ||
<div class="demo__code" v-else> | ||
<Prism language="html" :code="code"/> | ||
</div> | ||
</div> | ||
</script> | ||
|
||
<script src="index.js"></script> | ||
|
||
</body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters