2018-02-07 19:06:07 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2016-09-08 01:00:52 +02:00
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { connect } from 'react-redux';
|
2020-07-06 11:36:45 +02:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2016-09-08 01:00:52 +02:00
|
|
|
import * as ToastActions from '../actions/toast';
|
|
|
|
|
2020-04-30 00:34:37 +02:00
|
|
|
import ExitIcon from '../../../images/exit.svg';
|
2017-02-22 20:29:35 +01:00
|
|
|
|
2016-09-08 01:00:52 +02:00
|
|
|
function Toast(props) {
|
2020-07-06 11:36:45 +02:00
|
|
|
const { t } = useTranslation('WebEditor');
|
2016-09-08 01:00:52 +02:00
|
|
|
return (
|
|
|
|
<section className="toast">
|
|
|
|
<p>
|
2020-07-06 11:36:45 +02:00
|
|
|
{t(props.text)}
|
2016-09-08 01:00:52 +02:00
|
|
|
</p>
|
2020-05-06 01:03:58 +02:00
|
|
|
<button className="toast__close" onClick={props.hideToast} aria-label="Close Alert" >
|
|
|
|
<ExitIcon focusable="false" aria-hidden="true" />
|
2016-09-08 01:00:52 +02:00
|
|
|
</button>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Toast.propTypes = {
|
|
|
|
text: PropTypes.string.isRequired,
|
|
|
|
hideToast: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
function mapStateToProps(state) {
|
|
|
|
return state.toast;
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return bindActionCreators(ToastActions, dispatch);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Toast);
|