2021-02-04 19:15:23 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-05-20 08:04:19 +02:00
|
|
|
|
|
|
|
export default class InfoBox extends Component {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-05-20 08:04:19 +02:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onClose: PropTypes.func,
|
|
|
|
title: PropTypes.string,
|
|
|
|
description: PropTypes.string,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2019-12-19 23:00:22 +01:00
|
|
|
state = {
|
|
|
|
isShowing: true,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
handleClose() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { onClose } = this.props;
|
2018-05-20 08:04:19 +02:00
|
|
|
|
|
|
|
if (onClose) {
|
2021-02-04 19:15:23 +01:00
|
|
|
onClose();
|
2018-05-20 08:04:19 +02:00
|
|
|
} else {
|
2021-02-04 19:15:23 +01:00
|
|
|
this.setState({ isShowing: false });
|
2018-05-20 08:04:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { title, description } = this.props;
|
2018-05-20 08:04:19 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
return this.state.isShowing ? (
|
|
|
|
<div className="info-box">
|
2022-09-23 16:41:35 +02:00
|
|
|
<div
|
|
|
|
className="info-box__close"
|
|
|
|
data-testid="info-box-close"
|
|
|
|
onClick={() => this.handleClose()}
|
|
|
|
/>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="info-box__title">{title}</div>
|
|
|
|
<div className="info-box__description">{description}</div>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
) : null;
|
2018-05-20 08:04:19 +02:00
|
|
|
}
|
|
|
|
}
|