From a43615e0c0d4edc34a0f4a14172e559f00be298a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 27 Jul 2020 19:21:55 +0200 Subject: break out fullscreen form. refactor heading --- animism-align/frontend/app/constants.js | 2 +- .../frontend/app/utils/annotation.utils.js | 8 +-- .../components/annotations/annotation.form.js | 5 +- .../components/annotations/annotation.index.css | 21 ++++-- .../annotationForms/annotationForm.image.js | 10 ++- .../annotationForms/annotationForm.utility.js | 78 +++++++++++++++------- .../annotationForms/annotationForm.video.js | 2 +- .../annotationTypes/annotationTypes.image.js | 35 +++++++--- .../annotationTypes/annotationTypes.text.js | 19 +++++- .../annotationTypes/annotationTypes.utility.js | 9 ++- .../annotationTypes/annotationTypes.video.js | 8 ++- .../annotations/annotationTypes/index.js | 7 +- .../app/views/annotation/annotation.util.js | 2 +- .../app/views/media/components/media.form.js | 1 - .../paragraph/components/paragraphTypes/index.js | 5 +- .../paragraphTypes/paragraphTypes.text.js | 2 +- .../frontend/app/views/paragraph/paragraph.css | 6 +- .../app/views/paragraph/transcript.actions.js | 9 ++- .../transcript/components/elementTypes.text.js | 2 +- .../views/viewer/transcript/components/index.js | 6 +- .../frontend/app/views/viewer/viewer.actions.js | 2 +- 21 files changed, 167 insertions(+), 72 deletions(-) diff --git a/animism-align/frontend/app/constants.js b/animism-align/frontend/app/constants.js index 9b5396e..db710a5 100644 --- a/animism-align/frontend/app/constants.js +++ b/animism-align/frontend/app/constants.js @@ -39,7 +39,7 @@ export const ROMAN_NUMERALS = [ ] export const TEXT_ANNOTATION_TYPES = new Set([ - 'header', 'sentence', 'paragraph_end', + 'section_heading', 'heading_text', 'sentence', 'paragraph_end', ]) export const MEDIA_ANNOTATION_TYPES = new Set([ diff --git a/animism-align/frontend/app/utils/annotation.utils.js b/animism-align/frontend/app/utils/annotation.utils.js index 9622f80..0884f62 100644 --- a/animism-align/frontend/app/utils/annotation.utils.js +++ b/animism-align/frontend/app/utils/annotation.utils.js @@ -1,9 +1,9 @@ import { timestampToSeconds } from 'app/utils' -export const curtainTimings = annotation => { - const fadeInDuration = timestampToSeconds(annotation.settings.fade_in_duration) - const fadeOutDuration = timestampToSeconds(annotation.settings.fade_out_duration) - const duration = timestampToSeconds(annotation.settings.duration) +export const annotationFadeTimings = annotation => { + const fadeInDuration = timestampToSeconds(annotation.settings.fade_in_duration || '0') + const fadeOutDuration = timestampToSeconds(annotation.settings.fade_out_duration || '0') + const duration = timestampToSeconds(annotation.settings.duration || '0') const start_ts = annotation.start_ts const end_ts = start_ts + duration diff --git a/animism-align/frontend/app/views/align/components/annotations/annotation.form.js b/animism-align/frontend/app/views/align/components/annotations/annotation.form.js index 7882884..5842aab 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotation.form.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotation.form.js @@ -13,7 +13,7 @@ import { Select } from 'app/common' import { annotationFormLookup } from './annotationForms' const ANNOTATION_TYPES = [ - 'sentence', 'header', 'paragraph_end', + 'sentence', 'section_heading', 'heading_text', 'paragraph_end', 'video', 'image', 'image_carousel', 'curtain', @@ -124,7 +124,8 @@ class AnnotationForm extends Component { > {this.renderButtons()} {annotation.type === 'sentence' && this.renderTextarea()} - {annotation.type === 'header' && this.renderTextarea()} + {annotation.type === 'section_heading' && this.renderTextarea()} + {annotation.type === 'text_heading' && this.renderTextarea()} {(annotation.type in annotationFormLookup) && this.renderElementForm()} ) diff --git a/animism-align/frontend/app/views/align/components/annotations/annotation.index.css b/animism-align/frontend/app/views/align/components/annotations/annotation.index.css index 322f9e1..7c28b43 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotation.index.css +++ b/animism-align/frontend/app/views/align/components/annotations/annotation.index.css @@ -23,6 +23,7 @@ background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.4)); } .annotationIndex .annotation.media { + min-width: 300px; left: calc(405px + 0.5rem); } .annotation.sentence.even { @@ -31,7 +32,10 @@ .annotation.sentence.odd { background-color: #537; } -.annotation.header { +.annotation.section_heading { + background-color: #983; +} +.annotation.heading_text { background-color: #838; } .annotation.paragraph_end { @@ -49,8 +53,11 @@ padding: 0; } .annotation.curtain span { + position: absolute; + top: 0; left: 0; z-index: 1; color: black; + text-shadow: 0 0 3px #fff, 0 0 2px #fff, 0 0 1px #fff; padding: 0.25rem; } .annotation.curtain .fadeIn { @@ -78,7 +85,10 @@ overflow: hidden; text-overflow: ellipsis; } -.annotationIndex.condensed .annotation.header { +.annotationIndex.condensed .annotation.section_heading { + z-index: 2; +} +.annotationIndex.condensed .annotation.heading_text { z-index: 1; } .annotationIndex.condensed .annotation.paragraph_end { @@ -91,9 +101,12 @@ height: 2px; overflow: hidden; padding: 0; z-index: 0; } .annotationIndex.collapsed .annotation.sentence.selected { - z-index: 1; + z-index: 4; +} +.annotationIndex.collapsed .annotation.section_heading { + z-index: 3; } -.annotationIndex.collapsed .annotation.header { +.annotationIndex.collapsed .annotation.heading_text { z-index: 2; } .annotationIndex.collapsed .annotation.paragraph_end { diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.image.js b/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.image.js index 8457b68..490c822 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.image.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationForms/annotationForm.image.js @@ -1,8 +1,9 @@ import React, { Component } from 'react' import { Select } from 'app/common' +import { AnnotationFormFullscreen } from './annotationForm.utility' -export const AnnotationFormImage = ({ annotation, media, handleSettingsSelect }) => { +export const AnnotationFormImage = ({ annotation, media, handleSettingsSelect, handleSettingsChange }) => { if (!media.lookup) return
const { lookup, order } = media const image_list_items = order.filter(id => lookup[id].type === 'image').map(id => { @@ -13,7 +14,7 @@ export const AnnotationFormImage = ({ annotation, media, handleSettingsSelect }) } }) return ( -
+
+ + + + +
+ ) +} + +export const AnnotationFormFullscreen = ({ annotation, alwaysAccessible, handleSettingsChange, handleSettingsSelect }) => { + if (!alwaysAccessible && !annotation.settings.fullscreen) { + return ( + + ) + } const { fadeInDuration, fadeOutDuration, duration, start_ts, end_ts, fade_in_end_ts, fade_out_start_ts, - } = curtainTimings(annotation) - + } = annotationFadeTimings(annotation) return ( -
+
+ {!alwaysAccessible && ( + + )} - - { - const { start_ts, text } = annotation +export const AnnotationImage = ({ y, annotation, media, timeline, selected, onClick, onDoubleClick }) => { + const { text } = annotation const className = selected ? 'annotation media image selected' : 'annotation media image' if (checkAnnotationMediaNotReady(annotation, media)) { return } - const data = media[annotation.settings.media_id] + const mediaItem = media[annotation.settings.media_id] + + const { + fadeInDuration, fadeOutDuration, duration, + start_ts, end_ts, fade_in_end_ts, fade_out_start_ts, + } = annotationFadeTimings(annotation) + const durationHeight = annotation.settings.fullscreen ? durationToHeight(duration, timeline) : 'auto' + const fadeInHeight = durationToHeight(fadeInDuration, timeline) + const fadeOutHeight = durationToHeight(fadeOutDuration, timeline) + return (
onClick(e, annotation)} onDoubleClick={e => onDoubleClick(e, annotation)} > -
- {data.title} -
- {data.title}
- {data.author}
- {data.date} + {mediaItem.title}
+ {mediaItem.author}
+ {mediaItem.date}
) } + +/* +
+ {mediaItem.title} +
+*/ \ No newline at end of file diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.text.js b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.text.js index be4674f..19e0eaa 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.text.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.text.js @@ -19,9 +19,24 @@ export const AnnotationSentence = ({ y, annotation, selected, onClick, onDoubleC ) } -export const AnnotationHeader = ({ y, annotation, selected, onClick, onDoubleClick }) => { +export const AnnotationHeadingText = ({ y, annotation, selected, onClick, onDoubleClick }) => { const { start_ts, text } = annotation - const className = selected ? 'annotation header selected' : 'annotation header' + const className = selected ? 'annotation heading_text selected' : 'annotation heading_text' + return ( +
onClick(e, annotation)} + onDoubleClick={e => onDoubleClick(e, annotation)} + > + {text} +
+ ) +} + +export const AnnotationSectionHeading = ({ y, annotation, selected, onClick, onDoubleClick }) => { + const { start_ts, text } = annotation + const className = selected ? 'annotation section_heading selected' : 'annotation section_heading' return (
{ @@ -8,7 +8,7 @@ export const AnnotationCurtain = ({ y, annotation, timeline, selected, onClick, const { fadeInDuration, fadeOutDuration, duration, start_ts, end_ts, fade_in_end_ts, fade_out_start_ts, - } = curtainTimings(annotation) + } = annotationFadeTimings(annotation) const durationHeight = durationToHeight(duration, timeline) const fadeInHeight = durationToHeight(fadeInDuration, timeline) const fadeOutHeight = durationToHeight(fadeOutDuration, timeline) @@ -21,7 +21,10 @@ export const AnnotationCurtain = ({ y, annotation, timeline, selected, onClick, >
- Curtain: {annotation.settings.color}. {annotation.settings.curtain_text} + + Curtain: {annotation.settings.color}. + {annotation.settings.curtain_text} +
) } diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.video.js b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.video.js index d2fc4e5..1ebc804 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.video.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/annotationTypes.video.js @@ -17,9 +17,6 @@ export const AnnotationVideo = ({ y, annotation, media, selected, onClick, onDou onClick={e => onClick(e, annotation)} onDoubleClick={e => onDoubleClick(e, annotation)} > -
- {data.title} -
{data.title}
@@ -31,3 +28,8 @@ export const AnnotationVideo = ({ y, annotation, media, selected, onClick, onDou ) } +/* +
+ {data.title} +
+*/ \ No newline at end of file diff --git a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/index.js b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/index.js index ee30167..1a1c5ec 100644 --- a/animism-align/frontend/app/views/align/components/annotations/annotationTypes/index.js +++ b/animism-align/frontend/app/views/align/components/annotations/annotationTypes/index.js @@ -1,7 +1,9 @@ import React from 'react' import { - AnnotationSentence, AnnotationHeader, + AnnotationSentence, + AnnotationHeadingText, + AnnotationSectionHeading, AnnotationParagraphEnd, } from './annotationTypes.text' @@ -19,7 +21,8 @@ import { export const AnnotationElementLookup = { sentence: React.memo(AnnotationSentence), - header: React.memo(AnnotationHeader), + heading_text: React.memo(AnnotationHeadingText), + section_heading: React.memo(AnnotationSectionHeading), paragraph_end: React.memo(AnnotationParagraphEnd), video: React.memo(AnnotationVideo), image: React.memo(AnnotationImage), diff --git a/animism-align/frontend/app/views/annotation/annotation.util.js b/animism-align/frontend/app/views/annotation/annotation.util.js index 82edd9a..680de5e 100644 --- a/animism-align/frontend/app/views/annotation/annotation.util.js +++ b/animism-align/frontend/app/views/annotation/annotation.util.js @@ -8,7 +8,7 @@ export const thumbnailURL = data => { } } -export const curtainTimings = annotation => { +export const annotationFadeTimings = annotation => { const fadeInDurationInSeconds = timestampToSeconds(annotation.settings.fade_in_duration || '0') const fadeOutDurationInSeconds = timestampToSeconds(annotation.settings.fade_out_duration || '0') const durationInSeconds = timestampToSeconds(annotation.settings.duration || '0') diff --git a/animism-align/frontend/app/views/media/components/media.form.js b/animism-align/frontend/app/views/media/components/media.form.js index 9dbc130..a646e8e 100644 --- a/animism-align/frontend/app/views/media/components/media.form.js +++ b/animism-align/frontend/app/views/media/components/media.form.js @@ -245,7 +245,6 @@ export default class MediaForm extends Component { name="hide_in_bibliography" checked={data.settings.hide_in_bibliography} onChange={this.handleSettingsChange} - autoComplete="off" />