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-redux-subdivide

v0.0.4

Published

Split pane layout system for React and Redux. Each pane can be subdivided and any widget assigned to any pane.

Downloads

19

Readme

Subdivide Layout

Build Status Coverage Status version CC0 License

Split pane layout system for React and Redux apps. Each pane can be subdivided and any widget assigned to any pane allowing users define layout. Panes can be:

  • subdivided above a minimum size
  • subdivided horizontally or vertically
  • subdivided by dragging corners
  • resized by dragging edges
  • merged by dragging corners onto adjacent panes

When a new pane is created the user can chose which widget to display in that pane. The result is an application where the user can decide on an interface that suits their work flow.

It should also be possible to quickly mash up applications out of preexisting parts.


Usage

npm install react-redux-subdivide

Subdivide exposes the Subdivide component, a redux reducer, and a redux-observable epic.

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import {
  createStore,
  combineReducers,
  applyMiddleware
} from 'redux';
import { connect, Provider } from 'react-redux';
import {
  createEpicMiddleware,
  combineEpics
} from 'redux-observable';
import myEpics from './my-epics.js';

import {
  Subdivide,
  reducer as subdivideReducer,
  epic as subdivideEpic
} from 'subdivide';


class Chooser extends Component {
  constructor(...args) {
    super(...args);
    this.state = { choice: null };
    this.onSelect = this.onSelect.bind(this);
  }

  onSelect(choice) {
    this.setState({ choice });
  }
  
  renderMenu() {
    const choices = [
  	  'world',
  	  'moon',
  	  'universe',
  	  'galaxy'
  	];
  	return choices.map(choice => (
      <button
        key={ choice }
        onSelect={ () => onSelect(choice) }
        >
        { choice }
      </button>
    ));
);


  render() {
    const { choice } = this.state;

    return !choice ?
      <div>{ this.renderChoices() }</div> :
      <h1 />Hello { choice }!</h1>;
  }
}

const epicMiddleware =  createEpicMiddleware(
  combineEpics(...myEpics, subdivideEpic),
  // make sure to provide dependencies here
  // so subdivide can interface with the users
  // mouse movements
  { dependencies: { window, document } }
);

const store = createStore(
  combineReducers({
  	// this syntax will put the subdivide reducer
  	// on it's own key in the redux store.
  	// without doing this subdivide will not now
  	// where to look for it's own state
  	[subdivideReducer]: subdivideReducer
  }),
  applyMiddleware(
    epicMiddleware
  )
);

ReactDOM.render(
  <Provider store={store}>
    <Subdivide DefaultComponent={Chooser} />
  </Provider>,
  document.getElementById('root')
);

Run Example

npm install
npm start

Open the following link in a browser:

http://localhost:3000

Testing

Run the following two commands in separate terminals

npm run test:watch
npm run cover:watch

The first will start the testing scripts and rerun them on file changes. The second will run a task that will watch for file changes and run the coverage on the files.

You can open the html page displaying current coverage using the following

npm run cover:show

React-redux-subdivide is based off of the fantastic Subdivide project.

Although similar in appearence, the main differences from that project is a significant change in API, removing Immutable.js, adding the powerfull RxJS to accomplish the complex side-effects in Redux using Redux-Observable