From fe515fa4bc940183ba9253e67461c1f009a5d94b Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 26 Aug 2020 22:28:13 +0200 Subject: times and stuff on the section nav --- .../app/views/viewer/sections/viewer.sections.js | 42 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/sections/viewer.sections.js') diff --git a/animism-align/frontend/app/views/viewer/sections/viewer.sections.js b/animism-align/frontend/app/views/viewer/sections/viewer.sections.js index 4bb61ec..05eef9c 100644 --- a/animism-align/frontend/app/views/viewer/sections/viewer.sections.js +++ b/animism-align/frontend/app/views/viewer/sections/viewer.sections.js @@ -4,27 +4,52 @@ import { connect } from 'react-redux' import actions from 'app/actions' import ViewerSectionsNav from './viewer.sections.nav' -import { ROMAN_NUMERALS } from 'app/constants' +import { ROMAN_NUMERALS, CURTAIN_COLOR_LOOKUP } from 'app/constants' +import { clamp, timestamp, floatInRange, floatLT } from 'app/utils' import { thumbnailURL } from 'app/utils/annotation.utils' +import { SpeakerIcon } from '../nav/viewer.icons' class ViewerSections extends Component { + shouldComponentUpdate(nextProps) { + if (nextProps.nav !== this.props.nav) return true + return nextProps.nav + } render() { - const { sections } = this.props + const { play_ts, sections, currentSection } = this.props return (
{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 = Math.round(sectionProgress(section, play_ts) * 100) return (
actions.viewer.seekToSection(section)} >
+ backgroundImage: media && 'url(' + thumbnailURL(media) + ')', + }}> + {!no_audio && +
+
+ {timestamp(section.duration)} +
+
+ {SpeakerIcon} +
+
+
+
+
+ } +
{ROMAN_NUMERALS[section.index]}
{section.title} @@ -43,8 +68,15 @@ class ViewerSections extends Component { } } +const sectionProgress = (section, play_ts) => { + return (clamp(play_ts, section.start_ts, section.end_ts) - section.start_ts) / section.duration +} + 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)(ViewerSections) -- cgit v1.2.3-70-g09d2