summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/paragraph
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-17 19:50:25 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-17 19:50:25 +0200
commit136efc89b1006990e99039c5320c31cd2f29425e (patch)
tree893916e7326c06a5ebaf6e56c2a4611e763848f9 /animism-align/frontend/views/paragraph
parent649fec4f153ea1c72d2fa3ea89d7d3998237de3a (diff)
properly update display of annotation when adjusting time
Diffstat (limited to 'animism-align/frontend/views/paragraph')
-rw-r--r--animism-align/frontend/views/paragraph/components/paragraphTypes/index.js5
-rw-r--r--animism-align/frontend/views/paragraph/components/paragraphTypes/paragraphTypes.image.js17
2 files changed, 22 insertions, 0 deletions
diff --git a/animism-align/frontend/views/paragraph/components/paragraphTypes/index.js b/animism-align/frontend/views/paragraph/components/paragraphTypes/index.js
index 04546f6..bf68ed0 100644
--- a/animism-align/frontend/views/paragraph/components/paragraphTypes/index.js
+++ b/animism-align/frontend/views/paragraph/components/paragraphTypes/index.js
@@ -8,10 +8,15 @@ import {
MediaVideo
} from './paragraphTypes.video'
+import {
+ MediaImage
+} from './paragraphTypes.image'
+
export const ParagraphElementLookup = {
paragraph: React.memo(Paragraph),
hidden: React.memo(Paragraph),
blockquote: React.memo(Paragraph),
header: React.memo(ParagraphHeader),
video: React.memo(MediaVideo),
+ image: React.memo(MediaImage),
}
diff --git a/animism-align/frontend/views/paragraph/components/paragraphTypes/paragraphTypes.image.js b/animism-align/frontend/views/paragraph/components/paragraphTypes/paragraphTypes.image.js
new file mode 100644
index 0000000..36c72e9
--- /dev/null
+++ b/animism-align/frontend/views/paragraph/components/paragraphTypes/paragraphTypes.image.js
@@ -0,0 +1,17 @@
+import React, { Component } from 'react'
+
+export const MediaImage = ({ paragraph, media, currentParagraph, currentAnnotation, onAnnotationClick, onDoubleClick }) => {
+ if (!media.lookup) return <div />
+ const className = currentParagraph ? 'media image current' : 'media image'
+ const annotation = paragraph.annotations[0]
+ const item = media.lookup[annotation.settings.media_id]
+ if (!item) return <div>Media not found: {annotation.settings.media_id}</div>
+ return (
+ <div
+ className={className}
+ onDoubleClick={e => onDoubleClick(e, paragraph)}
+ >
+ <img src={item.settings.display.url} />
+ </div>
+ )
+}