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-brickwall-dnd

v1.0.11

Published

Fancy Drag & Drop component.

Downloads

7

Readme

React Brickwall Drag & Drop  

example workflow npm version made-with-typescript

React Brickwall Drag & Drop is a fancy way to move items across multiple data sources via React-driven UI.

Installing

npm install react-brickwall-dnd

Usage

All dropzones should be wrapped inside a <Brickwall /> component. Any HTML element inside <Brickwall /> that has an id prop starting with bw-dz will be considered a dropzone. Dropzones cannot be nested. All direct children of a dropzone are draggable items.

React Brickwall provides a handy way of controlling data source changes via useDataSourceController() hook. It handles storing each dropzone's items in state and automatically handles all item replacements. This hook returns two values:

  • lists is a dictionary where key is dropzone id and value is an array of your data objects;
  • handleItemDrop() is a function that is provided to <Brickwall /> component's onItemDrop prop and automatically updates data object lists for each dropzone.

Each time items composition changes inside <Brickwall /> context, lists returned from the above hook will be updated with latest changes.

Alternatively you can manually store dropzone data sources wherever you like and pass your custom "on drop" handler to onItemDrop prop.

Example:

import Brickwall, { useDataSourceController } from "react-brickwall-dnd";

interface ShufflerComponentProps {
  listA: Item[];
  listB: Item[];
  listC: Item[];
}

const ShufflerComponent: React.FC<ShufflerComponentProps> = ({ listA, listB, listC }) => {
  const { lists, handleItemDrop } = useDataSourceController({
    "bw-dz-list-a": listA,
    "bw-dz-list-b": listB,
    "bw-dz-list-c": listC,
  });

  React.useEffect(() => {
    // do your thing with updated data
  }, [lists]);

  return (
    <Brickwall animationSpeed={200} gridGap={20} onItemDrop={handleItemDrop}>
      <div id="bw-dz-list-a">
        {lists["bw-dz-list-a"].map((item) => (
          <div key={item.id}>{item.text}</div>
        ))}
      </div>
      // it doesn't matter how deep you put your dropzones relative to <Brickwall />
      <section>
        <div id="bw-dz-list-b">
          {lists["bw-dz-list-b"].map((item) => (
            <div key={item.id}>{item.text}</div>
          ))}
        </div>

        <div>
          <div id="bw-dz-list-c">
            {lists["bw-dz-list-c"].map((item) => (
              <div key={item.id}>{item.text}</div>
            ))}
          </div>
        </div>
      </section>
    </Brickwall>
  );
};