-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Widget Params] Migrated edit params + new widget dialog to Ant Modal (
- Loading branch information
Showing
7 changed files
with
144 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
const ModalOpener = (WrappedComponent) => { | ||
const container = document.createElement('div'); | ||
|
||
const render = (component) => { | ||
ReactDOM.render(component, container); | ||
document.body.appendChild(container); | ||
}; | ||
|
||
const destroy = () => { | ||
ReactDOM.unmountComponentAtNode(container); | ||
document.body.removeChild(container); | ||
}; | ||
|
||
const getResult = props => new Promise((resolve) => { | ||
const component = ( | ||
<WrappedComponent | ||
onClose={destroy} | ||
onConfirm={resolve} | ||
{...props} | ||
/> | ||
); | ||
|
||
render(component); | ||
}); | ||
|
||
return { | ||
open: props => ({ | ||
result: getResult(props), | ||
}), | ||
}; | ||
}; | ||
|
||
export default ModalOpener; |
Oops, something went wrong.