summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/editor/sidebar/components/tableOfContents.component.js
diff options
context:
space:
mode:
Diffstat (limited to 'animism-align/frontend/app/views/editor/sidebar/components/tableOfContents.component.js')
-rw-r--r--animism-align/frontend/app/views/editor/sidebar/components/tableOfContents.component.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/editor/sidebar/components/tableOfContents.component.js b/animism-align/frontend/app/views/editor/sidebar/components/tableOfContents.component.js
new file mode 100644
index 0000000..239dc69
--- /dev/null
+++ b/animism-align/frontend/app/views/editor/sidebar/components/tableOfContents.component.js
@@ -0,0 +1,30 @@
+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.length && <div className="no-sections">No sections found</div>}
+ {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)