1.1.2 • Published 5 years ago

@slothking-online/diagram v1.1.2

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

npm.io

Diagram is the tool for making node based systems. Define your own behaviour of this react based diagram system and create your tool. Visual programming is trending right now so this is a good basis.

Project Page

npm.io

Live demo

Here is Live Demo of diagram used to create node based graphql system

npm.io

Development using sandbox

$ npm run sandbox

Sandbox is a development mode that allows you to review live changes while modifying diagram's code in a hot-reload fashion. After running the command above, you can fool around with component's code in /src/ directory and see immediate results in the browser after navigating to http://localhost:8080.

Add to your project

$ npm install @slothking-online/diagram

Develop & Contribute

$ git clone https://github.com/slothking-online/diagram
$ npm install
$ npm run start

Define spacebar menu actions

import { Graph } from '@slothking-online/diagram';
import * as React from 'react';
let allCategories = [
  {
    name: 'middlewares',
    items: [
      {
        name: 'middleware',
        type: 'middleware',
        inputs: [
          {
            name: ''
          }
        ],
        outputs: [
          {
            name: ''
          }
        ]
      }
    ]
  }
];

export const MyGraphComponent = () => <Graph categories={allCategories} />;

Now if you press spacebar when mouse is on the graph you get this menu, which creates nodes.

Serialization of data

<Graph
  categories={allCategories}
  serialize={(nodes, links) => {
    //here you receive nodes and links after every graph change
  }}
  validate={(node1, node2) => {
    // not necessary but you can add custom validation function between every node
  }}
/>

Controls

  • Create - press and hold Spacebar and choose category -> node and Left Mouse Button click
  • Pan - press and hold Left Mouse Button and move mouse
  • Move - press and hold Left Mouse Button on node
  • Rename - To rename node simply start typing when one node is selected
  • Connect - Click and hold desired node output and move it to other node's output then release mouse button IMPORTANT: Every node is connectable only if it creates valid schema. Experiment to test
  • Node Properties - Click right mouse button on node
  • CMD/CTRL + Left Mouse Button Click - select multiple nodes
  • Delete - Click delete button when node/nodes are selected or right click -> delete

Keyboard shortcuts

  • CMD/CTRL + Mouse Click - Select multiple nodes
  • CMD/CTRL + L - Beautify diagram
  • CMD/CTRL + Z - Undo
  • CMD/CTRL + Y - Redo
  • CMD/CTRL + D - Duplicate Nodes
  • CMD/CTRL + F - Find nodes
  • ALT/OPTION + V - Find duplicate definitions(Validate)
  • ALT/OPTION + LMB on cloned node - navigate to definition
  • RIGHT MOUSE CLICK on node - node actions

Contribute

Feel free to contact us and contribute in graphql editor project. aexol@aexol.com

  1. fork this repo
  2. Create your feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

npm.io

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.21

6 years ago

0.2.20

6 years ago

0.2.19

6 years ago

0.2.18

6 years ago

0.2.17

6 years ago

0.2.16

6 years ago

0.2.15

6 years ago

0.2.14

6 years ago

0.2.13

6 years ago

0.2.12

6 years ago

0.2.11

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.29

6 years ago

0.1.28

6 years ago

0.1.27

6 years ago

0.1.26

6 years ago

0.1.25

6 years ago

0.1.24

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago