Skip to content

Commit 579b200

Browse files
author
elevatebart
committed
fix: restore demo
1 parent e69245e commit 579b200

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

demo/App.vue

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,84 @@
11
<template>
22
<main style="text-align: center">
3-
<VueLive :editorProps="{ lineNumbers: true }" :code="codeTemplate" :layout="CustomLayout"
4-
:components="registeredComponents" @error="(e: any) => log('Error on first example', e)" />
3+
<h1>Vue Live renders vue code in the browser</h1>
4+
<p class="description">
5+
<em>vue-live</em> is a VueJs component. It renders the code passed in prop
6+
using the VueJs compiler - yes exactly like the vuejs compiler. But wait!
7+
it has a <b>super-power</b>! It keeps the rendered code reactive in the
8+
browser.
9+
</p>
10+
<p class="description">
11+
If you edit the code in the editor on the left, the preview on the right
12+
will update automatically.
13+
</p>
14+
15+
<div class="livebox">
16+
<div class="hint">You can edit this <span>-></span></div>
17+
<VueLive :editorProps="{ lineNumbers: true }" :code="codeTemplate" :layout="CustomLayout"
18+
:components="registeredComponents" @error="(e: any) => log('Error on first example', e)" />
19+
</div>
20+
21+
<span v-if="!openExamples">+</span><span v-else>-</span>&nbsp;
22+
<a href="#" @click="openExamples = !openExamples">More examples</a>
23+
<div v-if="openExamples">
24+
<h2>Vue SFC</h2>
25+
<p>
26+
If this format is not fitting for you, vue-live renders VueJs single
27+
file components as well
28+
</p>
29+
<VueLive :code="codeSfc" :layout="CustomLayout" />
30+
<h2>SFC with setup</h2>
31+
<VueLive :code="codeSfcSetup" :layout="CustomLayout" />
32+
<h2>Pure JavaScript code</h2>
33+
<p>Or if you prefer to, use the <b>new Vue()</b> format</p>
34+
<VueLive :code="codeJs" :layout="CustomLayout" />
35+
<h2>Extra dependencies</h2>
36+
<p>
37+
Use the <b>requires</b> prop to make libraries and packages available in
38+
the browser
39+
</p>
40+
<VueLive :code="codeChicago" :layout="CustomLayout" :requires="chicagoRequires" />
41+
<h2>Custom delay</h2>
42+
<p>
43+
When updates should not happen too often, for instance when a component
44+
need a lot of computing power to render, one can change the standard
45+
throttle timing.
46+
</p>
47+
<VueLive :code="`<input type='button' value='update me' />`" :layout="CustomLayout" :delay="2000" />
48+
49+
<h2>Default Layout</h2>
50+
<div style="width: 950px; max-width: 95vw; margin: 20px auto">
51+
<VueLive :code="`<input type='button' value='I am Groot' />`" />
52+
</div>
53+
<h2>Custom Layout</h2>
54+
<div>
55+
<p>Attributes available for custom layout:</p>
56+
<p>
57+
<code>code: String</code>, <code>language: String</code>,
58+
<code>components: Object</code>, <code>requires: Object</code>, ...
59+
all props passed in the
60+
<code>layoutProps</code>
61+
</p>
62+
<VueLive :code="`<input type='button' value='I am Groot' />`" :layout="CustomLayout" />
63+
</div>
64+
65+
<h2>JSX</h2>
66+
<VueLive :code="realjsx" :layout="CustomLayout" :jsx="true" />
67+
68+
<h2>Double Root</h2>
69+
<VueLive :code="doubleRoot" :layout="CustomLayout" />
70+
71+
<h2>Separate components for Editor and Preview</h2>
72+
<div class="separate">
73+
<div class="preview-separate">
74+
<VueLivePreview :code="separateCode" @error="(e: any) => (error = e)" @success="error = undefined" />
75+
</div>
76+
<hr style="width: 950px" />
77+
<p>Edit the code here</p>
78+
<VueLiveEditor :code="separateCode" @change="updateCode" :error="error" />
79+
<div class="button-bar"><button>Save</button></div>
80+
</div>
81+
</div>
582

683
<github-corners href="https://github.com/vue-styleguidist/vue-live" gitColor="#FFFFFF" />
784
</main>

src/Preview.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ export default defineComponent({
8686
data() {
8787
return {
8888
scope: this.generateScope(),
89-
previewedComponent: {},
89+
previewedComponent: markRaw({
90+
render: () => h("div"),
91+
}),
9092
iteration: 0,
9193
error: false,
9294
removeScopedStyle: () => { },

0 commit comments

Comments
 (0)