Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eventespresso/react-exit-modal-typeform

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eventespresso/react-exit-modal-typeform

React component that allows the triggering of an typeform form via modal

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React Exit Modal for Typeform

This is a react component that provides an embedded typeform for use a exit modal survey. Use-cases are:

  • Applications that want to collect information when users cancel a subscription or deactivate a feature in the main app.
  • Triggering a Typeform survey from any user action in an application.

The modal that opens has an initial "options" view where the user is presented with two buttons. One to fill out a survey, and another to skip the survey. Skipping the survey will continue on with the original action triggered. If they choose to fill out a survey, then the next view in the modal will present them with an embedded typeform to fill out.

Installation

Install the module

npm install @eventespresso/react-exit-modal-typeform

Usage

A very basic usage example (triggering outside react):

  1. Importing the component
  2. Attaching the modal to the DOM on your trigger action
  3. Setting a listener for the custom modal close callback
import React from 'react';
import ReactDOM from 'react-dom';
import $ from 'jquery';
import ReactModal from 'react-modal';
import ExitModal, { CLOSE_MODAL_EVENT } from '@eventespresso/react-exit-modal-typeform';

const modalProps = {
    typeFormUrl: 'https://yourtypeformdomain.typeform.com/to/XXXXX'
}

/**
* Element that the modal is anchored to
*/
const modalAnchor = document.getElementById('react-cancel-modal');

let modalComponent = {};

const closeModalCallback = (e) => {
    //do stuff that happens after the modal closes, eg continue with a subscription cancel action etc.
    processSubscriptionCancel();
    //make sure you remove the event listener.
    modalComponent.el.removeEventListener(CLOSE_MODAL_EVENT, closeModalCallback);
};

$('.some-dom-element-trigger-container').on('click', '.element-clicked', function(e) {
   e.preventDefault();
   ReactModal.setAppElement(modalAnchor);
   modalComponent = ReactDOM.render(
       <ExitModal {...modalProps} />,
       modalAnchor
   );
   
   //set listener
   modalComponent.el.addEventListener(
       CLOSE_MODAL_EVENT,
       closeModalCallback,
       false
    );
});

There are a number of properties you can use to control the ExitModal. The only required property is the typeFormUrl property.

PropertyTypeDescription
showModalboolWhether to initialize with the modal open or not.
showTypeFormboolWhether to display the typeForm right away or not.
stylesobjectYou set inline styles for the modal via this property.
styles.overlayobjectInline styles for the overlay when the modal is open. Use javascript DOM style notation for the keys.
Note: It's recommended you use modalClassName and style via css class instead. However inline styles are provided for cases where style attributes may be dynamically calculated.
styles.contentobjectInline styles for the modal content container.
styles.typeFormStyleobjectInline styles for the container holding the embedded typeform (defaults to 600x400).
buttonClassobjectProvde css class for button styles.
buttonClass.doSurveystringCSS classname for the button triggering doing the survey.
buttonClass.closeModalstringCSS classname for the button triggering closing the modal.
modalClassNameobjectProvide css class to use with styling.
modalClassName.contentstringCSS classname to use for the modal content container.
modalClassName.overlaystringCSS classname to use for the modal overlay.
typeFormUrlstringrequired The url to your TypeForm that will be embedded in the modal content.
introTextstringText displayed in the initial view. Defaults to We're sorry to see you go! Will you share feedback through a short survey to help us improve our product?
skipButtonTextstringSkip button text. Defaults to Skip
doSurveyButtonTextstringStart survey button text. Defaults to Sure I'll help!

Keywords

FAQs

Package last updated on 21 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc