treebox
Install
npm i treeboxjs
Import
External JS with NPM:
import TreeBox from 'treeboxjs';
...
ES6 module:
<script type="module">
import TreeBox from 'path-to-module/dist/index.browser.js';
...
Use
import TreeBox from 'treeboxjs';
const nodes = {
display: `<h1>treebox example</h1>`,
children: {
directory: {
children: {
file: {
display: `<p>A file</p>`,
},
},
},
file: {
display: `
<div>
<p>Another file</p>
<p>Multiple elements must be wrapped in a single enclosing element</p>
<a treebox-href="/directory/file">Link to /directory/file within treebox</a>
</div>
`,
},
},
};
const root = document.getElementById('myTreeBoxRoot');
const tb = new TreeBox({nodes, root});
tb.navigate('/file');
tb.navigate('/directory/file');
tb.navigate('/');