summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/paragraph/components
diff options
context:
space:
mode:
Diffstat (limited to 'animism-align/frontend/views/paragraph/components')
-rw-r--r--animism-align/frontend/views/paragraph/components/paragraph.types.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/animism-align/frontend/views/paragraph/components/paragraph.types.js b/animism-align/frontend/views/paragraph/components/paragraph.types.js
new file mode 100644
index 0000000..c200a19
--- /dev/null
+++ b/animism-align/frontend/views/paragraph/components/paragraph.types.js
@@ -0,0 +1,44 @@
+import React, { Component } from 'react'
+
+import actions from '../../../actions'
+
+export const Paragraph = ({ paragraph, selectedParagraph, selectedAnnotation, onAnnotationClick, onDoubleClick }) => {
+ const className = paragraph.type
+ if (selectedParagraph) className += ' selected'
+ return (
+ <div
+ className={className}
+ onDoubleClick={e => onDoubleClick(e, paragraph)}
+ >
+ {paragraph.annotations.map(annotation => (
+ <span
+ key={annotation.id}
+ className={annotation.id === selectedAnnotation ? 'selected' : ''}
+ onClick={e => onAnnotationClick(e, paragraph, annotation)}
+ >
+ {annotation.text}
+ </span>
+ ))}
+ </div>
+ )
+}
+
+export const ParagraphHeader = ({ paragraph, selectedParagraph, selectedAnnotation, onAnnotationClick, onDoubleClick }) => {
+ const className = selectedParagraph ? 'header selected' : 'header'
+ const text = paragraph.annotations.map(annotation => annotation.text).join(' ')
+ console.log(text)
+ return (
+ <div
+ className={className}
+ onDoubleClick={e => onDoubleClick(e, paragraph)}
+ >
+ {text}
+ </div>
+ )
+}
+
+export const ParagraphElementLookup = {
+ paragraph: Paragraph,
+ blockquote: Paragraph,
+ header: ParagraphHeader,
+}