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

@lightspeed/cirrus-nps

v1.0.4

Published

Lightspeed Nps component

Downloads

33

Readme

Nps

The NPS component allows you to display a small pop-up window that asks user's to rate a particular subject.

There is no actual call to an API done, you'll need to integrate that yourself!

Installation

First, make sure you have been through the install steps steps required to add Flame in your application. Although it's not required to have Flame installed to use Logo, you will need to install its peer dependencies.

If using Yarn:

yarn add @lightspeed/cirrus-nps

Or using npm:

npm i -S @lightspeed/cirrus-nps

React Component

Props

| Prop | Type | Description | | -------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | onSubmit | (score: number, message: string) => void | Callback function invoked on submit. It receives the user inputted score and message as parameters. | | onIgnore | () => void | Callback that is invoked when the "ignore" button is clicked. | | translations | Object | The translation object. By default, an english version is bundled. You may of course use your own sets of translations. See further below for an example of the translation object. |

Example

import * as React from 'react';
import { Nps } from '@lightspeed/cirrus-nps';

const myTranslations = {
  // Insert translations here...
};

const MyComponent: React.FC = () => (
  <div>
    <Nps
      onIgnore={() => {
        console.log('The person chose to ignore the NPS');
      }}
      onSubmit={(score, message) => {
        console.log('submitting:', score, message);
      }}
      translations={myTranslations}
    />
  </div>
);

export default MyComponent;

Translation Object

The translation object has the following shape:

interface Translation {
  NPS_SUBJECT: string;
  NOT_NOW: string;
  ZERO_VERY_UNSATISFIED: string;
  TEN_VERY_SATISFIED: string;
  CHANGE_YOUR_ANSWER: string;
  SUBMIT: string;
  REASONING_FOR_SCORE: string | (score: number) => void;
  THANK_YOU_MESSAGE: string;
}

Since REASONING_FOR_SCORE is dynamic, you may input either a static string or a function that generates a string.

Here is an example implementation of the translation object.

const translation: Translation = {
  NPS_SUBJECT: 'How likely are you to recommend "Lightspeed" to a friend in the retail industry?',
  NOT_NOW: 'Not now',
  ZERO_VERY_UNSATISFIED: 'Not likely',
  TEN_VERY_SATISFIED: 'Very likely',
  CHANGE_YOUR_ANSWER: 'Change your answer',
  SUBMIT: 'Submit',
  THANK_YOU_MESSAGE: 'Thanks for your feedback!',
  REASONING_FOR_SCORE: (score: any) => `Tell us a bit more about why you chose ${score}?`,
};

A defaultTranslation object is provided, should you choose to override only certain properties...

import * as React from 'react';
import { Nps, defaultTranslation } from '@lightspeed/cirrus-nps';

const myTranslations = {
  ...defaultTranslation,
  NPS_SUBJECT: 'How do you like the new emoji pricing feature?',
};

const MyComponent: React.FC = () => (
  <div>
    <Nps
      translations={myTranslations}
      onIgnore={() => {
        /* insert some functionality here */
      }}
      onSubmit={(score, message) => {
        /* insert some functionality here */
      }}
    />
  </div>
);

export default MyComponent;