Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit 4826119

Browse files
authored
Add GitHub page and update README (#26)
* Add Overview page for docs (#6) * Remove Gulp, add babel-cli (#25) * Add content for docs (#6) * Update README (#6) * Add docs for GitHub page (#6) * Update CHANGELOG * v1.1.0 * Remove BitHound service
1 parent 2314120 commit 4826119

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5428
-149
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ npm-debug.log*
77

88
# compiled files
99
lib
10+
_book
1011

1112
# coverage directory used by tools like istanbul
1213
coverage

CHANGELOG.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
# Change Log
22

3-
## [v1.0.0](https://github.com/hckhanh/react-tree-es6/tree/v1.0.0)
3+
## [v1.1.0](https://github.com/hckhanh/react-tree-es6/tree/HEAD)
44

5-
[Full Changelog](https://github.com/hckhanh/react-tree-es6/compare/v0.1.2...v1.0.0)
5+
[Full Changelog](https://github.com/hckhanh/react-tree-es6/compare/v1.0.1...v1.1.0)
6+
7+
**Implemented enhancements:**
8+
9+
- Remove Gulp dependency [\#25](https://github.com/hckhanh/react-tree-es6/issues/25)
10+
- Create GitHub Page [\#6](https://github.com/hckhanh/react-tree-es6/issues/6)
11+
12+
## [v1.0.1](https://github.com/hckhanh/react-tree-es6/tree/v1.0.1) (2016-08-18)
13+
[Full Changelog](https://github.com/hckhanh/react-tree-es6/compare/v1.0.0...v1.0.1)
14+
15+
**Fixed bugs:**
16+
17+
- Update missing code in README doc [\#24](https://github.com/hckhanh/react-tree-es6/pull/24) ([hckhanh](https://github.com/hckhanh))
18+
19+
## [v1.0.0](https://github.com/hckhanh/react-tree-es6/tree/v1.0.0) (2016-08-16)
20+
[Full Changelog](https://github.com/hckhanh/react-tree-es6/compare/v1.0.0-0...v1.0.0)
621

722
**Implemented enhancements:**
823

924
- Add core property [\#20](https://github.com/hckhanh/react-tree-es6/issues/20)
1025
- Add Codecov service [\#15](https://github.com/hckhanh/react-tree-es6/issues/15)
26+
- Update content in README [\#23](https://github.com/hckhanh/react-tree-es6/pull/23) ([hckhanh](https://github.com/hckhanh))
27+
- Add core prop to ReactTree [\#22](https://github.com/hckhanh/react-tree-es6/pull/22) ([hckhanh](https://github.com/hckhanh))
1128
- Add test coverage \(\#15\) [\#19](https://github.com/hckhanh/react-tree-es6/pull/19) ([hckhanh](https://github.com/hckhanh))
1229

30+
## [v1.0.0-0](https://github.com/hckhanh/react-tree-es6/tree/v1.0.0-0) (2016-08-15)
31+
[Full Changelog](https://github.com/hckhanh/react-tree-es6/compare/v0.1.2...v1.0.0-0)
32+
1333
## [v0.1.2](https://github.com/hckhanh/react-tree-es6/tree/v0.1.2) (2016-08-14)
1434
[Full Changelog](https://github.com/hckhanh/react-tree-es6/compare/v0.1.1...v0.1.2)
1535

README.md

Lines changed: 3 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
[![dependencies Status](https://david-dm.org/hckhanh/react-tree-es6/status.svg)](https://david-dm.org/hckhanh/react-tree-es6)
66
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/288/badge)](https://bestpractices.coreinfrastructure.org/projects/288)
77

8-
The wrapper of jsTree (jstree.com) for React
8+
If you want to find a **tree view** component for [React](https://facebook.github.io/react/), this module is what you need.
99

1010
## Getting Started
1111

12-
If you want to find a **tree view** component for React, this module is what you need.
13-
**It supports ES6 and backward compatible with ES5.**
12+
**It ONLY supports ES6 and above.** Read <https://hckhanh.github.io/react-tree-es6> for more details.
1413

1514
## Installation
1615

@@ -20,102 +19,6 @@ npm install --save react-tree-es6
2019

2120
## Usage
2221

23-
import/require `ReactTree` in your source code:
24-
25-
```js
26-
import ReactTree from 'react-tree-es6';
27-
```
28-
29-
and add this component into your `render()` function:
30-
31-
```js
32-
render() {
33-
return (<ReactTree core={CORE} onChanged={this.handleOnChanged} />);
34-
}
35-
```
36-
37-
**Go to [example](example) folder to get more details.**
38-
39-
### core
40-
41-
`core` is the jsTree object contains basic data and configurations of the tree.
42-
This is an example of `core` object:
43-
44-
```js
45-
{
46-
data: [ // data can be an array or object.
47-
'Simple root node',
48-
{
49-
text: 'Root node 2',
50-
state: {
51-
opened: true,
52-
selected: true
53-
},
54-
children: [
55-
{
56-
text: 'Child 1'
57-
},
58-
'Child 2'
59-
]
60-
}
61-
]
62-
}
63-
```
64-
65-
As you know, a tree has one or many nodes, here is the full structure of a node:
66-
67-
```js
68-
// Alternative format of the node (id & parent are required)
69-
{
70-
id: 'string' // required
71-
parent: 'string' // required
72-
text: 'string' // node text
73-
icon: 'string' // string for custom
74-
state: {
75-
opened: boolean // is the node open
76-
disabled: boolean // is the node disabled
77-
selected: boolean // is the node selected
78-
},
79-
li_attr: { } // attributes for the generated LI node
80-
a_attr: { } // attributes for the generated A node
81-
}
82-
```
83-
84-
You can define a `core` object and then put it to `core` property:
85-
86-
```js
87-
const CORE = {
88-
data: [
89-
'Simple root node',
90-
{
91-
text: 'Root node 2',
92-
state: {
93-
opened: true,
94-
selected: true
95-
},
96-
children: [
97-
{
98-
text: 'Child 1'
99-
},
100-
'Child 2'
101-
]
102-
}
103-
]
104-
};
105-
106-
class ExampleApp extends React.Component {
107-
render() {
108-
return (<ReactTree core={CORE} />);
109-
}
110-
}
111-
```
112-
113-
**To make sure you can find what you need, go to [jsTree API](https://www.jstree.com/api) for more details.**
114-
115-
### onChanged
116-
117-
This is an event to handle when a node is clicked:
118-
11922
```js
12023
const CORE = {
12124
data: [
@@ -162,39 +65,6 @@ class ExampleApp extends React.Component {
16265
}
16366
```
16467

165-
### Themes
166-
167-
If user want to apply css for **ReactTree**, consider to include these files to your web app:
168-
169-
* node_modules/jstree/dist/themes/**default**/style.min.css
170-
* node_modules/jstree/dist/themes/**default-dark**/style.min.css
171-
172-
with additional options in `core` object, for instance with **default-dark** theme:
173-
174-
```js
175-
const CORE = {
176-
data: [
177-
'Simple root node',
178-
{
179-
text: 'Root node 2',
180-
state: {
181-
opened: true,
182-
selected: true
183-
},
184-
children: [
185-
{
186-
text: 'Child 1'
187-
},
188-
'Child 2'
189-
]
190-
}
191-
],
192-
themes: {
193-
name: 'default-dark'
194-
}
195-
};
196-
```
197-
19868
## License
19969

200-
MIT (<http://www.opensource.org/licenses/mit-license.php>)
70+
MIT

book.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"root": "./book",
3+
"version": "v1.1.0"
4+
}

book/GLOSSARY.md

Whitespace-only changes.

book/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# react-tree-es6
2+
3+
[jsTree](https://www.jstree.com) is written on library, my wrapper just *wrap it* to make sure it can work well with life cycle of React.
4+
All APIs from jsTree are apply to this wrapper. So you can work with this component like [jsTree](https://www.jstree.com).
5+
6+
![Tree Folder](./images/tree.png)
7+
8+
For now, it' just has some basic features. If you think there are some better ideas can apply to this wrapper,
9+
please [make a issue](https://github.com/hckhanh/react-tree-es6/issues/new). *Any help would be appreciated.*

book/SUMMARY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Summary
2+
3+
* [Overview](README.md)
4+
* [Get Started](get-started/README.md)
5+
* [Add core Data](get-started/add-core-data.md)
6+
* [Add onChanged Listener](get-started/add-onchanged-listener.md)
7+
* [Themes](get-started/themes.md)
8+
* [Full Example](get-started/full-example.md)
9+
* [License](license.md)

book/get-started/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Get Started
2+
3+
## Installation
4+
5+
```js
6+
npm install --save react-tree-es6
7+
```
8+
9+
Keep in mind that this module has *two peer dependencies* (**reat** and **react-dom**).
10+
It *only* support for **ES6 and above**, because I decide to move forward.
11+
The source code from this module is written in ES6 and compiled to ES5.
12+
13+
Please upgrade to **{{ config.version }}** to support [jsTree API](https://www.jstree.com/api)
14+
better than ~~v0.x~~.
15+
16+
## Usage
17+
18+
import `ReactTree` in your code:
19+
20+
```js
21+
import ReactTree from 'react-tree-es6';
22+
```
23+
24+
then, add to `render()` function:
25+
26+
```js
27+
render() {
28+
return (<ReactTree core={CORE} onChanged={this.handleOnChanged} />);
29+
}
30+
```

book/get-started/add-core-data.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Add core data
2+
3+
[`core`](https://www.jstree.com/api/#/?q=core) is the jsTree object contains basic
4+
data and configurations of the tree. This is an example of `core` object:
5+
6+
```js
7+
{
8+
data: [ // data can be an array or object.
9+
'Simple root node',
10+
{
11+
text: 'Root node 2',
12+
state: {
13+
opened: true,
14+
selected: true
15+
},
16+
children: [
17+
{
18+
text: 'Child 1'
19+
},
20+
'Child 2'
21+
]
22+
}
23+
]
24+
}
25+
```
26+
27+
## Node Format
28+
29+
As you know, *a tree has one or many nodes, each node has one or many child nodes*:
30+
31+
```js
32+
// Alternative format of the node (id & parent are required)
33+
{
34+
id: 'string' // required
35+
parent: 'string' // required
36+
text: 'string' // node text
37+
icon: 'string' // string for custom
38+
state: {
39+
opened: boolean // is the node open
40+
disabled: boolean // is the node disabled
41+
selected: boolean // is the node selected
42+
},
43+
li_attr: { } // attributes for the generated LI node
44+
a_attr: { } // attributes for the generated A node
45+
}
46+
```
47+
48+
You can define a `core` object and use with `core` property:
49+
50+
```js
51+
const CORE = {
52+
data: [
53+
'Simple root node',
54+
{
55+
text: 'Root node 2',
56+
state: {
57+
opened: true,
58+
selected: true
59+
},
60+
children: [
61+
{
62+
text: 'Child 1'
63+
},
64+
'Child 2'
65+
]
66+
}
67+
]
68+
};
69+
70+
class ExampleApp extends React.Component {
71+
render() {
72+
return (<ReactTree core={CORE} />);
73+
}
74+
}
75+
```
76+
77+
**To make sure you can find what you need, go to [jsTree API](https://www.jstree.com/api) for more details.**
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Add onChanged Listener
2+
3+
This event will be triggered when a node is clicked:
4+
5+
```js
6+
class ExampleApp extends React.Component {
7+
constructor(props) {
8+
super(props);
9+
10+
this.state = { items: [] };
11+
12+
this.handleOnChanged = this.handleOnChanged.bind(this);
13+
}
14+
15+
handleOnChanged(changedItems) {
16+
this.setState({
17+
items: changedItems.map(item => item.text).join(', ')
18+
});
19+
}
20+
21+
render() {
22+
return (
23+
<div>
24+
<ReactTree core={CORE} onChanged={this.handleOnChanged} />
25+
<div>Selected items: {this.state.items}</div>
26+
</div>
27+
);
28+
}
29+
}
30+
```

0 commit comments

Comments
 (0)