GithubHelp home page GithubHelp logo

afeiship / react-waterfall Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 310 KB

Waterfall component for react.

License: MIT License

Ruby 8.88% JavaScript 72.41% SCSS 9.49% EJS 9.22%
react waterfall high-performance

react-waterfall's Introduction

react-waterfall

Waterfall component for react.

version license size download

installation

npm install -S @jswork/react-waterfall

properties

Name Type Required Default Description
className string false -
items array false []
template func false noop
column number false 3

usage

  1. import css
@import "~@jswork/react-waterfall/dist/style.css";

// or use sass
@import "~@jswork/react-waterfall/dist/style.scss";

// customize your styles:
$react-waterfall-options: ()
  1. import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactWaterfall from '@jswork/react-waterfall';
import './assets/style.scss';

const 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' },
  { src: 'https://picsum.photos/id/101/160/120', id: '888' },
  { src: 'https://picsum.photos/id/102/160/120', id: '999' },
  { src: 'https://picsum.photos/id/103/160/120', id: '100' }
];


class App extends React.Component {
  constructor(inProps) {
    super(inProps);
    this.state = {
      column: 3,
      items
    };
  }

  template = ({ item }) => {
    return (
      <div key={item.id} className={`is-item`}>
        <img width="100%" src={item.src} />
        <p>Cap = {item.id}</p>
      </div>
    );
  };

  onChange = (inEvent) => {
    const { value } = inEvent.target;
    const _items = items.slice(0, parseInt(value, 10));
    this.setState({
      items: _items
    });
  };

  render() {
    const { items, column } = this.state;
    console.log('items:', items);

    return (
      <ReactDemokit
        className="p-3 app-container"
        url="https://github.com/afeiship/react-waterfall">
        <p>
          <input type="range" max={10} onChange={this.onChange} />
        </p>
        <ReactWaterfall
          column={column}
          items={items}
          template={this.template}
        />
      </ReactDemokit>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.

react-waterfall's People

Contributors

afeiship avatar

Stargazers

ax4 avatar winjeysong avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.