import React, { Component } from 'react' import { connect } from 'react-redux' import actions from 'app/actions' import { ROMAN_NUMERALS } from 'app/constants' import { Arrow } from './viewer.icons' import NavPlayer from './nav.player' import { thumbnailURL } from 'app/utils/annotation.utils' class NavParent extends Component { state = { hovering: false, suppressHover: false, } constructor(props){ super(props) this.handleMouseLeave = this.handleMouseLeave.bind(this) this.handleMouseEnter = this.handleMouseEnter.bind(this) } handleMouseEnter(){ if (this.state.suppressHover) return this.setState({ hovering: true }) } handleMouseLeave(){ this.setState({ hovering: false, suppressHover: false }) } render() { const { viewer } = this.props return (
actions.viewer.toggleComponent('nav')}> {viewer.currentSection && {ROMAN_NUMERALS[viewer.currentSection.index]} {'. '} {viewer.currentSection.title} }
{viewer.nextSection && actions.viewer.seekToSection(viewer.nextSection)}> Next }
{viewer.nextSection &&
{ actions.viewer.seekToSection(viewer.nextSection) this.setState({ hovering: false, suppressHover: true }) }} style={{ backgroundImage: viewer.nextSection.media.length && 'url(' + thumbnailURL(viewer.nextSection.media[0].media) + ')', }}/> }
) } } const mapStateToProps = state => ({ viewer: state.viewer, }) export default connect(mapStateToProps)(NavParent)