aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/modals/modal.js
diff options
context:
space:
mode:
authorsdtsui <szehungdanieltsui@gmail.com>2017-08-21 18:53:01 +0800
committersdtsui <szehungdanieltsui@gmail.com>2017-08-21 18:53:01 +0800
commit80a2cba38ef4fe6c01a624c5a504a7803b1a8316 (patch)
treebeb30d3a8dff24b9020242f67346847f7eba5b74 /ui/app/components/modals/modal.js
parent66829b7a05322320855b077c04f885908bd95efa (diff)
downloadtangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.tar
tangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.tar.gz
tangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.tar.bz2
tangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.tar.lz
tangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.tar.xz
tangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.tar.zst
tangerine-wallet-browser-80a2cba38ef4fe6c01a624c5a504a7803b1a8316.zip
Enhance global modal to accept styles from different components
Diffstat (limited to 'ui/app/components/modals/modal.js')
-rw-r--r--ui/app/components/modals/modal.js107
1 files changed, 62 insertions, 45 deletions
diff --git a/ui/app/components/modals/modal.js b/ui/app/components/modals/modal.js
index 77391dfcc..e2c5f77cc 100644
--- a/ui/app/components/modals/modal.js
+++ b/ui/app/components/modals/modal.js
@@ -14,18 +14,63 @@ const EditAccountNameModal = require('./edit-account-name-modal')
const NewAccountModal = require('./new-account-modal')
const MODALS = {
- BUY: [
- h(BuyOptions, {}, []),
- ],
- EDIT_ACCOUNT_NAME: [
- h(EditAccountNameModal, {}, []),
- ],
- ACCOUNT_DETAILS: [
- h(AccountDetailsModal, {}, []),
- ],
- NEW_ACCOUNT: [
- h(NewAccountModal, {}, []),
- ]
+ BUY: {
+ contents: [
+ h(BuyOptions, {}, []),
+ ],
+ mobileModalStyle: {
+ width: '95%',
+ top: isPopupOrNotification() === 'popup' ? '48vh' : '36.5vh',
+ boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
+ },
+ laptopModalStyle: {
+ width: '66%',
+ top: 'calc(30% + 10px)',
+ boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
+ },
+ },
+
+ EDIT_ACCOUNT_NAME: {
+ contents: [
+ h(EditAccountNameModal, {}, []),
+ ],
+ mobileModalStyle: {
+ width: '95%',
+ top: isPopupOrNotification() === 'popup' ? '48vh' : '36.5vh',
+ boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
+ },
+ laptopModalStyle: {
+ width: '45%',
+ top: 'calc(30% + 10px)',
+ boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
+ },
+ },
+
+ ACCOUNT_DETAILS: {
+ contents: [
+ h(AccountDetailsModal, {}, []),
+ ],
+ mobileModalStyle: {},
+ laptopModalStyle: {},
+ },
+
+ NEW_ACCOUNT: {
+ contents: [
+ h(NewAccountModal, {}, []),
+ ],
+ mobileModalStyle: {},
+ laptopModalStyle: {}
+ },
+
+ DEFAULT: {
+ contents: [],
+ mobileModalStyle: {},
+ laptopModalStyle: {},
+ }
+}
+
+const BACKDROPSTYLE = {
+ backgroundColor: 'rgba(245, 245, 245, 0.85)',
}
function mapStateToProps (state) {
@@ -51,26 +96,11 @@ function Modal () {
module.exports = connect(mapStateToProps, mapDispatchToProps)(Modal)
-const mobileModalStyles = {
- width: '95%',
- // Used to create matching t/l/r/b space in mobile view.
- top: isPopupOrNotification() === 'popup' ? '48vh' : '36.5vh',
- boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
-}
-
-const laptopModalStyles = {
- width: '66%',
- top: 'calc(30% + 10px)',
- boxShadow: 'rgba(0, 0, 0, 0.15) 0px 2px 2px 2px',
-}
-
-const backdropStyles = {
- backgroundColor: 'rgba(245, 245, 245, 0.85)',
-}
-
Modal.prototype.render = function () {
+ const modal = MODALS[this.props.modalState.name || 'DEFAULT']
- const children = MODALS[this.props.modalState.name] || []
+ const children = modal.contents
+ const modalStyle = modal[isMobileView() ? 'mobileModalStyle' : 'laptopModalStyle']
return h(FadeModal,
{
@@ -80,8 +110,8 @@ Modal.prototype.render = function () {
ref: (ref) => {
this.modalRef = ref
},
- modalStyle: isMobileView() ? mobileModalStyles : laptopModalStyles,
- backdropStyle: backdropStyles,
+ modalStyle,
+ backdropStyle: BACKDROPSTYLE,
},
children,
)
@@ -109,16 +139,3 @@ Modal.prototype.hide = function() {
Modal.prototype.show = function() {
this.modalRef.show()
}
-
-// TODO: specify default props and proptypes
-// Modal.defaultProps = {}
-
-// const elementType = require('react-prop-types/lib/elementType')
-// const PropTypes from 'prop-types'
-
-// Modal.propTypes = {
-// active: PropTypes.bool,
-// hideModal: PropTypes.func.isRequired,
-// component: elementType,
-// onHideCallback: PropTypes.func,
-// }