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-lite-layered

v0.2.3

Published

Dropdown menu from Talk by teambition

Downloads

10

Readme

React Lite Dialog, Modals, Popover, Overlay

Dialog, Modals, Popover, Overlay components from Talk by Teambition.

Demo http://ui.talk.ai/react-lite-layered/

Inspired by http://stackoverflow.com/a/26789089/883571

Notice, 0.1.x is using React 0.14.x, while 0.0.x was using React 0.13.

Properties

This module contains 6 layered components. There are some common properties:

  • show(bool.isRequired) controls visibility
  • name(string, defaults to default), CSS hook "is-for-#{name}"
Modal
T = React.PropTypes

propTypes:
  # this component accepts children
  name:             T.string
  title:            T.string
  onCloseClick:     T.func.isRequired
  showCornerClose:  T.bool
  show:             T.bool.isRequired
Popover
propTypes:
  # this component accepts children
  title:              T.string
  name:               T.string
  onPopoverClose:     T.func
  positionAlgorithm:  T.func # could be customized
  baseArea:           T.object.isRequired # top, right, down, left
  showClose:          T.bool.isRequired
  show:               T.bool.isRequired
  • baseArea(object.isRequired) positions get from Element.getBoundingClientRect

  • positionAlgorithm(func, optional) if given, takes in baseArea and returns CSS styles

Overlay
propTypes:
  # this component accepts children
  show: T.bool.isRequired
  name: T.string

Notice: click content to close overlay, not the black area.

Reader Modal
T = React.PropTypes

propTypes:
  # this component accepts children
  name:             T.string
  title:            T.string
  onCloseClick:     T.func.isRequired
  showCornerClose:  T.bool
  show:             T.bool.isRequired

Child structure

div
  .header (fixed at top)
  .content (scrollable)
  .footer (fixed at bottom)
File Modal
T = React.PropTypes

propTypes:
  # this component accepts children
  name:             T.string
  title:            T.string
  onCloseClick:     T.func.isRequired
  showCornerClose:  T.bool
  show:             T.bool.isRequired
Transition

Transition component with timeout. Read more at: https://github.com/facebook/react/issues/1326

Supposition

These modules contains bussiness logics of Teambition. I will suggest copy code and make create you own.

And the layered mixin is tricky. I hope it improved in the future.

Usage

npm i --save react-lite-layered

Read src/demo/main.jsx(compiles with Babel) for details:

import {default as React} from 'react';

import {Popover, Modal, Overlay} from 'react-lite-layered';

import './modal.css';
import './popover.css';
import './overlay.css';
import './fade.css';
import './demo.css';

var App = React.createClass({
  displayName: 'page-app',

  getInitialState: function () {
    return {
      showModal: false,
      showPopover: false,
      showOverlay: false
    };
  },

  componentDidMount: function() {
    this._areaEl = this.refs.area
  },

  getTriggerArea: function() {
    if (this._areaEl) {
      return this._areaEl.getBoundingClientRect()
    } else {
      return {}
    }
  },

  onModalShow: function() {
    this.setState({showModal: true})
  },

  onModalHide: function() {
    this.setState({showModal: false})
  },

  onPopoverToggle: function(event){
    event.stopPropagation()
    this.setState({showPopover: !this.state.showPopover})
  },

  onPopoverClose: function() {
    this.setState({showPopover: false})
  },

  onOverlayToggle: function() {
    this.setState({showOverlay: !this.state.showOverlay})
  },

  onOverlayClose: function() {
    this.setState({showOverlay: false})
  },

  renderModal: function() {
    return <Modal
      name="page-app" title="demo of Modal"
      onCloseClick={this.onModalHide} showClose={true} show={this.state.showModal}>
      <div>{"Content of Modal, style this for yor self."}</div>
    </Modal>
  },

  renderPopover: function() {
    return <Popover
      onPopoverClose={this.onPopoverClose}
      baseArea={this.getTriggerArea()}
      showClose={true}
      title="title is optional"
      show={this.state.showPopover}>
      <div>Some content of popover</div>
    </Popover>
  },

  renderOverlay: function() {
    return <Overlay name="page-app" show={this.state.showOverlay}>
      <div className="content" onClick={this.onOverlayClose}>{"Content in Overlay"}</div>
    </Overlay>
  },

  render: function() {
    return <div className="page-app">
        <button onClick={this.onModalShow}>Show Modal</button>
        <button ref="area" onClick={this.onPopoverToggle}>Show Popover</button>
        <button onClick={this.onOverlayToggle}>Show Overlay</button>
        {this.renderModal()}
        {this.renderPopover()}
        {this.renderOverlay()}
    </div>
  }
});

var PageApp = React.createFactory(App);

var demo = document.querySelector('.demo');

React.render(PageApp(), demo);

Develop

npm i

You need a static file server for the HTML files. Personally I suggest using Nginx.

Develop:

gulp html # regenerate index.html
webpack-dev-server --hot # enable live-reloading

or simply

npm run dev

Build (Pack and optimize js, reivision js and add entry in index.html):

gulp build

License

MIT