GithubHelp home page GithubHelp logo

york-ie-labs / resource-tree Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 448 KB

Tree structure visualized as a table. Click directories to move down into the tree, drag and drop to move directories and resources.

Home Page: https://york-ie-labs.github.io/resource-tree/

HTML 21.79% CSS 15.57% JavaScript 62.64%
react tree json files folder-structure folder-viewer hacktoberfest

resource-tree's Introduction

resource-tree

Tree structure visualized as a table. Click directories to move down into the tree, drag and drop to move directories and resources.

NPM JavaScript Style Guide

Install

yarn add @york-ie-labs/resource-tree

Dependencies

react-dnd

resource-tree depends on react-dnd. Since react-dnd can only have a single context in an app, where you wrap the resource-tree with DnD is up to your project implementation.

react-bootstrap-icons

resource-tree uses react-bootstrap-icons by default.

Usage

import React, { useRef, useState } from 'react'
import { ResourceTree } from '@york-ie-labs/resource-tree'
import { DndProvider, createDndContext } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'

import './App.css'

const initial = {
  label: 'home',
  children: [
    {
      type: 'directory',
      label: 'Personal Files',
      description: '',
      children: [
        {
          type: 'object',
          label: 'Interesting Tech',
          description: 'Notes on some companies and products'
        },
      ]
    },
  ]
}

function App() {
  const [tree, setTree] = useState(initial)
  const manager = useRef(RNDContext)
  return (
    <div className='app'>
      <DndProvider manager={manager.current.dragDropManager}>
        <ResourceTree tree={tree} setTree={setTree} />
      </DndProvider>
    </div>
  )
}

Props

Props Required Description
tree True The JSON tree structure to visualize. Each node under the root node must have a type key with a value of directory or object. Nodes of directory type must have children property with an Array as the value.
setTree True Update function to update the tree object
className False Optional class names to append to the resource-tree table element

License

MIT © York IE Labs

resource-tree's People

Contributors

anothrnick avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.