From 0b5156cb4e67fb3c4c5da57dca1ebb542f72212a Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Sat, 10 Mar 2018 19:59:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20add=20code=20sample=20to=20examp?= =?UTF-8?q?les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/index.html | 88 ++++++++++++++++++++++++++++++++----------------- docs/index.js | 53 ++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 31 deletions(-) diff --git a/docs/index.html b/docs/index.html index 32cffe2..f2de859 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,8 +5,9 @@ - VuePromised - + VuePromised + + @@ -36,7 +40,9 @@ - + + +
@@ -51,33 +57,38 @@
-
-
-

Single promise

+
+
+

Single promise

-
+
- -
-
- -
#{{ data.num }} - {{ data.title }}
-
-
- Error: {{ error.message }} -
-
+ + +
+
+ +
#{{ data.num }} - {{ data.title }}
+
+
+ Error: {{ error.message }} +
+
+

Multiple promises

+ psst, I need help to improve the API, see #4 to help +
+ @@ -85,19 +96,22 @@

Multiple promises

- -
-
-

{{ items.length }} promises resolved

-
- -
#{{ item.num }} - {{ item.title }}
-
-
-
- Failed {{ errors.length }} promises -
-
+ + +
+
+

{{ items.length }} promises resolved

+
+ +
#{{ item.num }} - {{ item.title }}
+
+
+
+ Failed {{ errors.length }} promises +
+
+
+
+ + diff --git a/docs/index.js b/docs/index.js index 6db06cb..73061b8 100644 --- a/docs/index.js +++ b/docs/index.js @@ -1,4 +1,4 @@ -/* global Vue, VuePromised, axios */ +/* global Vue, VuePromised, axios, PrismComponent */ // eslint-disable-next-line const delay = (t, value) => new Promise(r => setTimeout(r.bind(null, value), t)) @@ -11,6 +11,27 @@ function getRandomImage (max) { .then(res => res.data) } +Vue.component('DemoCode', { + template: '#demo-code', + props: { + code: String, + }, + + data () { + return { + showCode: false, + } + }, + + computed: { + seeLabel () { + return this.showCode ? 'See demo' : 'See code' + }, + }, + + components: { Prism: PrismComponent }, +}) + // eslint-disable-next-line new Vue({ el: '#app', @@ -18,6 +39,36 @@ new Vue({ data: () => ({ promise: null, promises: [], + + samples: { + single: `\ + +
+
+ +
#{{ data.num }} - {{ data.title }}
+
+
+ Error: {{ error.message }} +
+
+`, + multiple: `\ + +
+
+

{{ items.length }} promises resolved

+
+ +
#{{ item.num }} - {{ item.title }}
+
+
+
+ Failed {{ errors.length }} promises +
+
+` + }, }), created () {