From 4ea856fa18a09f6752ecb6dfece56193fd9c8f97 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Wed, 19 Feb 2020 18:19:26 +1300 Subject: [PATCH] enables inline PDFs for sources --- src/common/utilities.js | 13 ++++++++++--- src/components/Overlay/Content.js | 6 +++++- src/components/presentational/Card/Source.js | 7 ++++++- src/scss/overlay.scss | 5 +++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/common/utilities.js b/src/common/utilities.js index 55820ba..85df393 100644 --- a/src/common/utilities.js +++ b/src/common/utilities.js @@ -153,17 +153,24 @@ export function selectTypeFromPath (path) { return { type, path } } -export function selectTypeFromPathWithPoster (path, poster) { +export function typeForPath (path) { let type + path = path.trim() switch (true) { - case /\.(png|jpg)$/.test(path): + case /\.((png)|(jpg))$/.test(path): type = 'Image'; break case /\.(mp4)$/.test(path): type = 'Video'; break case /\.(md)$/.test(path): type = 'Text'; break + case /\.(pdf)$/.test(path): + type = 'Document'; break default: type = 'Unknown'; break } - return { type, path, poster } + return type +} + +export function selectTypeFromPathWithPoster (path, poster) { + return { type: typeForPath(path), path, poster } } diff --git a/src/components/Overlay/Content.js b/src/components/Overlay/Content.js index 8c3d669..6dab3cf 100644 --- a/src/components/Overlay/Content.js +++ b/src/components/Overlay/Content.js @@ -10,7 +10,7 @@ export default ({ media, viewIdx, translations, switchLanguage, langIdx }) => { const shiftW = el ? el.getBoundingClientRect().width : 0 function renderMedia (media) { - const { path, type, poster } = media + let { path, type, poster } = media switch (type) { case 'Image': return ( @@ -53,6 +53,10 @@ export default ({ media, viewIdx, translations, switchLanguage, langIdx }) => { /> ) + case 'Document': + return ( +