es6-tree
tree view for web with vanilla ES6 Javascript
Using Octicons from Github
Default Customized
- Override styles easily
- Select event as node is clicked
- Select node from outside
- Supports anchor with href
Dependencies
none
- use static-server from
src
folder to test
Usage
;const tree = 'tree-div' config data;
Config
You can pass null
to use default config.
Types will be mapped to the type in your data, customize their styles like this:
const config = types: folder: css: "icon icon-file-directory" file: css: "icon icon-file" ;
Data
const data = id: "master-node" name: "#" type: "main" expanded: true children: id: "folder-1" type: "folder" name: "A folder" children: id: "article-1" name: "An article" type: "file" href: "/blog/1" id: "article-2" name: "Another article" type: "file" ;
Events
On select
tree;
Methods for interaction
select(id)
Select a node with code, will open all parent nodes as well
tree;
open(id)
Open a node that has children with code
tree;
Override styles
color on hover nodes
color for selected node
color on icon