1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/ui/components/app/info-box/info-box.component.js

45 lines
933 B
JavaScript
Raw Normal View History

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,
};
2018-05-20 08:04:19 +02:00
static propTypes = {
onClose: PropTypes.func,
title: PropTypes.string,
description: PropTypes.string,
};
2018-05-20 08:04:19 +02:00
state = {
isShowing: true,
};
2018-05-20 08:04:19 +02:00
2020-11-03 00:41:28 +01:00
handleClose() {
const { onClose } = this.props;
2018-05-20 08:04:19 +02:00
if (onClose) {
onClose();
2018-05-20 08:04:19 +02:00
} else {
this.setState({ isShowing: false });
2018-05-20 08:04:19 +02:00
}
}
2020-11-03 00:41:28 +01:00
render() {
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">
<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>
) : null;
2018-05-20 08:04:19 +02:00
}
}