GithubHelp home page GithubHelp logo

netkin-paris / vue-blocks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ghostiam/vue-blocks

0.0 0.0 0.0 1.16 MB

Vue2 dataflow graph editor

Home Page: https://ghostiam.github.io/vue-blocks/index.html

License: MIT License

JavaScript 2.62% HTML 1.29% Vue 96.09%

vue-blocks's Introduction

Vue-Blocks

Demo

Demo

Basic usage

<template>
  <div id="app">
    <VueBlocksContainer
      ref="container"
      :blocksContent="blocks"
      :scene.sync="scene"
      class="container"/>
  </div>
</template>

<script>
  import VueBlocksContainer from '...path.../vue-blocks/src'

  export default {
    name: 'App',
    components: {
      VueBlocksContainer
    },
    data: function () {
      return {
        blocks: [
          {
            name: 'test',
            title: 'Test block',
            family: 'Test',
            description: 'Description text',
            fields: [
              {
                name: 'in1',
                type: 'event',
                attr: 'input'
              },
              {
                name: 'in2',
                type: 'event',
                attr: 'input'
              },
              {
                name: 'out1',
                type: 'event',
                attr: 'output'
              },
              {
                name: 'out2',
                type: 'event',
                attr: 'output'
              }
            ]
          }
        ],
        scene: {
          blocks: [
            {
              id: 1,
              x: 0,
              y: 0,
              name: 'test',
              title: 'Test block',
              values: {
                property: [
                  {
                    name: 'message',
                    type: 'string'
                  }
                ]
              }
            },
            {
              id: 2,
              x: 0,
              y: 50,
              name: 'test',
              title: 'Test block 2',
              values: {
                property: [
                  {
                    name: 'message',
                    type: 'string'
                  }
                ]
              }
            }
          ],
          links: [],
          container: {
            centerX: 0,
            centerY: 0,
            scale: 1
          }
        }
      }
    }
  }
</script>


<style>
  html, body {
    margin: 0;
    padding: 0;
  }

  html {
    width: 100vw;
    height: 100vh;
  }

  body,
  #app,
  .container {
    width: 100%;
    height: 100%;
  }
</style>

Props

blocksContent

Type: Array.<Node>
Required: true
Default: []

Object Node:

{
  name: 'name-node',
  title: 'Title node',
  family: 'family - just for grouping',
  description: 'Description text',
  fields: Array.<NodeField>
}

Object NodeField:

{
  name: 'name',
  type: 'type-name', // not used
  attr: 'attribute' // input/output or custom
  'other': - for custom
}

Custom attributes are available in scene.blocks[index].values.YourAttrName

scene

Type: Object
Required: false
Default:

{
  blocks: [],
  links: [],
  container: {}
}

Object Scene:

{
  blocks: Array.<Block>,
  links: Array.<BlockLinks>,
  container: {
   centerX: number
   centerY: number
   scale: number
  }
}

Object Block:

{
  id: number,
  x: number,
  y: number,
  name: string,
  title: string,
  values: {
    customAttribute: [ // show "NodeField"
      name: NodeField (without name and attr fields)
    ]
  }
}

Object BlockLinks:

{
  id: number, // ID
  originID: number, // Origin block ID
  originSlot: number, // Origin block slot number
  targetID: number, // Target block ID
  targetSlot: number // Target block slot number
}

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run serve

# build for production with minification
npm run build

# build for github pages
npm run build:docs

License

MIT license

vue-blocks's People

Contributors

dependabot[bot] avatar ghostiam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.