/** * Essays / texts / artist statements */ import React, { Component } from 'react' import { connect } from 'react-redux' import actions from 'site/actions' import "./artists.css" import "./essay.css" import { ARTISTS, ARTIST_ORDER, ESSAYS, ESSAY_TEXTS, ESSAY_ORDER } from "site/projects/museum/constants" import { ArrowLeft, ArrowRight, Globe } from "site/projects/museum/icons" import { history } from "site/store" class Essays extends Component { state = { currentIndex: 0, detail: false, } constructor(props) { super(props) this.ref = React.createRef() this.showEssay = this.showEssay.bind(this) this.previousEssay = this.previousEssay.bind(this) this.nextEssay = this.nextEssay.bind(this) this.close = this.close.bind(this) this.goHome = this.goHome.bind(this) this.changeLanguage = this.changeLanguage.bind(this) } componentDidMount() { actions.site.interact() } showEssay(currentIndex) { this.setState({ detail: true, currentIndex }) this.scrollToTop() } previousEssay() { this.go(-1) } nextEssay() { this.go(1) } go(step) { const currentIndex = (this.state.currentIndex + step + ESSAY_ORDER.length) % ESSAY_ORDER.length this.setState({ currentIndex }) this.scrollToTop() } goHome() { history.push(`/thelastmuseum/home/`) } changeLanguage() { actions.site.changeLanguage(this.props.language === "de" ? "en" : "de") } scrollToTop() { setTimeout(() => { Array.from(this.ref.current.querySelectorAll(".artist-detail")).forEach(el => { el.scrollTo(0, 0) }) }, 0) } close() { this.setState({ detail: false }) } render() { const { language } = this.props const { currentIndex, detail } = this.state return (