diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-05-31 07:17:40 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@users.noreply.github.com> | 2018-06-01 01:37:52 +0800 |
commit | cc73d869fed79c63261821fb7ad8f1e5180ffca2 (patch) | |
tree | cb4eb988a13843fa2c01a7fee0ca594bdc98e75f /ui/app/components/modals/notification | |
parent | f4d833cb09758beb62a65ad4011d16bdb81b33ff (diff) | |
download | tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.tar tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.tar.gz tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.tar.bz2 tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.tar.lz tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.tar.xz tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.tar.zst tangerine-wallet-browser-cc73d869fed79c63261821fb7ad8f1e5180ffca2.zip |
Add new alert modals
Diffstat (limited to 'ui/app/components/modals/notification')
3 files changed, 70 insertions, 0 deletions
diff --git a/ui/app/components/modals/notification/index.js b/ui/app/components/modals/notification/index.js new file mode 100644 index 000000000..d60a3129b --- /dev/null +++ b/ui/app/components/modals/notification/index.js @@ -0,0 +1,2 @@ +import Notification from './notification.container' +module.exports = Notification diff --git a/ui/app/components/modals/notification/notification.component.js b/ui/app/components/modals/notification/notification.component.js new file mode 100644 index 000000000..1af2f3ca8 --- /dev/null +++ b/ui/app/components/modals/notification/notification.component.js @@ -0,0 +1,30 @@ +import React from 'react' +import PropTypes from 'prop-types' +import Button from '../../button' + +const Notification = (props, context) => { + return ( + <div className="modal-container"> + { props.children } + <div className="modal-container__footer"> + <Button + type="primary" + onClick={() => props.onHide()} + > + { context.t('ok') } + </Button> + </div> + </div> + ) +} + +Notification.propTypes = { + onHide: PropTypes.func.isRequired, + children: PropTypes.element, +} + +Notification.contextTypes = { + t: PropTypes.func, +} + +export default Notification diff --git a/ui/app/components/modals/notification/notification.container.js b/ui/app/components/modals/notification/notification.container.js new file mode 100644 index 000000000..5b98714da --- /dev/null +++ b/ui/app/components/modals/notification/notification.container.js @@ -0,0 +1,38 @@ +import { connect } from 'react-redux' +import Notification from './notification.component' + +const { hideModal } = require('../../../actions') + +const mapStateToProps = state => { + const { appState: { modal: { modalState: { props } } } } = state + const { onHide } = props + return { + onHide, + } +} + +const mapDispatchToProps = dispatch => { + return { + hideModal: () => dispatch(hideModal()), + } +} + +const mergeProps = (stateProps, dispatchProps, ownProps) => { + const { onHide, ...otherStateProps } = stateProps + const { hideModal, ...otherDispatchProps } = dispatchProps + + return { + ...otherStateProps, + ...otherDispatchProps, + ...ownProps, + onHide: () => { + hideModal() + + if (onHide && typeof onHide === 'function') { + onHide() + } + }, + } +} + +export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(Notification) |