All Projects → shashankraider → react-bricks

shashankraider / react-bricks

Licence: other
React Implementation for bricks.js with infinite scroller

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to react-bricks

MiniMasonry.js
Minimalist dependancy free Masonry layout library
Stars: ✭ 313 (+1741.18%)
Mutual labels:  masonry-layout
Iris.iOS
An iOS application enables you explore art works provided by DeviartArt.com with high quality UX.
Stars: ✭ 60 (+252.94%)
Mutual labels:  masonry-layout
vue-masonry-gallery
Masonry gallery layout component for Vue.js
Stars: ✭ 35 (+105.88%)
Mutual labels:  masonry-layout
react-plock
Plock is a responsive masonry layout implementation for React.
Stars: ✭ 118 (+594.12%)
Mutual labels:  masonry-layout
QuickWebKit
A great & strong plugin based WebViewController. 一款基于插件的 WebView 视图控制器,您可以基于它设计您的浏览器插件,然后像积木一样来组装它们。
Stars: ✭ 29 (+70.59%)
Mutual labels:  bricks
react-native-masonry-list
The Masonry List implementation which has similar implementation as the `FlatList` in React Native
Stars: ✭ 255 (+1400%)
Mutual labels:  masonry-layout
angular-masonry
A simple lightweight library to use Masonry layout in Angular
Stars: ✭ 11 (-35.29%)
Mutual labels:  masonry-layout
AWESOME-LDraw
LDraw — awesome software, file format, parts library and model repository (3D models of LEGO® and LEGO-compatible bricks)
Stars: ✭ 30 (+76.47%)
Mutual labels:  bricks
Wortuhr ESP8266
Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele
Stars: ✭ 33 (+94.12%)
Mutual labels:  bricks
Justified Gallery
Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
Stars: ✭ 1,512 (+8794.12%)
Mutual labels:  masonry-layout

React Bricks

React Bricks is a React Masonry Framework with infinite scroll feature, currently it leverages bricks.js. This framework is plug and play used to deliver "Pinterest" type experience.

Demo

Demo link - https://react-bricks.herokuapp.com/

Feedback

For Feeback on any enhancement requests, please reach out on [email protected]

Install

$ npm install react-bricks-infinite

Usage

import React from "react";
import ReactBricks from "react-bricks-infinite";

class Bricks extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            bricks: this.getBricks(),
            reRender: false,
            containerId: "bricks-container-app",
            hasMoreBricks: true
        }

    }
     getBricks = () => { 
         let results = null;
        results = this.elements.map(({key, value}, i) => {
            return (
                <div key={key}
                      className="card">
                      <h1>{i}</h1>
                      <p>{value}</p>
                </div>     
            );
        });
        return results;
    }
     render() {
        return(
            <div className="app">
                <ReactBricks
                containerId = {this.containerId}
                loadMoreBricks = {this.loadMore}
                hasMoreBricks  = {this.state.hasMoreBricks}
                reRender = {this.state.reRender}
                bricks= {this.state.bricks}
                defaultLoaderStyle = {this.defaultLoaderStyle}
                />
            </div>
        );
    }
}

Props

containerId

Id of the container of the grid which will contain the bricks/grid items, Default value is containerId = "bricks-container"

 return(
            <div>
                <ReactBricks
                containerId = "bricks-container"
                .
                .
                .
                />
            </div>
        );

bricks

bricks are the list of child items which will be part of the grid

 return(
            <div>
                <ReactBricks
                bricks= {this.state.bricks}
                .
                .
                .
                />
            </div>
        );

hasMoreBricks

This is type = boolean field required to be true in case their are more bricks/items to be loaded in the grid. If false Event listeners asscoiated are removed . By default it has value false

sizes

Its an array of objects describing the properties of grid container at different window breakpoints.

How does each object looks like :-

{ mq: '768px', columns: 3, gutter: 25 }

// mq      - the minimum viewport width (String CSS unit: em, px, rem)
// columns - the number of vertical columns
// gutter  - the space (in px) between the columns and grid items

By default the sizes value is

 sizes= [
        {columns: 2, gutter: 20},
        {mq: '768px', columns: 3, gutter: 25},
        {mq: '1024px', columns: 5, gutter: 40}
    ] 

How to use it -

const sizes= [
        {columns: 2, gutter: 10},
        {mq: '768px', columns: 2, gutter: 35},
        {mq: '1024px', columns: 8, gutter: 60}
    ] 

    return(
            <div>
                <ReactBricks
                .
                .
               sizes = {sizes}
                .
                .
                />
            </div>
        );  

useWindowForScroll

This is type = boolean If true Scroll listeners are attached to window , in case of false it will attach to the components parentNode. By default it is true

reRender

This is type = boolean If true reRender will readjust all the bricks in the grid container. This is helpful in case of a window resize

.
.
constructor(props) {
    .
    .
     window.onresize = () => {
           this.setState({reRender: true});
        }
        .
        .
}

render(){
    return(
            <div>
                <ReactBricks
                .
                .
               reRender = {this.state.reRender}
                .
                .
                />
            </div>
        );   
}

What is happening above is when on a resize we send props reRender as true it will repack all the bricks depending on the new window size and the breakpoint mentioned in the sizes props above

loaderComponent

Your own custom loader component can be passed as props to ReactBricks. By default the loader is a spinner.

Default Loader

Default Loader Screen Shot

return(
            <div>
                <ReactBricks
                .
                .
               loaderComponent = {<CustomLoader className="custom-loader"/>}
                .
                .
                />
            </div>
        );      

else , you can customize the default Loader using defaultLoaderStyle

defaultLoaderStyle

Currently the spinner has by default below properties

spinnerSize = 28(in px) duration: 1333 (in ms) color: multicolor (4 colors)

In case the default spinner properties needs to be changed, it can be done as below

 const defaultLoaderStyle = {
            spinnerSize: 64,
            duration: 2000,
            color: "#ff0000"
        }
 return(
            <div>
                <ReactBricks
                .
                .
               defaultLoaderStyle = {defaultLoaderStyle}
                .
                .
                />
            </div>
        );       

style

Custom inline styles can be passed which would applied to the grid container . By default it is {}

 const style = {
            background: "#000000",
        }
 return(
            <div>
                <ReactBricks
                .
                .
               style = {style}
                .
                .
                />
            </div>
        );       

License

MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].