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 (
TEXTS
{ESSAY_ORDER.map((key, index) => { const essay = ESSAYS[key] return (
this.showEssay(index)}> {essay.title}
) })}
{ESSAY_ORDER.map((key, index) => ( ))} {detail && (
{ESSAYS[ESSAY_ORDER[currentIndex]].title}
)}
{ArrowLeft}
{ArrowRight}
Home
{this.props.language === "de" ? ( de / en ) : ( de / en )}
) } } const mapStateToProps = state => ({ interactive: state.site.interactive, language: state.site.language, }) export default connect(mapStateToProps)(Essays) const EssayDetail = props => { switch (props.essayId) { case 'nadim': return case 'statements': return case 'developer': return } } const ArtistStatements = ({ essayId, index, isCurrent, language, onClose }) => (
ARTIST STATEMENTS
{ARTIST_ORDER.map((key, index) => { const artist = ARTISTS[key] return (
{artist.name}
) })}
) const NadimEssay = ({ essayId, index, isCurrent, language, onClose }) => (
About The Last Museum
By Nadim Samman
) const ArtistGlobe = () => (
{Globe} {ARTIST_ORDER.map((key, index) => { const artist = ARTISTS[key] return (
history.push(`/thelastmuseum/${artist.start}`)}> {index + 1}
) })}
) const DeveloperNotes = ({ essayId, index, isCurrent, language, onClose }) => (
Developer Notes
By Jules LaPlace
)