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

wpb

v0.1.2

Published

WpB - WebpackBulder - less chaos in React World!

Downloads

33

Readme

Webpack Builder

Less chaos in React World

How to install

npm i -S wpb

How to use

index.jsx

import React, { Fragment } from 'react';
import { app, Loadable } from 'wpb';
import { Route } from 'react-router-dom';

app(() => (
  <Fragment>
    <Route exact path="/" component={Loadable(import('./modules/home'))} />
    <Route path="/actions" component={Loadable(import('./modules/actions'))} />
  </Fragment>
));

if (module.hot) {
  module.hot.accept();
}

Module Example

.
├── actions
│   └── index.js
├── components
│   ├── index.jsx
│   └── style.scss
├── constants
│   └── index.js
├── containers
│   └── index.js
├── epics
│   ├── index.js
│   └── init.js
├── index.jsx
└── reducers
    └── index.js

constants/index.js

export const ACTIONS_INIT = 'ACTIONS_INIT';
export const ACTIONS_IDLE = 'ACTIONS_IDLE';
export const ACTIONS_CLEAR = 'ACTIONS_CLEAR';

actions/index.js

import * as constants from '../constants';

export const initActions = () => ({
  type: constants.ACTIONS_INIT,
});

export const idleActions = () => ({
  type: constants.ACTIONS_IDLE,
});

export const clearActions = () => ({
  type: constants.ACTIONS_CLEAR,
});

components/index.jsx

import React from 'react';
import PropTypes from 'prop-types';
import { CSSTransition, TransitionGroup } from 'react-transition-group';
import Layout from '../../layout';
import style from './style.scss';

const classNames = {
  appear: style.appear,
  appearActive: style['appear-active'],
  enter: style.enter,
  enterActive: style['enter-active'],
  exit: style.exit,
  exitActive: style['exit-active'],
};

const transitionProps = {
  timeout: 1000,
  classNames,
};

const Component = ({ status, initActions, clearActions }) => (
  <Layout>
    <div>
      <h1>Status: {status}</h1>
      <TransitionGroup>
        {status !== 'idle' && (
          <CSSTransition {...transitionProps}>
            <button onClick={initActions}>Init</button>
          </CSSTransition>
        )}
        {status === 'idle' && (
          <CSSTransition {...transitionProps}>
            <button onClick={clearActions}>Clear</button>
          </CSSTransition>
        )}
      </TransitionGroup>
    </div>
  </Layout>
);

Component.propTypes = {
  status: PropTypes.string.isRequired,
  initActions: PropTypes.func.isRequired,
  clearActions: PropTypes.func.isRequired,
};

export default Component;

components/style.scss

.enter {
  opacity: 0;
}

.enter.enter-active {
  opacity: 0;
  transition: opacity 300ms ease-in;
}

.exit {
  opacity: 0;
}

.exit.exit-active {
  opacity:  0.01;
  transition: opacity 200ms ease-in;
}

.appear {
  opacity: 0;
}

.appear.appear-active {
  opacity: 0.01;
  transition: opacity 100ms ease-in;
}

containers/index.js

import { connect } from 'react-redux';
import Component from '../components';
import { initActions, clearActions } from '../actions';

const mapStateToProps = state => ({ status: state.actions.status });
const mapDispatchToProps = { initActions, clearActions };

export default connect(mapStateToProps, mapDispatchToProps)(Component);

reducers/index.js

import * as constants from '../constants';

const status = 'null';

const defaultState = {
  status,
};

export default (state = defaultState, action) => {
  switch (action.type) {
    case constants.ACTIONS_INIT:
      return { ...state, status: 'init' };
    case constants.ACTIONS_IDLE:
      return { ...state, status: 'idle' };
    case constants.ACTIONS_CLEAR:
      return { ...state, status };
    default:
      return state;
  }
};

epics/index.js

import { combineEpics } from 'redux-observable';

import initEpic from './init';

export default combineEpics(initEpic);

epics/init.js

import { ACTIONS_INIT } from '../constants';
import { idleActions } from '../actions';

export default action$ => action$.ofType(ACTIONS_INIT).mapTo(idleActions());

index.jsx

import React from 'react';
import { injectReducer, injectEpic } from 'wpb/lib/store';
import Container from './containers';
import redux from './reducers';
import epics from './epics';

injectEpic('actions', epics);
injectReducer('actions', redux);

export default props => (
  <Container {...props} />
);