From 108d4835d0942faf2305e702d698ae88a45022a5 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 18 Sep 2020 18:48:23 +0200 Subject: pullquote paragraph type --- .../views/viewer/player/components.inline/index.js | 2 ++ .../viewer/player/components.inline/inline.text.js | 29 ++++++++++++++++++++++ .../transcript/components/elementTypes.text.js | 28 +++++++++++++++++++++ .../views/viewer/transcript/components/index.js | 3 ++- 4 files changed, 61 insertions(+), 1 deletion(-) (limited to 'animism-align/frontend/app/views/viewer') diff --git a/animism-align/frontend/app/views/viewer/player/components.inline/index.js b/animism-align/frontend/app/views/viewer/player/components.inline/index.js index 0e26df6..16e3044 100644 --- a/animism-align/frontend/app/views/viewer/player/components.inline/index.js +++ b/animism-align/frontend/app/views/viewer/player/components.inline/index.js @@ -4,6 +4,7 @@ import { Paragraph, SectionHeading, HeadingText, + Pullquote, } from './inline.text' import { @@ -31,6 +32,7 @@ export const inlineComponents = { intro_paragraph: React.memo(Paragraph), hidden: React.memo(Paragraph), blockquote: React.memo(Paragraph), + pullquote: React.memo(Pullquote), section_heading: React.memo(SectionHeading), heading_text: React.memo(HeadingText), big_text: React.memo(Paragraph), diff --git a/animism-align/frontend/app/views/viewer/player/components.inline/inline.text.js b/animism-align/frontend/app/views/viewer/player/components.inline/inline.text.js index 91ea506..70cf91a 100644 --- a/animism-align/frontend/app/views/viewer/player/components.inline/inline.text.js +++ b/animism-align/frontend/app/views/viewer/player/components.inline/inline.text.js @@ -26,6 +26,35 @@ export const Paragraph = ({ paragraph, currentParagraph, currentAnnotation, onAn ) } +export const Pullquote = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick }) => { + if (paragraph.hidden) return null + let className = paragraph.type + if (className !== 'paragraph') className += ' paragraph' + if (currentParagraph) className += ' current' + const firstAnnotation = paragraph.annotations[0] + return ( +
+
onAnnotationClick(e, paragraph, firstAnnotation)}>{SpeakerIcon}
+ {paragraph.annotations.map(annotation => ( + onAnnotationClick(e, paragraph, firstAnnotation)} + dangerouslySetInnerHTML={{ __html: ' ' + annotation.text + ' ' }} + /> + ))} +
+ ) +} + export const SectionHeading = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick }) => { if (paragraph.hidden) return null let className = currentParagraph ? 'section_heading current' : 'section_heading' diff --git a/animism-align/frontend/app/views/viewer/transcript/components/elementTypes.text.js b/animism-align/frontend/app/views/viewer/transcript/components/elementTypes.text.js index 5ea12da..49cbdd3 100644 --- a/animism-align/frontend/app/views/viewer/transcript/components/elementTypes.text.js +++ b/animism-align/frontend/app/views/viewer/transcript/components/elementTypes.text.js @@ -24,6 +24,34 @@ export const Paragraph = ({ paragraph, currentParagraph, currentAnnotation, onAn ) } +export const Pullquote = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick }) => { + let className = paragraph.type + if (className !== 'paragraph') className += ' paragraph' + if (currentParagraph) className += ' current' + return ( +
+ {paragraph.annotations.map(annotation => ( + onAnnotationClick(e, paragraph, annotation)} + dangerouslySetInnerHTML={{ __html: ' ' + annotation.text + ' ' }} + /> + ))} +
+ ) +} + export const ParagraphHeading = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick }) => { let className = currentParagraph ? 'section_heading current' : 'section_heading' const text = paragraph.annotations.map(annotation => annotation.text).join(' ') diff --git a/animism-align/frontend/app/views/viewer/transcript/components/index.js b/animism-align/frontend/app/views/viewer/transcript/components/index.js index e71a98f..35084e7 100644 --- a/animism-align/frontend/app/views/viewer/transcript/components/index.js +++ b/animism-align/frontend/app/views/viewer/transcript/components/index.js @@ -1,7 +1,7 @@ import React from 'react' import { - Paragraph, ParagraphHeading, HiddenParagraph + Paragraph, ParagraphHeading, HiddenParagraph, Pullquote } from './elementTypes.text' import { @@ -21,6 +21,7 @@ export const transcriptElementLookup = { intro_paragraph: React.memo(Paragraph), big_text: React.memo(Paragraph), blockquote: React.memo(Paragraph), + pullquote: React.memo(Pullquote), hidden: React.memo(Paragraph), heading_text: React.memo(HiddenParagraph), -- cgit v1.2.3-70-g09d2