summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/editor/annotation/components/annotationForms/annotationForm.utility.js
blob: 7e823cc439a0cd2341b1c756bb74a5a6a569b6d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import React, { Component } from 'react'

import { timestamp } from 'app/utils'
import { TextInput, LabelDescription, Select, Checkbox } from 'app/common'
import { CURTAIN_COLOR_SELECT_OPTIONS, CURTAIN_STYLE_SELECT_OPTIONS } from 'app/constants'
import { annotationFadeTimings } from 'app/utils/annotation.utils'
import { makeMediaItems } from 'app/utils/annotation.utils'

export const AnnotationFormIntro = ({ annotation, media, handleSettingsChange, handleSettingsSelect }) => {
  if (!media.lookup) return <div />
  const image_list_items = makeMediaItems(media, 'file')
  return (
    <div className='options'>
      <Select
        name='media_id'
        className="media_id"
        selected={annotation.settings.media_id}
        options={image_list_items}
        defaultOption='Choose a file'
        onChange={handleSettingsSelect}
      />

      <TextInput
        title="Title"
        name="title"
        placeholder="Enter title or leave blank"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />

      <TextInput
        title="Subtitle"
        name="subtitle"
        placeholder="Enter subtitle or leave blank"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />

      <Select
        title='Color'
        name='color'
        selected={annotation.settings.color}
        options={CURTAIN_COLOR_SELECT_OPTIONS}
        defaultOption='Pick a color'
        onChange={handleSettingsSelect}
      />

      <TextInput
        title="Actual start time"
        name="intro_start_ts"
        placeholder="0:00"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />

      <LabelDescription>
        {'Timestamp where voiceover starts, after any intro sound effect.'}
      </LabelDescription>

      <AnnotationFormFullscreen
        annotation={annotation}
        handleSettingsChange={handleSettingsChange}
        handleSettingsSelect={handleSettingsSelect}
      />
    </div>
  )
}

export const AnnotationFormCurtain = ({ annotation, handleSettingsChange, handleSettingsSelect }) => {
  return (
    <div className='options'>
      <TextInput
        title="Curtain text"
        name="curtain_text"
        placeholder="Enter text or leave blank"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />

      <Select
        title='Color'
        name='color'
        selected={annotation.settings.color}
        options={CURTAIN_COLOR_SELECT_OPTIONS}
        defaultOption='Pick a color'
        onChange={handleSettingsSelect}
      />

      <Select
        title='Style'
        name='curtain_style'
        selected={annotation.settings.curtain_style}
        options={CURTAIN_STYLE_SELECT_OPTIONS}
        defaultOption='Pick a style'
        onChange={handleSettingsSelect}
      />

      <Checkbox
        label="Contains flashing light"
        name="flashing_light_warning"
        checked={annotation.settings.flashing_light_warning}
        onChange={handleSettingsSelect}
      />

      <AnnotationFormFullscreen
        alwaysAccessible
        annotation={annotation}
        handleSettingsChange={handleSettingsChange}
        handleSettingsSelect={handleSettingsSelect}
      />
    </div>
  )
}

export const AnnotationFormFullscreen = ({ annotation, handleSettingsChange, handleSettingsSelect }) => {
  const {
    fadeInDuration, fadeOutDuration, duration,
    start_ts, end_ts, fade_in_end_ts, fade_out_start_ts,
  } = annotationFadeTimings(annotation)
  return (
    <div>
      <TextInput
        title="Total duration"
        name="duration"
        className="number"
        placeholder="0:00"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />
      <LabelDescription>
        {duration}
        {' seconds, ends at '}
        {timestamp(end_ts)}
      </LabelDescription>

      <TextInput
        title="Fade in duration"
        name="fade_in_duration"
        className="number"
        placeholder="0:00"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />
      <LabelDescription>
        {fadeInDuration}
        {' seconds, ends at '}
        {timestamp(fade_in_end_ts)}
      </LabelDescription>

      <TextInput
        title="Fade out duration"
        name="fade_out_duration"
        className="number"
        placeholder="0:00"
        data={annotation.settings}
        onChange={handleSettingsChange}
        autoComplete="off"
      />
      <LabelDescription>
        {fadeOutDuration}
        {' seconds, starts at '}
        {timestamp(fade_out_start_ts)}
      </LabelDescription>
    </div>
  )
}