summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/player/components.fullscreen/fullscreen.image.js
blob: 60ba7c94d0f5b322f26226963b3bac0a3af30ac8 (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
import React from 'react'

import { CURTAIN_COLOR_LOOKUP } from 'app/constants'
export const FullscreenImage = ({ element, media, transitionDuration }) => {
  const color = element.color || CURTAIN_COLOR_LOOKUP.white

  const item = media.lookup[element.settings.media_id]
  const style = {
    backgroundColor: color.backgroundColor,
    color: color.textColor,
    transitionDuration,
  }
  
  let url;
  // console.log(element, item)
  if (item.type === 'gallery') {
    const index = parseInt(element.settings.frame_index)
    const frame_id = item.settings.image_order[index]
    const frame = item.settings.display_lookup[frame_id]
    if (!frame) {
      console.error("Slide not found:", element.settings.frame_index)
      return <div />
    }
    url = frame.url
  } else {
    url = item.settings.display.url
  }

  return (
    <div
      className='fullscreen-element image'
      style={style}
    >
      <div style={{
        backgroundImage: 'url(' + url + ')',
      }} />
    </div>
  )
}