blob: 8fb3d54e7aa7e128e53209f7475f87b2805fe1fd (
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
|
import React, { Component } from 'react'
// import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
import { ROMAN_NUMERALS } from 'app/constants'
import actions from 'app/actions'
class TableOfContents extends Component {
render() {
const { loading, order, lookup } = this.props.annotation
if (loading || !order) return null
const sectionIds = order.filter(id => lookup[id].type === "section_heading")
return (
<div className="sidebar-content toc">
{sectionIds.map((id, i) => (
<div key={id} onClick={() => actions.align.setScrollPosition(lookup[id].start_ts)}>
{ROMAN_NUMERALS[i]}{'. '}{lookup[id].text}
</div>
))}
</div>
)
}
}
const mapStateToProps = state => ({
annotation: state.annotation.index,
})
export default connect(mapStateToProps)(TableOfContents)
|