summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/sections/viewer.sections.js
blob: 085749fd13c7ce16a3afa4f89f2052196af4d83c (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
import React, { Component } from 'react'
// import { Link } from 'react-router-dom'
import { connect } from 'react-redux'

import actions from 'app/actions'
import ViewerSectionsNav from './viewer.sections.nav'
import { ROMAN_NUMERALS } from 'app/constants'
import { thumbnailURL } from 'app/utils/annotation.utils'

class ViewerSections extends Component {
  componentDidMount() {
  }
  
  handleSectionSelection(section) {
    actions.audio.seek(section.start_ts)
    actions.viewer.hideSection('nav')
  }

  render() {
    const { sections } = this.props
    return (
      <div className="viewer-sections">
        {sections.map(section => {
          // console.log(section)
          return (
            <div
              className="viewer-section"
              key={section.index}
              onClick={() => this.handleSectionSelection(section)}
            >
              <div>
                <div className="section-thumbnail" style={{
                  backgroundImage: section.media.length && 'url(' + thumbnailURL(section.media[0].media) + ')',
                }}/>
                <div className="section-title">
                  {ROMAN_NUMERALS[section.index]}<br />
                  {section.title}
                </div>
                <div className="section-media">
                  {section.mediaLabels}
                </div>
              </div>
            </div>
          )
        })}
        <ViewerSectionsNav />
      </div>
    )
  }
}

const mapStateToProps = state => ({
  sections: state.viewer.sections,
})

export default connect(mapStateToProps)(ViewerSections)