diff --git a/src/components/presentational/covers/TemplateCover.js b/src/components/TemplateCover.js similarity index 57% rename from src/components/presentational/covers/TemplateCover.js rename to src/components/TemplateCover.js index 21ac7e4..17614c6 100644 --- a/src/components/presentational/covers/TemplateCover.js +++ b/src/components/TemplateCover.js @@ -1,10 +1,16 @@ import React from 'react' import { connect } from 'react-redux' -import MediaOverlay from '../../Overlay/Media' import marked from 'marked' +import MediaOverlay from './Overlay/Media' const MEDIA_HIDDEN = -2 +/** + * Manages the presentation of props that come in from the store's app.cover. + * These are documented in docs/custom-cover.md. + * The component is a bit of a mess, keeping a lot of internal state and using + * a couple of weird offset calculations... but it works for the time being. + */ class TemplateCover extends React.Component { constructor (props) { super(props) @@ -17,15 +23,61 @@ class TemplateCover extends React.Component { if (index < headerEndIndex) { return this.props.cover.headerVideos[index] } else if (index >= 0) { - return this.props.cover.videos[index] + return this.props.cover.videos[index - headerEndIndex] } else { return null } } - render () { + onVideoClickHandler (index) { + const buffer = this.props.cover.headerVideos ? this.props.cover.headerVideos.length : 0 + return () => { + this.setState({ + video: index + buffer + }) + } + } + + renderHeaderVideos () { const { headerVideos } = this.props.cover - var video = this.getVideo(this.state.video, headerVideos.length || 0) + return ( +
app.cover
+