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

55 lines
1.8 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');
module.exports = React.createClass({
propTypes: {
items: React.PropTypes.array
},
getDefaultProps: function () {
return {
items: require('./carousel.json'),
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;
default:
href = '/' + item.type + '/' + item.id + '/';
}
2015-09-08 14:56:28 -04:00
return (
<Thumbnail key={item.id}
type={item.type}
href={href}
2015-09-08 14:56:28 -04:00
title={item.title}
2015-10-06 13:07:24 -04:00
src={item.thumbnailUrl}
creator={item.creator}
remixes={item.remixes}
loves={item.loves} />
2015-09-08 14:56:28 -04:00
);
2015-10-06 13:07:24 -04:00
})}
2015-09-08 14:56:28 -04:00
</Slider>
);
}
});