1.0.2 • Published 4 years ago

@feizheng/react-waterfall v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

react-waterfall

Waterfall component for react.

installation

npm install -S @feizheng/react-waterfall

properties

propertytypedefaultdescription
classNamestring''Extend className
itemsarray[]DataSource items
templatefuncnoop({ item, index, column })Item template
columnnumber3The column number

usage

  1. import css

    @import "~react-waterfall/style.scss";
    
    // customize your styles:
    $react-waterfall-options: ()
  2. import js

    import ReactWaterfall from '../src/main';
    import ReactDOM from 'react-dom';
    import React from 'react';
    import './assets/style.scss';
    
    class App extends React.Component {
      constructor(inProps) {
        super(inProps);
        this.state = {
          items: [
            { src: 'https://picsum.photos/id/658/200/300', id: '111' },
            { src: 'https://picsum.photos/id/653/200/100', id: '222' },
            { src: 'https://picsum.photos/id/112/300/200', id: '333' },
            { src: 'https://picsum.photos/id/656/500/200', id: '444' },
            { src: 'https://picsum.photos/id/115/100/120', id: '555' },
            { src: 'https://picsum.photos/id/621/100/180', id: '666' },
            { src: 'https://picsum.photos/id/634/160/120', id: '777' },
          ]
        };
      }
    
      template = ({ item }) => {
        return (
          <div key={item.id} className={`is-item`}>
            <img width="100%" src={item.src} />
            <p>Cap = {item.id}</p>
          </div>
        );
      };
    
      render() {
        return (
          <div className="app-container">
            <ReactWaterfall items={this.state.items} template={this.template} />
          </div>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago