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

export default class Modal extends Component {
  render() {
    if (this.props.visible) {
      document.body.classList.add("inModal")
    }
    else {
      document.body.classList.remove("inModal")
    }

    const className = this.props.visible
      ? 'modal visible'
      : 'modal'
    
    const style = 'background-color:hsl(' + randint(360) + ',20%,95%)'
    
    return (
      <div class={className} style={style}>
        <div class='inner'>
          {this.props.children}
        </div>
      </div>
    )
  }
}

function randint(n){ return (Math.random()*n)|0 }
function randrange(n){ return (Math.random()*n)|0 }