mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-01-10 07:57:23 +03:00
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
|
import React, { Component } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
|
||
|
class Toast extends Component {
|
||
|
componentDidMount() {
|
||
|
setTimeout(() => {
|
||
|
this.props.removeToast(this.props.id);
|
||
|
}, 30000);
|
||
|
}
|
||
|
|
||
|
shouldComponentUpdate() {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<div className={`toast toast--${this.props.type}`}>
|
||
|
<p className="toast__content">
|
||
|
{this.props.message}
|
||
|
</p>
|
||
|
<button className="toast__dismiss" onClick={() => this.props.removeToast(this.props.id)}>
|
||
|
<svg stroke="#fff" fill="none" width="20" height="20" strokeWidth="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m18 6-12 12"/><path d="m6 6 12 12"/></svg>
|
||
|
</button>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Toast.propTypes = {
|
||
|
id: PropTypes.string.isRequired,
|
||
|
message: PropTypes.string.isRequired,
|
||
|
type: PropTypes.string.isRequired,
|
||
|
removeToast: PropTypes.func.isRequired,
|
||
|
};
|
||
|
|
||
|
export default Toast;
|