react-hive-flow

1.0.65 • Public • Published

react-hive-flow

Hive Flow maker for React

NPM JavaScript Style Guide

Install

yarn add react-hive-flow

Dev

cd react-hive-flow

yarn start

cd react-hive-flow/example

yarn start

Usage

Editor

import React, { Component } from 'react'

import HiveEditor from 'react-hive-flow'
import 'react-hive-flow/dist/index.css'

class Example extends Component {
  render() {
    return <HiveEditor
              direction={"vertical" || "horizontal"}
              nodes={[
                {
                  id: 'unique key',
                  data: {
                    label: 'Label'
                  },
                  position: {
                    x: Int,
                    y: Int
                  }
                }
              ]}
              links={[{
                id: 'unique key 2',
                source: 'node_id',
                target: 'node_id',
                animated: Boolean
              }]}
              modalBody={(NodeType, node, editor) => {
                <div>
                  <NodeType.modal node={node}/>
                  {/* misc jsx */}
                </div>
              }}
              onJoinNode={(cb) => {
                cb(user_id)
              }}
              onNodeChange={(nodes) => {
                //new state of nodes
              }}
              onLinkChange={(links) => {
                //new state of links
              }} />
  }
}

Editor

  let editor = {
      nodes: props.nodes,
      links: props.links,
      exploring: exploring,
      exploreNode: (id) => opens node in modal for editing 
      nodeTypes: {nodeKey: Node},
      updateNode: (id, node_func) => runs node_func(node) from id, expects
modifications to be made in the function and then the new value for node
returned,
      joinNode: (id) => join members of node,
      addNode: (type, position) => nodeKey and position object,
      addLink: (from, to) => add link,
      addChild: (parent_id) => add base node as child of parent
  }

Nodes


import React from 'react';

export const type = 'nodeKey'  

export function modal(props){
  //props.node
  //props.editor
}

export function node(props){
  //props.node
  //props.editor
}

License

MIT © balbatross

Readme

Keywords

none

Package Sidebar

Install

npm i react-hive-flow

Weekly Downloads

1

Version

1.0.65

License

MIT

Unpacked Size

137 kB

Total Files

9

Last publish

Collaborators

  • thetechcompany