eiriklv / react-masonry-mixin

A React.js mixin for using @desandro's Masonry
MIT License
175 stars 37 forks source link

Create MasonryComponent as an alternative to Mixin #8

Open eiriklv opened 9 years ago

eiriklv commented 9 years ago

Follow the same principals as FluxComponent from flummox

cassidoo commented 9 years ago

+1, especially now that Mixins are out

eiriklv commented 9 years ago

@cassidoo

Shouldn't be too much work, and it would look a lot nicer with something like this:

var React = require('react');
var Masonry = require('react-masonry-component')(React);

var masonryOptions = {
    transitionDuration: 0
};

var Gallery = React.createClass({
    render: function () {
        var images = this.props.elements.map(function(element){
           return (
                <div className="someclass">
                    <img src="element.src" />
                </div>
            );
        });

        return (
            <Masonry options={masonryOptions}>
                {images}
            </Masonry>
        );
    }
});

module.exports = Gallery;

You would just need to be able to specify what type of element the <Masonry> component should default to and be able to override it, just like <CSSTransitionGroup>.

rayshan commented 9 years ago

+1

eiriklv commented 9 years ago

@rayshan it exists here :-)

rayshan commented 9 years ago

Oh cool will give that a try, thanks!