diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-10-28 19:06:49 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-10-28 19:06:49 +0100 |
| commit | 35166bde2d54cc06d0095e59890226ea177cd7d8 (patch) | |
| tree | fd057851568b55a65cee7eeebbbc37843d11362d /animism-align/frontend/app/views/align/components/sidebar/tableOfContents.component.js | |
| parent | c6b2d664421f12f8c137adb1b9930a0ba3e79037 (diff) | |
convert align sidebar into a section TOC navigator
Diffstat (limited to 'animism-align/frontend/app/views/align/components/sidebar/tableOfContents.component.js')
| -rw-r--r-- | animism-align/frontend/app/views/align/components/sidebar/tableOfContents.component.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/animism-align/frontend/app/views/align/components/sidebar/tableOfContents.component.js b/animism-align/frontend/app/views/align/components/sidebar/tableOfContents.component.js new file mode 100644 index 0000000..24cb59c --- /dev/null +++ b/animism-align/frontend/app/views/align/components/sidebar/tableOfContents.component.js @@ -0,0 +1,31 @@ +import React, { Component } from 'react' +// import { Link } from 'react-router-dom' +import { bindActionCreators } from 'redux' +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") + console.log(this.props.annotation) + return ( + <div className="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) |
