mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 21:38:35 +03:00
basic photobook support
This commit is contained in:
51
src/components/Photobook.jsx
Normal file
51
src/components/Photobook.jsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import React from 'react'
|
||||
|
||||
class Photobook extends React.Component {
|
||||
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state ={
|
||||
isLoading: true,
|
||||
isLoaded: false
|
||||
}
|
||||
this.loadImgs = this.loadImgs.bind(this)
|
||||
}
|
||||
|
||||
loadImgs() {
|
||||
console.log(this.props.src)
|
||||
Promise.resolve()
|
||||
.then(fetch(this.props.src))
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
})
|
||||
.then(() => {
|
||||
this.setState({ isLoading: false, isLoaded: true })
|
||||
})
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (this.state.isLoading) this.loadImgs()
|
||||
}
|
||||
|
||||
// componentWillReceiveProps(nextProps) {
|
||||
//
|
||||
// if (!src.length) return this.setState({ isLoading: false, isLoaded: false })
|
||||
// this.setState({ isLoading: true, isLoaded: false })
|
||||
// }
|
||||
|
||||
render() {
|
||||
if (this.state.isLoading) {
|
||||
return <div>Loading</div>
|
||||
}
|
||||
return <div>Ciao</div>
|
||||
}
|
||||
}
|
||||
|
||||
Photobook.propTypes = {
|
||||
loader: false,
|
||||
unloader: false,
|
||||
src: []
|
||||
}
|
||||
|
||||
export default Photobook
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import Img from 'react-image'
|
||||
import Photobook from './Photobook.jsx'
|
||||
import { Player } from 'video-react'
|
||||
import Spinner from './presentational/Spinner'
|
||||
import NoSource from './presentational/NoSource'
|
||||
@@ -25,23 +26,33 @@ class SourceOverlay extends React.Component {
|
||||
}
|
||||
|
||||
renderPhoto() {
|
||||
const imageExts = ['.jpg', '.png']
|
||||
const extraUrls = imageExts.map(ext => `${this.props.source.path}${ext}`)
|
||||
const possibleUrls = [ this.props.source.path, ...extraUrls ]
|
||||
return (
|
||||
<div className='source-image-container'>
|
||||
<Img
|
||||
className='source-image'
|
||||
src={possibleUrls}
|
||||
src={this.props.source.paths}
|
||||
loader={<Spinner />}
|
||||
unloader={<NoSource failedUrls={possibleUrls} />}
|
||||
unloader={<NoSource failedUrls={this.props.source.paths} />}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
renderPhotobook() {
|
||||
return this.renderError()
|
||||
return (
|
||||
<div className='source-image-container'>
|
||||
{this.props.source.paths.map((url, idx) => (
|
||||
<Img
|
||||
key={idx}
|
||||
className='source-image'
|
||||
src={url}
|
||||
loader={<Spinner />}
|
||||
unloader={<NoSource failedUrls={[this.props.source.path]} />}
|
||||
/>
|
||||
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
renderError() {
|
||||
|
||||
@@ -20,6 +20,8 @@ const CardSource = ({ source, isLoading, onClickHandler }) => {
|
||||
return 'videocam'
|
||||
case 'Photo':
|
||||
return 'photo'
|
||||
case 'Photobook':
|
||||
return 'photo_album'
|
||||
default:
|
||||
return 'help'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user