From 49bf241d0fa275053424db3458a057de7b9d418f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 21 Nov 2020 16:44:07 +0100 Subject: messaging if rest of chapters are disabled. grayscale all disabled media --- .../views/viewer/sections/viewer.sections.list.js | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) (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 index 0d34a45..8fc1238 100644 --- a/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js +++ b/animism-align/frontend/app/views/viewer/sections/viewer.sections.list.js @@ -2,7 +2,7 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import actions from 'app/actions' -import { ROMAN_NUMERALS } from 'app/constants' +import { ROMAN_NUMERALS, SECTION_LIMITED_MESSAGE } from 'app/constants' import { timestamp } from 'app/utils' import { thumbnailURL, sectionProgressPercentage } from 'app/utils/annotation.utils' import { SpeakerIcon } from '../nav/viewer.icons' @@ -10,6 +10,9 @@ import { SpeakerIcon } from '../nav/viewer.icons' const SECTION_WIDTH = 13 * 16 class ViewerSectionsList extends Component { + state = { + selectedSectionIndex: -1, + } constructor(props) { super(props) this.scrollRef = React.createRef() @@ -33,8 +36,20 @@ class ViewerSectionsList extends Component { let delta = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? e.deltaY : e.deltaX this.scrollRef.current.scrollLeft += delta } + handleSectionClick(e, section) { + if (this.props.onlyEnableFirstSection) { + this.setState({ selectedSectionIndex: section.index }) + clearTimeout(this.warningFadeTimeout) + this.warningFadeTimeout = setTimeout(() => { + this.setState({ selectedSectionIndex: -1 }) + }, 10000) + } else { + actions.viewer.seekToSection(section) + } + } render() { - const { play_ts, sections, media, currentSection } = this.props + const { play_ts, sections, media, currentSection, onlyEnableFirstSection } = this.props + const { selectedSectionIndex } = this.state return (
actions.viewer.seekToSection(section)} + onClick={e => this.handleSectionClick(e, section)} > -
+
@@ -85,6 +100,11 @@ class ViewerSectionsList extends Component { {section.mediaLabels}
+ {!!(onlyEnableFirstSection && section.index) && ( +
+ {SECTION_LIMITED_MESSAGE} +
+ )}
) })} @@ -96,6 +116,7 @@ class ViewerSectionsList extends Component { const mapStateToProps = state => ({ media: state.media.index, nav: state.viewer.nav, + onlyEnableFirstSection: state.viewer.onlyEnableFirstSection, play_ts: state.audio.play_ts, sections: state.viewer.sections, currentSection: state.viewer.currentSection, -- cgit v1.2.3-70-g09d2