All Projects → vue-styleguidist → Vue Live

vue-styleguidist / Vue Live

A component to demo components, inspired by react-live

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Live

Preview Email
Automatically opens your browser to preview Node.js email messages sent with Nodemailer. Made for Lad!
Stars: ✭ 112 (-8.94%)
Mutual labels:  demo, preview
vuepress-plugin-example-preview
Easily display the preview of a code snippet
Stars: ✭ 15 (-87.8%)
Mutual labels:  live, preview
Helloworld Msa
Main repository with documentation and support files
Stars: ✭ 218 (+77.24%)
Mutual labels:  documentation, demo
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 589 (+378.86%)
Mutual labels:  demo, live
Redemo
react demo component
Stars: ✭ 60 (-51.22%)
Mutual labels:  documentation, demo
Dt54
Laravel 5.4 DataTables Demo Application (WIP)
Stars: ✭ 27 (-78.05%)
Mutual labels:  documentation, demo
Ocbarrage
iOS 弹幕库 OCBarrage, 同时渲染5000条弹幕也不卡, 轻量, 可拓展, 高度自定义动画, 超高性能, 简单易上手; A barrage render-engine with high performance for iOS. At the same time, rendering 5000 barrages is also very smooth, lightweight, scalable, highly custom animation, ultra high performance, simple and easy to use!
Stars: ✭ 294 (+139.02%)
Mutual labels:  demo, live
Kodeweave
HTML/CSS/JS and Markdown Playground For Web Designers and Developers
Stars: ✭ 87 (-29.27%)
Mutual labels:  live, preview
Elm Doc Preview
Elm offline documentation previewer
Stars: ✭ 113 (-8.13%)
Mutual labels:  documentation, preview
Docs
API Platform documentation
Stars: ✭ 119 (-3.25%)
Mutual labels:  documentation
Devdocs
Shopware 5 Developers Website
Stars: ✭ 120 (-2.44%)
Mutual labels:  documentation
Plantuml Previewer.vim
Vim / Neovim plugin for preview PlantUML
Stars: ✭ 119 (-3.25%)
Mutual labels:  preview
Lodash.com
The Lodash website.
Stars: ✭ 119 (-3.25%)
Mutual labels:  documentation
Lurker
📖 The ultimate tool for documenting and testing APIs in Rails
Stars: ✭ 120 (-2.44%)
Mutual labels:  documentation
Wiki
Awesome way to learn together! 🤣
Stars: ✭ 119 (-3.25%)
Mutual labels:  documentation
Rotatedrevealers
Animated rotated overlays, or "reveal" elements for interesting page transition effects.
Stars: ✭ 121 (-1.63%)
Mutual labels:  demo
Kotlinlang.ru
Russian translation of Kotlin reference
Stars: ✭ 118 (-4.07%)
Mutual labels:  documentation
Wikiman
Wikiman is an offline search engine for manual pages, Arch Wiki, Gentoo Wiki and other documentation.
Stars: ✭ 117 (-4.88%)
Mutual labels:  documentation
Gdscript Docs Maker
Create documentation and class references from your Godot GDScript code
Stars: ✭ 121 (-1.63%)
Mutual labels:  documentation
Demosify
Create a playground to show the demos of your projects.
Stars: ✭ 121 (-1.63%)
Mutual labels:  demo

vue-live

A lightweight playground for live editing VueJs code in the browser

Build Status NPM Version NPM Downloads semantic-release


Usage

The simplest way to render components is as a VueJs template:

<template>
    <VueLive :code="`<date-picker />`" :components="{ DatePicker }" @error="(e) => handleError(e)">
</template>

<script>
import { VueLive } from "vue-live";
import DatePicker from "vuejs-datepicker"

export default {
    components: { VueLive },
    data(){
        return {
            // make DatePicker available in template
            DatePicker
        }
    }
}
</script>

Check out the demo for alternative syntaxes to write your showcases.

Enabling template compilation

To compile templates in the browser, you need the compiler to be in your JS bundle.

If you do not, you might see errors about using the runtime version of Vue.

To bundle this, there is a simple solution: Add an alias in webpack.config.js.

module.export = {
  resolve: {
    alias: {
      // this enables loading the "full" version of vue
      // instead of only loading the vue runtime
      vue$: "vue/dist/vue.esm.js",
    },
  },
};

in nuxt.config.js

