Browse Source

Use `onHide` callback from react-mortal

master
meriadec 7 years ago
parent
commit
713bc067dc
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 2
      package.json
  2. 4
      src/components/base/Modal/index.js
  3. 7
      src/components/modals/AddAccount/index.js
  4. 4
      src/components/modals/Receive.js
  5. 4
      src/components/modals/Send.js
  6. 4
      src/components/modals/SettingsAccount.js
  7. 14
      yarn.lock

2
package.json

@ -69,7 +69,7 @@
"react": "^16.2.0", "react": "^16.2.0",
"react-dom": "^16.2.0", "react-dom": "^16.2.0",
"react-i18next": "^7.3.4", "react-i18next": "^7.3.4",
"react-mortal": "^3.0.1", "react-mortal": "^3.1.0",
"react-motion": "^0.5.2", "react-motion": "^0.5.2",
"react-qr-reader": "^2.0.1", "react-qr-reader": "^2.0.1",
"react-redux": "^5.0.6", "react-redux": "^5.0.6",

4
src/components/base/Modal/index.js

@ -20,6 +20,7 @@ import Icon from 'components/base/Icon'
type Props = { type Props = {
isOpened?: boolean, isOpened?: boolean,
onClose: Function, onClose: Function,
onHide?: Function,
preventBackdropClick?: boolean, preventBackdropClick?: boolean,
render: Function, render: Function,
data?: any, data?: any,
@ -109,11 +110,12 @@ export class Modal extends PureComponent<Props> {
} }
render() { render() {
const { preventBackdropClick, isOpened, onClose, render, data } = this.props const { preventBackdropClick, isOpened, onClose, onHide, render, data } = this.props
return ( return (
<Mortal <Mortal
isOpened={isOpened} isOpened={isOpened}
onClose={onClose} onClose={onClose}
onHide={onHide}
motionStyle={(spring, isVisible) => ({ motionStyle={(spring, isVisible) => ({
opacity: spring(isVisible ? 1 : 0, springConfig), opacity: spring(isVisible ? 1 : 0, springConfig),
y: spring(isVisible ? 0 : 20, springConfig), y: spring(isVisible ? 0 : 20, springConfig),

7
src/components/modals/AddAccount/index.js

@ -265,12 +265,12 @@ class AddAccountModal extends PureComponent<Props, State> {
}) })
} }
handleClose = () => { handleClose = () => clearTimeout(this._timeout)
clearTimeout(this._timeout)
handleHide = () =>
this.setState({ this.setState({
...defaultState, ...defaultState,
}) })
}
addAccount = ({ id, name, ...data }) => { addAccount = ({ id, name, ...data }) => {
const { inputValue } = this.state const { inputValue } = this.state
@ -297,6 +297,7 @@ class AddAccountModal extends PureComponent<Props, State> {
name={MODAL_ADD_ACCOUNT} name={MODAL_ADD_ACCOUNT}
preventBackdropClick={step !== 'chooseWallet'} preventBackdropClick={step !== 'chooseWallet'}
onClose={this.handleClose} onClose={this.handleClose}
onHide={this.handleHide}
render={({ onClose }) => ( render={({ onClose }) => (
<ModalBody onClose={onClose} flow={3}> <ModalBody onClose={onClose} flow={3}>
<Text fontSize={4} color="steel"> <Text fontSize={4} color="steel">

4
src/components/modals/Receive.js

@ -47,7 +47,7 @@ class ReceiveModal extends PureComponent<Props, State> {
[key]: value, [key]: value,
}) })
handleClose = () => handleHide = () =>
this.setState({ this.setState({
...defaultState, ...defaultState,
}) })
@ -59,7 +59,7 @@ class ReceiveModal extends PureComponent<Props, State> {
return ( return (
<Modal <Modal
name={MODAL_RECEIVE} name={MODAL_RECEIVE}
onClose={this.handleClose} onHide={this.handleHide}
render={({ data, onClose }) => { render={({ data, onClose }) => {
const account = this.getAccount(data) const account = this.getAccount(data)
return ( return (

4
src/components/modals/Send.js

@ -140,7 +140,7 @@ class Send extends PureComponent<Props, State> {
step, step,
}) })
handleClose = () => handleHide = () =>
this.setState({ this.setState({
...defaultState, ...defaultState,
}) })
@ -153,7 +153,7 @@ class Send extends PureComponent<Props, State> {
return ( return (
<Modal <Modal
name={MODAL_SEND} name={MODAL_SEND}
onClose={this.handleClose} onHide={this.handleHide}
render={({ data, onClose }) => ( render={({ data, onClose }) => (
<Fragment> <Fragment>
<ModalBody p={2}> <ModalBody p={2}>

4
src/components/modals/SettingsAccount.js

@ -113,7 +113,7 @@ class SettingsAccount extends PureComponent<Props, State> {
push('/') push('/')
} }
handleClose = () => handleHide = () =>
this.setState({ this.setState({
...defaultState, ...defaultState,
}) })
@ -124,7 +124,7 @@ class SettingsAccount extends PureComponent<Props, State> {
return ( return (
<Modal <Modal
name={MODAL_SETTINGS_ACCOUNT} name={MODAL_SETTINGS_ACCOUNT}
onClose={this.handleClose} onHide={this.handleHide}
render={({ data, onClose }) => { render={({ data, onClose }) => {
const account = this.getAccount(data) const account = this.getAccount(data)
return ( return (

14
yarn.lock

@ -7430,14 +7430,14 @@ react-modal@^3.1.10:
prop-types "^15.5.10" prop-types "^15.5.10"
warning "^3.0.0" warning "^3.0.0"
react-mortal@^3.0.1: react-mortal@^3.1.0:
version "3.0.1" version "3.1.0"
resolved "https://registry.yarnpkg.com/react-mortal/-/react-mortal-3.0.1.tgz#be8477513deb08ceb22ba8ae4b52220dc5c741ff" resolved "https://registry.yarnpkg.com/react-mortal/-/react-mortal-3.1.0.tgz#8dc4eaa0cf267a3614a07e8cef5e130840942fb3"
dependencies: dependencies:
prop-types "^15.6.0" prop-types "^15.6.0"
react "^16.1.1" react "^16.2.0"
react-motion "^0.5.0" react-motion "^0.5.0"
react-portal "^4.0.0" react-portal "^4.1.2"
react-motion@^0.5.0, react-motion@^0.5.2: react-motion@^0.5.0, react-motion@^0.5.2:
version "0.5.2" version "0.5.2"
@ -7451,7 +7451,7 @@ react-onclickoutside@^6.5.0:
version "6.7.1" version "6.7.1"
resolved "https://registry.yarnpkg.com/react-onclickoutside/-/react-onclickoutside-6.7.1.tgz#6a5b5b8b4eae6b776259712c89c8a2b36b17be93" resolved "https://registry.yarnpkg.com/react-onclickoutside/-/react-onclickoutside-6.7.1.tgz#6a5b5b8b4eae6b776259712c89c8a2b36b17be93"
react-portal@^4.0.0: react-portal@^4.1.2:
version "4.1.2" version "4.1.2"
resolved "https://registry.yarnpkg.com/react-portal/-/react-portal-4.1.2.tgz#7f28f3c8c2ed5c541907c0ed0f24e8996acf627f" resolved "https://registry.yarnpkg.com/react-portal/-/react-portal-4.1.2.tgz#7f28f3c8c2ed5c541907c0ed0f24e8996acf627f"
dependencies: dependencies:
@ -7560,7 +7560,7 @@ react-treebeard@^2.1.0:
shallowequal "^0.2.2" shallowequal "^0.2.2"
velocity-react "^1.3.1" velocity-react "^1.3.1"
react@^16.0.0, react@^16.1.1, react@^16.2.0: react@^16.0.0, react@^16.2.0:
version "16.2.0" version "16.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba" resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
dependencies: dependencies:

Loading…
Cancel
Save