import React, { Component } from 'react' import actions from 'site/actions' import "./artists.css" import { ARTISTS, ARTIST_ORDER } from "site/projects/museum/constants" import { ArrowLeft, ArrowRight } from "site/projects/museum/icons" export default class Artists extends Component { state = { currentIndex: 0, detail: true, } constructor(props) { super(props) this.showArtist = this.showArtist.bind(this) this.previousArtist = this.previousArtist.bind(this) this.nextArtist = this.nextArtist.bind(this) } componentDidMount() { actions.site.interact() } showArtist(currentIndex) { this.setState({ detail: true, currentIndex }) } previousArtist() { this.go(-1) } nextArtist() { this.go(1) } go(step) { const currentIndex = (this.state.currentIndex + step + ARTIST_ORDER.length) % ARTIST_ORDER.length this.setState({ currentIndex }) } render() { const { currentIndex, detail } = this.state return (
ARTISTS
{ARTIST_ORDER.map((key, index) => { const artist = ARTISTS[key] return (
this.showArtist(currentIndex)}> {artist.name}
) })}
{ARTIST_ORDER.map((key, index) => ( ))}
{ArrowLeft}
{ArrowRight}
) } } const ArtistDetail = ({ artist, index, isCurrent }) => { return (
{artist.name}
{artist.location}
) }