1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
import React, { Component } from 'react'
import { connect } from 'react-redux'
import {
EfluxLogo, EfluxClose, TranscriptIcon
} from './eflux.icons'
import { PlayButton } from './viewer.icons'
import actions from 'app/actions'
import { URLS } from 'app/constants'
const PLAY_MESSAGES = {
not_started: 'Start the Exhibition',
playing: 'Pause',
paused: 'Resume',
}
class EfluxChrome extends Component {
state = {
eflux: false,
play: false,
transcript: false,
close: 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, navGradient,
playing, transcriptOpen, isFullscreen,
growlOpen, growlMessage,
atEndOfSection, currentSection
} = this.props
const showingTranscriptTooltip = ((atEndOfSection && currentSection.index === 0) || this.state.transcript)
let className = "eflux-header"
if (navStyle) className += ' ' + navStyle
if (navGradient) className += ' gradient'
if (transcriptOpen) className += ' transcript-open'
return (
<div className={className}>
<div className="eflux-gradient" />
<div className="eflux-logo">
<a
href={URLS.eflux_logo}
onMouseEnter={() => this.handleMouseEnter('eflux')}
onMouseLeave={() => this.handleMouseLeave('eflux')}
>
{EfluxLogo}
</a>
</div>
<div className={growlOpen ? "growl-tooltip growl-message open" : "growl-tooltip growl-message"}>
{growlMessage}
</div>
<div className="eflux-nav">
{isFullscreen &&
<div
className="fullscreen-close"
onMouseEnter={() => this.handleMouseEnter('close')}
onMouseLeave={() => this.handleMouseLeave('close')}
>
{EfluxClose}
</div>
}
<span
onMouseEnter={() => this.handleMouseEnter('play')}
onMouseLeave={() => this.handleMouseLeave('play')}
>
<PlayButton playing={playing} />
</span>
<div
className="transcript-icon"
onMouseEnter={() => this.handleMouseEnter('transcript')}
onMouseLeave={() => this.handleMouseLeave('transcript')}
onClick={() => actions.viewer.toggleComponent('transcript')}
>
{TranscriptIcon}
</div>
</div>
<div className={
this.state.close
? "growl-tooltip tooltip-close hover"
: "growl-tooltip tooltip-close"
}>
{'Close fullscreen player'}
</div>
<div className={
this.state.eflux
? "growl-tooltip tooltip-eflux hover"
: "growl-tooltip tooltip-eflux"
}>
{'Back to e-flux'}
</div>
<div className={
(!showingTranscriptTooltip && this.state.play)
? "growl-tooltip tooltip-play hover"
: "growl-tooltip tooltip-play"
}>
{this.state.playMessage}
</div>
<div className={
showingTranscriptTooltip
? "growl-tooltip tooltip-transcript hover"
: "growl-tooltip tooltip-transcript"
}
onClick={() => actions.viewer.toggleComponent('transcript')}
>
{'Read the Transcript'}
</div>
</div>
)
}
}
const mapStateToProps = state => ({
navStyle: state.viewer.navStyle,
navGradient: state.viewer.navGradient,
playing: state.audio.playing,
transcriptOpen: state.viewer.transcript,
growlOpen: state.viewer.growlOpen,
growlMessage: state.viewer.growlMessage,
atEndOfSection: state.viewer.atEndOfSection,
currentSection: state.viewer.currentSection,
isFullscreen: state.viewer.isFullscreen,
})
export default connect(mapStateToProps)(EfluxChrome)
|