summaryrefslogtreecommitdiff
path: root/client/components/Paintings.jsx
blob: 79dbe7610ea82a1381f2a42c31e3ca6e6c830d9d (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
import { h, Component } from 'preact'
import { Link } from 'react-router-dom'
import { randrange } from '../util'

export default class Paintings extends Component {
  constructor() {
    super()
  }
  render() {
    const paintings = this.props.data.painting.map( (painting, i) => {
      painting.style = painting.style || 'background-color:hsl(' + randrange(300,460) + ',50%,98%)'
      return (
        <div class='cell' key={i} style={painting.style}>
          <div class='painting'>
            <Link to={'/painting/' + painting.id}>
              <div class='image' style={'background-image: url(' + painting.image.uri + ')'} />
            </Link>
          </div>
          <div class='about'>
            <div>
              <div>{painting.title}</div>
              <div>{painting.medium}</div>
              <div>{painting.date}</div>
              <div>{painting.image.caption}</div>
              <br/>
              <Link to={'/painting/' + painting.id}>
                More info &gt;
              </Link>
            </div>
          </div>
        </div>
      )
    })
    const about = this.props.data.page[0]
    const body = (about.body || '').replace(/\n/g,'<br>')
    const page = (
      <div class='cell'>
        <div class='painting'>
          <a href='http://asdf.us/pepper/' target='_blank'>
            <div class='image' style={'background-image: url(' + about.image.uri + ')'} />
          </a>
        </div>
        <div class='about'>
          <div dangerouslySetInnerHTML={{ __html: body }} />
        </div>
      </div>
    )
    return (
      <div class='paintings'>
        {paintings}
        {page}
      </div>
    )
  }
}