import React from 'react' import {galleryImageUrl} from '../lib/helpers' export default class Gallery extends React.Component { onPrevClick (e) { this.props.dispatch({type: 'PREV_IMAGE'}) } onNextClick (e) { this.props.dispatch({type: 'NEXT_IMAGE'}) } onImageDotClick (index, e) { this.props.dispatch({type: 'VIEW_IMAGE', action: {index}}) } render () { const {images, imageIndex} = this.props if (!images || images.length === 0) { return null } const showPrev = imageIndex > 0 const showNext = imageIndex < images.length - 1 return (
{showPrev ?
: null} {showNext ?
: null}
{images.map((img, index) => { let cls = 'image-dot' if (index === imageIndex) { cls += ' selected' } return (
) })}
) } }