Popup React Component

    Popup is a popup window with any HTML content that pops up over App's main content. Popup as all other overlays is part of so called "Temporary Views".

    Popup React component represents Popup component.

    Popup Components

    There are following components included:

    • Popup / F7Popup - popup element

    Popup Properties

    Prop Type Description
    <Popup> properties
    tabletFullscreen boolean Defines whether the popup should be displayed fullscreen on tablets or not
    opened boolean Allows to open/close Popup and set its initial state
    backdrop boolean Enables Popup backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
    closeByBackdropClick boolean When enabled, popup will be closed on backdrop click. By default inherits same app parameter value (true)
    animate boolean Whether the Popup should be opened/closed with animation or not. Can be overwritten in .open() and .close() methods. By default inherits same app parameter value (true)

    Popup Methods

    <Popup> methods
    .open(animate) Open popup
    .close(animate) Close popup

    Popup Events

    Event Description
    <Popup> events
    popupOpen Event will be triggered when Popup starts its opening animation
    popupOpened Event will be triggered after Popup completes its opening animation
    popupClose Event will be triggered when Popup starts its closing animation
    popupClosed Event will be triggered after Popup completes its closing animation

    Open And Close Popup

    You can control Popup state, open and closing it:

    • using Popup API
    • by passing true or false to its opened prop
    • by clicking on Link or Button with relevant popupOpen property (to open it) and popupClose property to close it

    Access To Popup Instance

    You can access Popup initialized instance by accessing .f7Popup component's property.

    Examples

    export default class extends React.Component {
      constructor(props) {
        super(props);
    
        this.state = {
          popupOpened: false,
        }
      }
      render() {
        return (
          <Page onPageBeforeRemove={this.onPageBeforeRemove.bind(this)}>
            <Navbar title="Popup"></Navbar>
            <Block>
              <p>Popup is a modal window with any HTML content that pops up over App's main content. Popup as all other overlays is part of so called "Temporary Views".</p>
              <p>
                <Button raised popupOpen=".demo-popup">Open Popup</Button>
              </p>
              <p>
                <Button raised onClick={() => this.setState({ popupOpened : true })}>Open Via Prop Change</Button>
              </p>
              <p>
                <Button raised onClick={this.createPopup.bind(this)}>Create Dynamic Popup</Button>
              </p>
            </Block>
            <Popup className="demo-popup" opened={this.state.popupOpened} onPopupClosed={() => this.setState({popupOpened : false})}>
              <Page>
                <Navbar title="Popup Title">
                  <NavRight>
                    <Link popupClose>Close</Link>
                  </NavRight>
                </Navbar>
                <Block>
                  <p>Here comes popup. You can put here anything, even independent view with its own navigation. Also not, that by default popup looks a bit different on iPhone/iPod and iPad, on iPhone it is fullscreen.</p>
                  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non. Ut leo mauris, eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus, viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatis dignissim. Suspendisse non nisl semper tellus malesuada suscipit eu et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare consequat nunc viverra pellentesque. Aenean semper eu massa sit amet aliquam. Integer et neque sed libero mollis elementum at vitae ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibus lectus.</p>
                  <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula. Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh, suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctor vel tristique ac, malesuada ut ante. Sed molestie, est in eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque tempor congue massa quis faucibus. Vestibulum nunc eros, convallis blandit dui sit amet, gravida adipiscing libero.</p>
                </Block>
              </Page>
            </Popup>
          </Page>
        )
      }
      createPopup() {
        const self = this;
        // Create popup
        if (!self.popup) {
          self.popup = self.$f7.popup.create({
            content: `
              <div class="popup">
                <div class="page">
                  <div class="navbar">
                    <div class="navbar-inner">
                      <div class="title">Dynamic Popup</div>
                      <div class="right"><a href="#" class="link popup-close">Close</a></div>
                    </div>
                  </div>
                  <div class="page-content">
                    <div class="block">
                      <p>This popup was created dynamically</p>
                      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non. Ut leo mauris, eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus, viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatis dignissim. Suspendisse non nisl semper tellus malesuada suscipit eu et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare consequat nunc viverra pellentesque. Aenean semper eu massa sit amet aliquam. Integer et neque sed libero mollis elementum at vitae ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibus lectus.</p>
                    </div>
                  </div>
                </div>
              </div>
            `.trim(),
          });
        }
        // Open it
        self.popup.open();
      }
      onPageBeforeRemove() {
        const self = this;
        // Destroy popup when page removed
        if (self.popup) self.popup.destroy();
      }
    };