export default {
  build: {
    extend(config, { isDev, isClient }) {
      // ..
      config.resolve.alias.vue$ = "vue/dist/vue.esm.js";
    },
  },
};

and finally in gridsome.config.js

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        vue$: "vue/dist/vue.esm.js",
      },
    },
  },
};

Events

@error

When the template compilation or the script evaluation fail, errors are returned in this box. Hooking on these errors will not prevent them from displaying on the preview panel but will allow you to provide more info to your users about how to fix what they see.

<template>
  <VueLive
    code="<h1>make this example {{ fail }}</h1>"
    @error="(e) => log('Error on first example', e)"
  />
</template>

Props

code

Type String

Specifies the initial code to be evaluated

<template>
  <VueLive code="<button>test</button>" />
</template>

layout

Type vue component

Layout to be used for displaying the

Example

<template>
  <VueLive :layout="layout" />
</template>
<script>
import layout from "./Layout.vue";

export default {
  data() {
    return { layout };
  },
};
</script>

layout.vue

<template>
  <div class="my-vuelive">
    <div class="my-vuelive-editor">
      <slot name="editor"></slot>
    </div>
    <div class="my-vuelive-preview">
      <slot name="preview"></slot>
    </div>
  </div>
</template>
<style>
.my-vuelive {
  border: 1px solid #ccc;
  border-radius: 10px;
}

.my-vuelive-editor {
  margin: 8px;
}

.my-vuelive-preview {
  margin: 8px;
}
</style>

components

Type Object:

  • key: registration name
  • value: VueJs component object

Register some components to be used in the vue-live instance.

Example

<template>
  <VueLive :components="registeredComponents" code="<DatePicker />" />
</template>
<script>
import DatePicker from "./DatePicker.vue";

export default {
  data() {
    return {
      registeredComponents: {
        DatePicker,
      },
    };
  },
};
</script>

requires

Type Object:

  • key: query in the require/import statement
  • value: value returned by an es5 reauire statement

To allow require statements on a code evaluated in the browser, we have to pre-package all dependencies. This allows bundlers to know in advance what external dependencies will be allowed in the code.

Example

<template>
  <VueLive :requires="preRequiredObjects" :code="code" />
</template>
<script>
import DatePicker from "./DatePicker.vue";

export default {
  data() {
    return {
      // lodash can be pre-packaged by the bundler
      // so it can be required at runtime
      preRequiredObjects: {
        lodash: require("lodash"),
      },
      code: `
import _ from 'lodash'

const val = _.each({1,2,3}, (i, v) => {
  return \`\${i} value \${v}\`
})

<li v-for="v in val">
  v : {{v}}
</li>
      `,
    };
  },
};
</script>

jsx

Type Boolean

JSX does not always play nice with vue templates. If you want to expose vue templates, leave this option off. If you plan on using render functions with JSX, you will have to turn this option on.

Example

<template>
  <vue-live :code="code" jsx />
</template>
<script>
export default {
  data() {
    return {
      code: `
const args = {
  type: "button",
  value: "update me"
};

export default {
  render() {
    return <input {...args} />;
  }
};      
      `,
    };
  },
};
</script>

delay

Type Number

Time between a change in the code and its effect in the preview.

Note If a change happens before the prview has changed, the timer is reset.

editorProps

Type Object

Props passed directly to vue-prism-editor as a spread

dataScope

Type Object

Data object that wil be merged with the output data of the preview.

Example

```vue
<template>
  <VueLive
    :components="registeredComponents"
    :data-scope="dataScope"
    code="<DatePicker :value='today' />{{ today }}"
  />
</template>
<script>
import DatePicker from "./DatePicker.vue";

export default {
  data() {
    return {
      registeredComponents: {
        DatePicker,
      },
      // Without this variable declaration,
      // today will not have a value when entering the
      // particularly useful when examples or only a template
      dataScope: {
        today: new Date(),
      },
    };
  },
};
</script>

checkVariableAvailability

Type Boolean

Makes sure that every variable in the template actually exists when the user starts editing.

Throws an error in te preview field when the variable dont exist.

squiggles

Type Boolean default: true

Shows a red indicator when the parser errors with the code given.

How to contribute

npm ci

Compiles and hot-reloads for development

npm run start

Compiles and minifies library for production using rollup

npm run build

Run unit and e2e tests

npm run test:unit
npm run test:e2e

Lints and fixes files

npm run lint
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].