diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index d734de0..11263d6 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -154,7 +154,18 @@ function mapDispatchToProps(dispatch) { }; } +function injectSource(id) { + return state => ({ + ...state, + app: { + ...state.app, + source: state.domain.sources[id] + } + }) +} + export default connect( state => state, + // injectSource('src7'), mapDispatchToProps, )(Dashboard); diff --git a/src/components/SourceOverlay.jsx b/src/components/SourceOverlay.jsx index e5a79f6..02f40bf 100644 --- a/src/components/SourceOverlay.jsx +++ b/src/components/SourceOverlay.jsx @@ -64,24 +64,65 @@ function SourceOverlay ({ source, onCancel }) { ) } - function _renderPath(path) { + function toMedia(path) { + let type; switch (true) { case /\.(png|jpg)$/.test(path): - return renderImage(path) + type = 'Image'; break case /\.(mp4)$/.test(path): - return renderVideo(path) + type = 'Video'; break case /\.(md)$/.test(path): + type = 'Text'; break + default: + type = 'Unknown'; break + } + return { type, path } + } + + function getTypeCounts(media) { + let counts = { Image: 0, Video: 0, Text: 0 } + media.forEach(m => { + counts[m.type] += 1 + }) + return counts + } + + function _renderPath(media) { + const { path, type } = media + switch (type) { + case 'Image': + return renderImage(path) + case 'Video': + return renderVideo(path) + case 'Text': return renderText(path) default: - console.log('unsupported extension') return renderNoSupport(path.split('.')[1]) } } - function _renderContent() { + function _renderCounts(counts) { + const strFor = type => + counts[type] > 0 ? + `${counts[type]} ${type.toLowerCase()}${counts[type] > 1 ? 's': ''}` + : '' + const img = strFor('Image') + const vid = strFor('Video') + const txt = strFor('Text') + + return ( +