Skip to content

Commit

Permalink
added README
Browse files Browse the repository at this point in the history
  • Loading branch information
nglgzz committed May 20, 2017
1 parent 68d49f9 commit bc0dd7e
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# React Mindmap
A React component for MindNode maps.

## Installation

npm install react-mindmap --save

## Usage

```js
import { Component } from 'react';
import { render } from 'react-dom';
import MindMap from 'react-mindmap';

class Example extends Component {
render() {
return (
<MindMap url="/maps/devops.json" />
);
}
}

render(<Example />, document.getElementById('target'));
```

![img](https://raw.githubusercontent.com/learn-anything/img/master/react-mindmap-example.png)

## Props
| Prop | Type | Default | Description |
|-------------------------------|:------:|:-------:|--------------------------------------------------------------------------------------------------|
| [`url`](#url) | String | | URL to fetch the map's JSON. If specified the other two props won't be taken into consideration. |
| [`nodes`](#nodes) | Array | [ ] | Array of objects used to render nodes. Is used only when `url` is not specified. |
| [`connections`](#connections) | Array | [ ] | Array of objects used to render connections. Is used only when `url` is not specified. |

### url
URL indicating the location of the map's JSON. The URL has to return a valid JSON
with the following structure.

```js
{
"nodes": [
{ /* node 1 */ },
{ /* node 2 */ },
...
],
"connections": [
{ /* connection 1 */ },
{ /* connection 2 */ },
...
]
}
```

### nodes
Array of objects with the following structure.

```json
{
"id": "79ED2113",
"title": {
"maxWidth": 300.0,
"text": "<p><a href=\"http://www.wikiwand.com/en/DevOps\">DevOps 🌐</a></p>"
},
"location": {
"x": 93,
"y": -527
}
}
```

### connections
Array of objects with the following structure. **wayPointOffset** is the offset
from the starting point, for the control point of a quadratic bezier curve. If the
connections are straight, just let the coordinated be 0.

```json
{
"startNodeID": "79ED2113",
"endNodeID": "A6760924",
"wayPointOffset": {
"x": -188.84,
"y": 71.79
}
}
```

## Styling
All inline styling in `node.title.text` is removed automatically, and all emojis
are converted to image tags with emojis from github.

The rendered map uses four css classes for styling:

- **.mindmap-svg**: main `svg` element containing the map;
- **.mindmap-node**: `foreignObject` element containing the HTML code from `node.title.text`;
- **.mindmap-connection**: `path` element for each connection;
- **.mindmap-emoji**: `img` tag for emoji
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"build": "webpack",
"test": "webpack; http-server -p 3000"
},
"dependencies": {
"http-server": "^0.9.0",
"browserDependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4"
},
Expand All @@ -35,6 +34,7 @@
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.10.3",
"http-server": "^0.9.0",
"node-sass": "^4.5.0",
"postcss-loader": "^2.0.5",
"sass-lint": "^1.10.2",
Expand Down

0 comments on commit bc0dd7e

Please sign in to comment.