From c05f49f1cd5683b868c82e453a76aec185bcbe01 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Oct 2020 15:19:17 +0200 Subject: refactor viewer sections list, share, subscribe, subscription form --- .../views/viewer/sections/viewer.sections.list.js | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js (limited to 'animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js') diff --git a/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js b/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js new file mode 100644 index 0000000..34a944d --- /dev/null +++ b/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js @@ -0,0 +1,86 @@ +import React, { Component } from 'react' +import { connect } from 'react-redux' + +import actions from 'app/actions' +import { ROMAN_NUMERALS } from 'app/constants' +import { timestamp } from 'app/utils' +import { thumbnailURL, sectionProgressPercentage } from 'app/utils/annotation.utils' +import { SpeakerIcon } from '../nav/viewer.icons' + +class ViewerSectionsList extends Component { + constructor(props) { + super(props) + this.scrollRef = React.createRef() + this.handleWheel = this.handleWheel.bind(this) + } + shouldComponentUpdate(nextProps) { + if (nextProps.nav !== this.props.nav) return true + return nextProps.nav + } + handleWheel(e) { + let delta = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? e.deltaY : e.deltaX + this.scrollRef.current.scrollLeft += delta + } + render() { + const { play_ts, sections, currentSection } = this.props + return ( +
this.handleWheel(e)} + > + {sections.map(section => { + // console.log(section) + const media = section.media.length ? section.media[0].media : null + const { no_audio, section_nav_color } = section + const progress = sectionProgressPercentage(section, play_ts) + return ( +
actions.viewer.seekToSection(section)} + > +
+
+ {!no_audio && +
+
+ {timestamp(section.duration)} +
+
+ {SpeakerIcon} +
+
+
+
+
+ } +
+
+ {ROMAN_NUMERALS[section.index]}
+ {section.title} +
+
+ {section.mediaLabels} +
+
+
+ ) + })} +
+ ) + } +} + +const mapStateToProps = state => ({ + nav: state.viewer.nav, + play_ts: state.audio.play_ts, + sections: state.viewer.sections, + currentSection: state.viewer.currentSection, +}) + +export default connect(mapStateToProps)(ViewerSectionsList) -- cgit v1.2.3-70-g09d2