Skip to content

Instantly share code, notes, and snippets.

@hedgerworkco
Last active August 29, 2015 14:25
Show Gist options
  • Save hedgerworkco/1c8c5a622ed7bbbd95e9 to your computer and use it in GitHub Desktop.
Save hedgerworkco/1c8c5a622ed7bbbd95e9 to your computer and use it in GitHub Desktop.

#howto modal

Under /app/scripts/apps/internet.jsx:

const modalProps = {
  show: this.state.modalPayload.modalOpen,
  onHide: this.closeModal,
  container: document.body,
  dialogClassName: 'modal-fullscreen',
  'aria-labelledby': 'contained-modal-title'
};

and in render:

    <Modal { ...modalProps } >
      <SidebarModalContainer
        { ...modalPayload.payload }/>
    </Modal>

and this.closeModal:

closeModal() {
    ModalActions.closeModal();
}

To open a modal, use: ModalActions.fetchModal({ url: 'foo/bar/baz' });

This fetches the modal from the API and triggers the modal to open.

The app receives the modal data as

this.state.modalPayload

I still need to figure out how to accept different templates besides SidebarModalContainer, or we can adapt it to show multiple templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment