diff --git a/src/components/SourceOverlay.jsx b/src/components/SourceOverlay.jsx
index 8f6da4e..2999bfe 100644
--- a/src/components/SourceOverlay.jsx
+++ b/src/components/SourceOverlay.jsx
@@ -62,6 +62,12 @@ class SourceOverlay extends React.Component {
)
}
+ renderNoSupport(ext) {
+ return (
+
+ )
+ }
+
renderTestimony() {
return (
@@ -70,21 +76,44 @@ class SourceOverlay extends React.Component {
)
}
- _renderSwitch() {
- switch(this.props.source.type) {
- case 'Video':
- return this.renderVideo()
- case 'Photo':
- return this.renderPhoto()
- case 'Photobook':
- return this.renderPhotobook()
- case 'Eyewitness Testimony':
- return this.renderTestimony()
+ _renderPath(path) {
+ // render conditionally based on the extension
+ switch (true) {
+ case /\.(png|jpg)$/.test(path):
+ console.log('image')
+ return
{path}
+ case /\.(mp4)$/.test(path):
+ console.log('video')
+ return
{path}
+ case /\.(md)$/.test(path):
+ console.log('text')
+ return
{path}
default:
- return this.renderError()
+ console.log('unsupported extension')
+ return this.renderNoSupport(path.split('.')[1])
}
}
+ _renderContent() {
+ return (
+
+ {this.props.source.paths.map(this._renderPath)}
+
+ )
+ // switch(this.props.source.type) {
+ // case 'Video':
+ // return this.renderVideo()
+ // case 'Photo':
+ // return this.renderPhoto()
+ // case 'Photobook':
+ // return this.renderPhotobook()
+ // case 'Eyewitness Testimony':
+ // return this.renderTestimony()
+ // default:
+ // return this.renderError()
+ // }
+ }
+
render() {
if (typeof(this.props.source) !== 'object') {
return this.renderError()
@@ -100,7 +129,7 @@ class SourceOverlay extends React.Component {
{this.props.source.id}
- {this._renderSwitch()}
+ {this._renderContent()}
diff --git a/src/components/presentational/CardSource.js b/src/components/presentational/CardSource.js
index 6d4aacc..b3bca21 100644
--- a/src/components/presentational/CardSource.js
+++ b/src/components/presentational/CardSource.js
@@ -35,12 +35,21 @@ const CardSource = ({ source, isLoading, onClickHandler }) => {
)
}
+ const isImgUrl = /\.(jpg|png)$/
let thumbnail = source.thumbnail
- if (!thumbnail || thumbnail === '') {
+
+ if (!thumbnail || thumbnail === '' || !thumbnail.match(isImgUrl)) {
// default to first image in paths, null if no images
- const imgs = source.paths.filter(p => p.match(/\.(jpg|png)$/))
+ const imgs = source.paths.filter(p => p.match(isImgUrl))
thumbnail = imgs.length > 0 ? imgs[0] : null
}
+ console.log(thumbnail)
+
+ const fallbackIcon = (
+
+ {renderIconText(source.type)}
+
+ )
return (
@@ -49,12 +58,15 @@ const CardSource = ({ source, isLoading, onClickHandler }) => {
: (
onClickHandler(source)}>
{!!thumbnail ? (
-

- ) : (
-
- {renderIconText(source.type)}
-
- )}
+

}
+ unloader={fallbackIcon}
+ width={30}
+ height={30}
+ />
+ ) : fallbackIcon}
{source.id}
)}
diff --git a/src/components/presentational/Spinner.js b/src/components/presentational/Spinner.js
index 062bd83..f3c483c 100644
--- a/src/components/presentational/Spinner.js
+++ b/src/components/presentational/Spinner.js
@@ -1,8 +1,8 @@
import React from 'react';
-const Spinner = () => {
+const Spinner = ({ small }) => {
return (
-
+
diff --git a/src/scss/loading.scss b/src/scss/loading.scss
index 1fdcff6..063c622 100644
--- a/src/scss/loading.scss
+++ b/src/scss/loading.scss
@@ -42,6 +42,12 @@ https://github.com/tobiasahlin/SpinKit/blob/master/LICENSE
position: relative;
margin: 10px auto;
+
+ &.small {
+ width: 15px;
+ height: 15px;
+ margin: 5px 20px 5px 10px;
+ }
}
.double-bounce, .double-bounce-overlay {