import React from 'react'
import marked from 'marked'
import Content from './Content'
import Controls from './Controls'
import { selectTypeFromPathWithPoster } from '../../common/utilities'
/*
* Inside the SourceOverlay, both the currently displaying media and language
* can be changed by the user. These are both managed in this component's React
* state.
*/
class SourceOverlay extends React.Component {
constructor () {
super()
this.state = { mediaIdx: 0, langIdx: 0 }
this.onShiftGallery = this.onShiftGallery.bind(this)
}
getTypeCounts (media) {
return media.reduce(
(acc, vl) => {
acc[vl.type] += 1
return acc
},
{ Image: 0, Video: 0, Text: 0 }
)
}
onShiftGallery (shift) {
// no more left
if (this.state.mediaIdx === 0 && shift === -1) return
// no more right
if (this.state.mediaIdx === this.props.source.paths.length - 1 && shift === 1) return
this.setState({ mediaIdx: this.state.mediaIdx + shift })
}
switchLanguage (idx) {
this.setState({ langIdx: idx })
}
renderContent (source) {
const { url, title, paths, date, type, poster, description } = source
const shortenedTitle = title.substring(0, 100)
return (
perm_media{type} today{date}{shortenedTitle}
Evidence type
: null}
{type ? Date Published
: null}
{date ? Link
: null}
{url ? linkLink to original URL : null}