From f6ec8acb30bd098463fee4908a3e06cf19e0142b Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 9 Sep 2020 14:41:45 +0200 Subject: tooltips --- .../frontend/app/views/viewer/nav/eflux.chrome.js | 100 +++++++++++++++++---- 1 file changed, 83 insertions(+), 17 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/nav/eflux.chrome.js') diff --git a/animism-align/frontend/app/views/viewer/nav/eflux.chrome.js b/animism-align/frontend/app/views/viewer/nav/eflux.chrome.js index f8c2892..a7f6d24 100644 --- a/animism-align/frontend/app/views/viewer/nav/eflux.chrome.js +++ b/animism-align/frontend/app/views/viewer/nav/eflux.chrome.js @@ -7,24 +7,90 @@ import { import { PlayButton } from './viewer.icons' import actions from 'app/actions' -const EfluxChrome = React.memo(({ navStyle, playing, transcriptOpen, started, growlOpen, growlMessage }) => ( -
-
- - {EfluxLogo} - -
-
- {growlMessage} -
-
- -
actions.viewer.toggleComponent('transcript')}> - {EfluxMenu} +const PLAY_MESSAGES = { + not_started: 'Start the Exhibition', + playing: 'Pause', + paused: 'Resume', +} + +class EfluxChrome extends Component { + state = { + eflux: false, + play: false, + transcript: false, + started: false, + playMessage: PLAY_MESSAGES.not_started, + } + handleMouseEnter(category) { + this.setState({ [category]: true }) + } + handleMouseLeave(category) { + this.setState({ [category]: false }) + } + componentDidUpdate(prevProps) { + if (this.props.playing !== prevProps.playing) { + if (!this.state.started) { + this.setState({ + started: true, + play: false, + }) + setTimeout(() => { + this.setState({ + playMessage: this.props.playing ? PLAY_MESSAGES.playing : PLAY_MESSAGES.paused, + }) + }, 150) + } else { + this.setState({ + playMessage: this.props.playing ? PLAY_MESSAGES.playing : PLAY_MESSAGES.paused, + }) + } + } + } + render() { + const { navStyle, playing, transcriptOpen, growlOpen, growlMessage } = this.props + return ( +
+ +
+ {growlMessage} +
+
+ this.handleMouseEnter('play')} + onMouseLeave={() => this.handleMouseLeave('play')} + > + + +
this.handleMouseEnter('transcript')} + onMouseLeave={() => this.handleMouseLeave('transcript')} + onClick={() => actions.viewer.toggleComponent('transcript')} + > + {EfluxMenu} +
+
+
+ {'Back to e-flux'} +
+
+ {this.state.playMessage} +
+
+ {'Read the Transcript'} +
-
-
-)) + ) + } +} const mapStateToProps = state => ({ navStyle: state.viewer.navStyle, -- cgit v1.2.3-70-g09d2