Flume

Extract logic from your apps with a user-friendly node editor powered by Re...

README

undefined
NPM JavaScript Style Guide Minzip Size

Flume


Guides & Examples



Install


  1. ``` sh
  2. npm install --save flume
  3. ```

Usage


Defining your nodes


Import FlumeConfig and use it to define the nodes and ports that will make up your node editor.

  1. ``` js
  2. import { FlumeConfig, Controls, Colors } from "flume";

  3. const flumeConfig = new FlumeConfig()

  4. flumeConfig
  5.   .addPortType({
  6.     type: "number",
  7.     name: "number",
  8.     label: "Number",
  9.     color: Colors.red,
  10.     controls: [
  11.       Controls.number({
  12.         name: "num",
  13.         label: "Number"
  14.       })
  15.     ]
  16.   })
  17.   .addNodeType({
  18.     type: "number",
  19.     label: "Number",
  20.     initialWidth: 150,
  21.     inputs: ports => [
  22.       ports.number()
  23.     ],
  24.     outputs: ports => [
  25.       ports.number()
  26.     ]
  27.   })
  28.   .addNodeType({
  29.     type: "addNumbers",
  30.     label: "Add Numbers",
  31.     initialWidth: 150,
  32.     inputs: ports => [
  33.       ports.number({name: "num1"}),
  34.       ports.number({name: "num2"})
  35.     ],
  36.     outputs: ports => [
  37.       ports.number({name: "result"})
  38.     ]
  39.   })
  40. ```

Rendering the node editor


To render the node editor, import NodeEditor and pass it your nodeTypes and portTypes from the configuration you created.

  1. ``` js
  2. import React from 'react'
  3. import { NodeEditor } from 'flume'
  4. import config from './config'

  5. const App = () => {

  6.   return (
  7.     <div style={{width: 600, height: 800}}> // Give the wrapper a width & height
  8.       <NodeEditor
  9.         nodeTypes={config.nodeTypes}
  10.         portTypes={config.portTypes}
  11.       />
  12.     </div>
  13.   )
  14. }
  15. ```

For more complete documentation visit: flume.dev

License