summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/viewer.container.js
blob: 38f08e4c86f9e2525d04a0ffeb68eee185bedec0 (plain)
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
import React, { Component } from 'react'
import { Route } from 'react-router-dom'
import { connect } from 'react-redux'

import './viewer.fonts.css'
import './viewer.css'
import './nav/nav.css'
import './nav/eflux.css'
import './sections/sections.css'
import './sections/share.css'
import './sections/subscribe.css'
import './sections/footnotes.css'
import './transcript/transcript.css'
import './checklist/checklist.css'
import './checklist/credits.css'
import './modals/modals.css'
import './forms/forms.css'
import './player/player.container.css'
import './player/player.fullscreen.css'
import './player/player.transcript.css'
import './player/components.media/media.css'

import { Loader } from 'app/common'

import NavParent from './nav/nav.parent'
import ViewerSections from './sections/viewer.sections'
import ViewerRouter from './nav/viewer.router'
import EfluxChrome from './nav/eflux.chrome'
import Player from './player/player.container'
import Transcript from './transcript/transcript.container'
import Checklist from './checklist/checklist.container'
import VitrineModal from './modals/modals.vitrine'

class ViewerContainer extends Component {
  render() {
    const { loaded, viewer, playing } = this.props
    if (!loaded) {
      return <div className='viewer loading'><Loader /></div>
    }
    let className = 'viewer'
    if (playing) {
      className += ' audio-playing'
    } else {
      className += ' audio-paused'
    }
    if (viewer.checklist || viewer.credits) {
      className += ' checklist-open'
    } else {
      if (viewer.transcript) className += ' transcript-open'
      if (viewer.nav) className += ' nav-open'
    }
    if (viewer.share) {
      className += ' share-open'
    } else if (viewer.subscribe) {
      className += ' subscribe-open'
    } else if (viewer.footnotes) {
      className += ' footnotes-open'
    }
    return (
      <div>
        <div className='viewer-parent'>
          <EfluxChrome />
          <div className={className}>
            <Player />
            <NavParent />
            <ViewerSections />
            <Transcript />
            <Checklist />
            <Route exact path='/viewer/:component/' component={ViewerRouter} />
          </div>
          <VitrineModal />
        </div>
      </div>
    )
  }
}

const mapStateToProps = state => ({
  loaded: (
    !!state.annotation.index.lookup &&
    !!state.paragraph.index.lookup &&
    !!state.media.index.lookup &&
    !!state.viewer.sections.length
  ),
  playing: state.audio.playing,
  viewer: state.viewer,
})

export default connect(mapStateToProps)(ViewerContainer)