scratch-www/src/components/carousel/carousel.jsx

65 lines
2.1 KiB
React
Raw Normal View History

2015-09-08 14:56:28 -04:00
var React = require('react');
var Slider = require('react-slick');
var Thumbnail = require('../thumbnail/thumbnail.jsx');
require('slick-carousel/slick/slick.scss');
require('slick-carousel/slick/slick-theme.scss');
require('./carousel.scss');
var Carousel = React.createClass({
2015-10-09 16:16:37 -04:00
type: 'Carousel',
2015-09-08 14:56:28 -04:00
propTypes: {
items: React.PropTypes.array
},
getDefaultProps: function () {
return {
items: require('./carousel.json'),
showRemixes: false,
showLoves: false,
2015-09-08 14:56:28 -04:00
settings: {
arrows: true,
dots: false,
infinite: false,
lazyLoad: true,
slidesToShow: 5,
slidesToScroll: 5,
variableWidth: true
}
};
},
render: function () {
return (
<Slider className={'carousel ' + this.props.className} {... this.props.settings}>
2015-09-10 15:00:07 -04:00
{this.props.items.map(function (item) {
var href = '';
switch (item.type) {
case 'gallery':
href = '/studio/' + item.id + '/';
break;
case 'project':
href = '/projects/' + item.id + '/';
break;
default:
href = '/' + item.type + '/' + item.id + '/';
}
2015-09-08 14:56:28 -04:00
return (
<Thumbnail key={item.id}
showLoves={this.props.showLoves}
showRemixes={this.props.showRemixes}
type={item.type}
href={href}
2015-09-08 14:56:28 -04:00
title={item.title}
src={item.thumbnail_url}
creator={item.creator}
remixes={item.remixers_count}
loves={item.love_count} />
2015-09-08 14:56:28 -04:00
);
}.bind(this))}
2015-09-08 14:56:28 -04:00
</Slider>
);
}
});
module.exports = Carousel;