summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/player/components.media/media.grid.js
blob: 93b8696481eebd217a2d607c93ecaa3131b65fb5 (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
import React, { Component } from 'react'

import { CURTAIN_COLOR_LOOKUP } from 'app/constants'

export const Grid = ({ media, annotation }) => {
  const { image_order, image_lookup, display_lookup, thumbnail_lookup, caption_lookup } = media.settings
  const color = CURTAIN_COLOR_LOOKUP[annotation.settings.color] || CURTAIN_COLOR_LOOKUP.white
  const style = {
    // backgroundColor: color.backgroundColor,
    // color: color.textColor,
  }
  // console.log(display_lookup)
  // console.log(width)
  return (
    <div style={style} className='grid-container'>
      {image_order.map(id => {
        const image = display_lookup[id]
        const caption = (caption_lookup && caption_lookup[id]) || {}
        // console.log(image)
        return (
          <GridItem key={id} image={image} caption={caption} />
        )
      })}
    </div>
  )
}

const GridItem = ({ image, caption }) => {
  // console.log(image)
  return (
    <div className='grid-item'>
      <div className='grid-image'>
        <img src={image.url} />
      </div>
      {caption.caption && (
        <div className='grid-caption'>
          {caption.caption}
        </div>
      )}
    </div>
  )
}