npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-fs-tree

v0.2.0

Published

A recursive FS tree React.Component

Downloads

16

Readme

react-fs-tree

I am a beautiful React.Component tree and I will help you present FS hierarchy within a React App. No dependencies, just pure awesomeness! My creator has created me after testing few alternatives for tortilla.academy, and has found nothing which is as stylish and can show git-diff annotations right out of the box next to each file (here's an example page which was built with me).

This is how I look like behind the scenes:

import React from 'react'
import FSRoot from 'react-fs-tree'

const FSTree = () => (
  <FSRoot childNodes={[
    { name: 'file' },
    { name: 'added file', mode: 'a' },
    { name: 'deleted file', mode: 'd' },
    { name: 'modified file', mode: 'm' },
    { name: 'folder', childNodes: [
      { name: 'foo' },
      { name: 'bar' },
      { name: 'baz' },
    ] },
  ]} />
)

A small demonstration app of me can be found in the demo dir.

My nodes will pop and glow once you click on them. I'll be sure to notify you whenever it happens ;-)

const onSelect = (node) => {
  console.log(`node ${node.path} selected`)
}

const onOpen = (node) => {
  console.log(`node ${node.path} opened`)
}

<FSRoot onSelect={onSelect} onOpen={onOpen} childNodes={[
  // ...
]} />

I can also notify you on...

  • onSelect(node)

  • onDeselect(node)

  • onSelectChange(node)

  • onOpen(node)

  • onClose(node)

  • onOpenChange(node)

If you really want, you can change my colors with the theme prop, using the following variables:

  • theme.primary

  • theme.selectedBackground

  • theme.selectedText

  • theme.modeM

  • theme.modeA

  • theme.modeD

Each of my nodes is an entity of its own and will do exactly what you tell it to:

  • node.open() - Will open the node.

  • node.close() - Will close the node.

  • node.toggleOpen() - Will open the node if closed and will close the node if opened.

  • node.select() - Will select the node.

  • node.deselect() - Will deselect the node.

  • node.toggleSelect() - Will select the node if deselected and will deselect the node if selected.

You can also ask for any of its details, like...

  • node.name - The name of the node e.g. foo.

  • node.path - The full path of the node starting from the root e.g. ~/folder/foo.

  • node.childNodes - An array of the direct children of the node.

  • node.parentNode - The parent of the node.

  • node.root - The greatest ancestor of the node.

  • node.opened - Whether the node is opened or not.

  • node.selected - Whether the node is selected or not.

  • node.branchedOut - Whether the node has offspring or not.

  • node.virtual - Whether the node is currently rendered or is just a virtual representation of the its data*.

* A node is an actual instance of its belonging React.Component.

You should also know that...

  • You can make me non interactive by passing me the noninteractive flag. When that happens my nodes won't respond to your clicks, and neither do I. You can ask each of my nodes whether it's interactive or not with node.noninteractive.

  • You can pass a git-diff mode that will signify whether the node was added ('a'), deleted ('d') or modified ('m'). You can ask the node what's its mode at anytime using node.mode.

If you like what you see you can install me with npm:

$ npm install react-fs-tree

Feel free to use me (MIT license)!