blob: 8688b8e8f59e6aeaf3552e155cf57a5a7069e875 (
plain) (
blame)
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
|
import React, { Component } from 'react'
import PropTypes from 'prop-types'
export default class InfoBox extends Component {
static contextTypes = {
t: PropTypes.func,
}
static propTypes = {
onClose: PropTypes.func,
title: PropTypes.string,
description: PropTypes.string,
}
constructor (props) {
super(props)
this.state = {
isShowing: true,
}
}
handleClose () {
const { onClose } = this.props
if (onClose) {
onClose()
} else {
this.setState({ isShowing: false })
}
}
render () {
const { title, description } = this.props
return !this.state.isShowing
? null
: (
<div className="info-box">
<div
className="info-box__close"
onClick={() => this.handleClose()}
/>
<div className="info-box__title">{ title }</div>
<div className="info-box__description">{ description }</div>
</div>
)
}
}
|