1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/app/components/app/home-notification/home-notification.component.js
Dan J Miller 9d5be5d29f
New notification fixes (#6955)
* Replace use of backup-notification with use of home notification

* Pin notifications relative to window

* Remove unneeded isRequired condition on some home.component properties

* Refactor rendering of home notifications

* UX for multiple notifications

* Adds dismissal to provider request notification.

* Fix test failures

The e2e tests have been updated to reference `home-notification`
classnames instead of the removed `background-notification`. The
active tab proptypes and default values were updated as well.
2019-08-02 18:01:26 -02:30

113 lines
2.9 KiB
JavaScript

import React, { PureComponent } from 'react'
import classnames from 'classnames'
import {Tooltip as ReactTippy} from 'react-tippy'
import PropTypes from 'prop-types'
import Button from '../../ui/button'
export default class HomeNotification extends PureComponent {
static contextTypes = {
metricsEvent: PropTypes.func,
}
static defaultProps = {
onAccept: null,
ignoreText: null,
onIgnore: null,
infoText: null,
}
static propTypes = {
acceptText: PropTypes.string.isRequired,
onAccept: PropTypes.func,
ignoreText: PropTypes.string,
onIgnore: PropTypes.func,
descriptionText: PropTypes.string.isRequired,
infoText: PropTypes.string,
classNames: PropTypes.array,
}
handleAccept = () => {
this.props.onAccept()
}
handleIgnore = () => {
this.props.onIgnore()
}
render () {
const { descriptionText, acceptText, onAccept, ignoreText, onIgnore, infoText, classNames = [] } = this.props
return (
<div className={classnames('home-notification', ...classNames)}>
<div className="home-notification__header">
<div className="home-notification__header-container">
<img
className="home-notification__icon"
alt=""
src="images/icons/connect.svg"
/>
<div className="home-notification__text">
{ descriptionText }
</div>
</div>
{
infoText ? (
<ReactTippy
style={{
display: 'flex',
}}
html={(
<p className="home-notification-tooltip__content">
{infoText}
</p>
)}
offset={-36}
distance={36}
animation="none"
position="top"
arrow
theme="info"
>
<img
alt=""
src="images/icons/info.svg"
/>
</ReactTippy>
) : (
null
)
}
</div>
<div className="home-notification__buttons">
{
(onAccept && acceptText) ? (
<Button
type="primary"
className="home-notification__accept-button"
onClick={this.handleAccept}
>
{ acceptText }
</Button>
) : (
null
)
}
{
(onIgnore && ignoreText) ? (
<Button
type="secondary"
className="home-notification__ignore-button"
onClick={this.handleIgnore}
>
{ ignoreText }
</Button>
) : (
null
)
}
</div>
</div>
)
}
}