import React, { Component } from 'react'
import { ROMAN_NUMERALS } from 'app/constants'
import { SpeakerIcon } from '../../nav/viewer.icons'
export const Paragraph = ({ paragraph, currentParagraph, currentAnnotation, onAnnotationClick }) => {
if (paragraph.hidden) return null
if (paragraph.annotations.length === 0) 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 => {
if (annotation.type === 'footnote') {
return (
onAnnotationClick(e, paragraph, annotation)}
dangerouslySetInnerHTML={{ __html: annotation.footnote_id }}
/>
)
}
return (
onAnnotationClick(e, paragraph, annotation)}
dangerouslySetInnerHTML={{ __html: ' ' + annotation.text + ' ' }}
/>
)
})}
)
}
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 => {
if (annotation.type === 'footnote') {
return (
onAnnotationClick(e, paragraph, annotation)}
dangerouslySetInnerHTML={{ __html: annotation.footnote_id }}
/>
)
}
const isPullquoteCredit = annotation.type === 'pullquote_credit'
return (
!isPullquoteCredit && onAnnotationClick(e, paragraph, annotation)}
dangerouslySetInnerHTML={{ __html: ' ' + annotation.text + ' ' }}
/>
)
})}
)
}
export const SectionHeading = ({ paragraph }) => {
if (paragraph.hidden) return null
return (
{ROMAN_NUMERALS[paragraph.sectionIndex]}
{'. '}
{paragraph.annotations[0].text}
)
}
export const HeadingText = ({ paragraph }) => {
if (paragraph.hidden) return null
const text = paragraph.annotations.map(annotation => annotation.text).join(' ')
return (
{text}
)
}