npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@turbofan/turbofan-js

v0.2.0

Published

A helper script for sending form data to the Turbofan API

Downloads

9

Readme

Usage

Add the form to your HTML

Default ID: #turbofan-form

Add the barebones subscription form and extend it to your liking:

<form id="turbofan-form" action="https://api.turbofan.email/v1/form/FORM-ID-HERE/register" method="post">
	<input name="email" type="email" autocomplete="email" required>

	<button type="submit">Sign up</button>
</form>

Or add the extended form to start with:

<form id="turbofan-form" action="https://api.turbofan.email/v1/form/FORM-ID-HERE/register" method="post">
	<label for="firstname">Your first name</label>
	<input id="firstname" name="firstname" type="text" autocomplete="given-name" required>

	<label for="email-address">Your email</label>
	<input id="email-address" name="email" type="email" autocomplete="email" required>

	<button type="submit">Sign up</button>

	<div class="spinner turbofan-hidden">Sending ...</div>

	<p class="success-msg turbofan-hidden">Thank you, please <span class="inbox-link">check your inbox</span> to confirm your subscription!</p>
	<p class="error-msg turbofan-hidden">Error, please try again later.</p>

	<p>By clicking the button above, you agree to our <a href="/privacy/" target="_blank">privacy policy</a> and for the use of your email address to receive our newsletter.</p>
</form>

Here, the optional elements are used:

  • Loading spinner (default class: spinner)
  • Successful signup (default class: success-msg)
  • Error during signup (default class: error-msg)
  • Inbox link placeholder (default class: inbox-link)

Note that if you don't have CSS helper classes for hidden elements or hidden for screen readers only, you can include the optional stylesheet before </head>:

<link href="style.css?v=0.1.1" rel="stylesheet">

(optional) Add an error message to your confirmation page

<div id="turbofan-confirm">
	<p class="error-msg turbofan-hidden">Error, please try again later.</p>
</div>

Include settings

Include the settings on all pages with a form and the confirmation page, before </body>:

<script>
const turbofanSettings = {
	apiHost: 'https://api.turbofan.email',
	confirmationPathname: '/my-confirm-page/',
	formSelector: '#turbofan-form',
	formSuccessMsgSelector: '#turbofan-form .success-msg',
	formErrorMsgSelector: '#turbofan-form .error-msg',
	formInboxLinkSelector: '#turbofan-form .inbox-link',
	formSpinnerSelector: '#turbofan-form .spinner',
	confirmErrorMsgSelector: '#turbofan-confirm .error-msg',
	hiddenClass: 'turbofan-hidden',
};
</script>

Setting | Description | Default value | Required? ---|---|---|--- apiHost | URL of the API, override to test locally | https://api.turbofan.email | No confirmationPathname | Path to your signup confirmation page (link in the confirmation email) | /signup-confirmed/ | No hiddenClass | Name of CSS class | turbofan-hidden | No

Option A: As a module (ESM)

Include the script on the page with the sign up form, after the settings and before </body>:

<script src="signup.js?v=0.1.1" type="module"></script>

Include the script on the confirmation page, after the settings and before </body>:

<script src="confirm.js?v=0.1.1" type="module"></script>

Option B: Use the bundle

Include the script on both the page with the sign up form and the confirmation page, after the settings and before </body>:

<script src="turbofan.bundle.js?v=0.1.1"></script>

Development

  • npm install
  • npm run dev