Git Product home page Git Product logo

Riddlevox

Riddlevox is an open-source TypeScript widget that will help you capture more leads with email opt-in forms. This is a rough and untested widget, built in a couple of hours to be used solely for demonstrating the power of Shopify's script tag API.

Do not use this widget in production, it has not been extensively tested.

Riddlevox

Installation

You can install this package using npm:

npm install @nozzlegear/riddlevox --save

##Usage

For proper display on mobile, the target website must have set a meta viewport tag with width=device-width, initiali-scale=1.0. This will already be set on Shopify store fronts, unless the store has explicitly installed a goofy, mobile-hostile theme.

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

Configuring Riddlevox

Riddlevox can be configured with the following options, by passing them in as an object to the Riddlevox constructor:

const options = 
{
    position: "bottom-right",
    title: "Sign up for our mailing list!",
    message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
    buttonText: "Sign up!",
    defaultThankYouMessage: "Thank you! Your subscription to our mailing list has been confirmed.",
    backgroundColor: "#34495e",
    // Whether Riddlevox should inject its own CSS style tag onto the page.
    // Default value: false
    injectCss: true,
    onConversion: function (firstName, emailAddress, vox) {
        console.log("Conversion received.", firstName, emailAddress);

        if (!fname || !email)
        {
            vox.showError("You must enter a valid first name and email address.");

            return;
        }

        vox.showThankYouMessage();
    }
}

new Riddlevox() and vox.start()

Before you can use Riddlevox, you must construct a new instance of it while passing in the options.

import { RiddleVox } from "@nozzlegear/riddlevox";

const vox = new Riddlevox(options);

//Show Riddlevox's unopened tab on the page.
vox.start();

At this point, nothing will be displayed even though Riddlevox has been added to the page's DOM. Call vox.start() to show the title tab.

//Show Riddlevox's title tab.
vox.start();

Clicking on the title tab will open and close Riddlevox's form.

vox.open() and vox.close()

While the user can click on Riddlevox's title tab to open and close the form, you can also open and close it programatically.

//Open Riddlevox's form
vox.open();

//Close Riddlevox's form
vox.close();

vox.showError() and vox.hideError()

Riddlevox lets you show or hide an error message on its form. It should be used when validating their email details after they've submitted the form.

//Show an error on Riddlevox's form.
vox.showError("Please enter a valid email address.");

//Hide that error
vox.hideError();

vox.hideError will be called automatically by Riddlevox each time the user submits the form.

vox.showThankYouMessage()

After the user has submitted their details, assuming it passes your validation, you can show the previously configured default thank-you message, or you can pass in a custom message with dynamic information. This will hide Riddlevox's email capture form and display the thank-you message in place of it.

// Show the default thank-you message
vox.showThankYouMessage();
// Show a custom thank-you message with dynamic information like the user's first name
vox.showThankYouMessage(`Thanks for joining our mailing list, ${firstName}!`); 

vox.options.onConversion()

Configure your onConversion handler by setting it in Riddlevox's options. When the user submits Riddlevox's email capture form, your onConversion handler will be called and receive the user's first name, their email address and the instance of Riddlevox that owns the form.

This is a great time to validate the information they've provided, show an error message if necessary, or else show the thank-you message.

const options = 
{
    ...
    onConversion: function (firstName, emailAddress, vox) {
        console.log("Conversion received.", firstName, emailAddress);

        if (!fname || !email)
        {
            vox.showError("You must enter a valid first name and email address.");

            return;
        }

        vox.showThankYouMessage();
    },
    ...
}

vox.destroy()

If you want to completely remove Riddlevox from the page, including Riddlevox's title tab, you can use this method. Note that after destroying Riddlevox, you must create and start a new instance to use it again.

vox.destroy();

Learn how to build rock-solid Shopify apps with C# and ASP.NET

Riddlevox was built to showcase the power of Shopify's script tag API, which lets you inject your own, custom scripts and JS libraries onto a Shopify store's website. It's a great way to add dynamic functionality or analytics to a merchant's store front.

I've created a premium course for building rock-solid Shopify apps with C# and ASP.NET, and one of the chapters deals specifically with using custom JavaScript widgets and libraries to add things like Riddlevox to a Shopify store. It's called The Shopify Development Handbook, and you can get a free preview with real, production-ready code samples by going to https://nozzlegear.com/shopify-development-handbook.

Joshua Harms's Projects

add-ts-webpack icon add-ts-webpack

A small command line tool for adding the necessary dependencies for a TypeScript + React + Babel app built with webpack.

alexa-message-builder icon alexa-message-builder

A .NET Standard package for building Alexa messages. Inspired by the NPM package 'alexa-message-builder'.

animatetransition icon animatetransition

Library for transition animations between blocks (pages) in the application.

arenamarker icon arenamarker

An addon for World of Warcraft which marks friendly arena players with raid target icons when entering the arena

artist-tally-tool icon artist-tally-tool

This is a simple Dart tool that emails a tally of a client's graphic artist workload for the previous day.

auto-prop-component icon auto-prop-component

A small React component which lets you generically update a component's state rather than relying on dozens of tiny functions.

awesome-dotnet-core icon awesome-dotnet-core

:honeybee: A collection of awesome .NET core libraries, tools, frameworks and software

azure-functions icon azure-functions

This repository is full of custom Azure functions (like AWS Lambda) that I use. Most are Alexa skills, some are daily roundup emails.

bagbarhider icon bagbarhider

A small WoW addon that hides the bag bar by default and adds slash commands to show it.

barrelsby icon barrelsby

Automatic TypeScript barrels (index.ts files) for your entire code base

bash-snippets icon bash-snippets

A collection of small bash scripts for heavy terminal users

bigdebuffs icon bigdebuffs

A fork of BigDebuffs with some changes/fixes for Dragonflight.

blackfuse icon blackfuse

Blackfuse is an F# + Fable starter project for building @Shopify apps in a type-safe, functional-first way while utilizing the .NET ecosystem.

bogpaddle icon bogpaddle

CLI utility for hashing a "secret" string to SHA512 and copying the hash to the clipboard.

caprine icon caprine

Elegant Facebook Messenger desktop app

cc-expiry icon cc-expiry

An NPM package for formatting credit card expiry dates in MM/YY or MM/YYYY formats.

chromely icon chromely

Lightweight Alternative to Electron.NET, Electron for .NET/.NET Core

clockit icon clockit

Small timeclock app built for a friend.

collage icon collage

A sample application for Filepicker.io that allows people to assemble their online photos into collages.

convertkitforwindows icon convertkitforwindows

A public repository for the (unofficial) ConvertKit for Windows app. This app is in the Windows app store.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.