import React, { Component } from 'react' import { Link } from 'react-router-dom' import { connect } from 'react-redux' 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" import { history } from "site/store" class Artists extends Component { state = { currentIndex: 0, detail: false, } constructor(props) { super(props) this.ref = React.createRef() this.showArtist = this.showArtist.bind(this) this.previousArtist = this.previousArtist.bind(this) this.nextArtist = this.nextArtist.bind(this) this.goHome = this.goHome.bind(this) this.changeLanguage = this.changeLanguage.bind(this) } componentDidMount() { actions.site.interact() } showArtist(currentIndex) { this.setState({ detail: true, currentIndex }) this.scrollToTop() } 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 }) this.scrollToTop() } goHome() { history.push(`/last-museum/home/`) } changeLanguage() { actions.site.changeLanguage(this.props.language === "de" ? "en" : "de") } scrollToTop() { setTimeout(() => { if (!this.ref.current) return Array.from(this.ref.current.querySelectorAll(".artist-content")).forEach(el => { el.scrollTo(0, 0) }) }, 0) } render() { const { language } = this.props const { currentIndex, detail } = this.state return (