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

react-npc-dialogue

v1.0.4

Published

React components for creating flexible NPC dialogue boxes

Downloads

3

Readme

React NPC Dialogue

A game-like dialogue library for modular and functional dialogue boxes

Installation

npm install react-npc-dialogue

Usage

import Dialogue from 'react-npc-dialogue';

export function Demo() {
    const exampleText = [
        'Hello, my name is John Doe.',
        'I am going to now stop talking for one second.',
        1000,
        'I am back.',
        '$alert Now I am a floating window!',
        '...Ok bye.',
    ];

    return (
        <Dialogue
            text={exampleText}
            delimiter={'$'}
        />
    );
}

Props

  • text (Required): Array of strings, numbers, and functions, which will be rendered sequentially as dialogue
  • cursor: String to use as the cursor while typing
  • delayMap: Object of delay times to use for certain characters (Ex: have the printout pause for 300ms after every comma)
  • globalInput: Boolean, whether the user can click anywhere on the screen to advance dialogue
  • onComplete: Function to call when dialogue is finished
  • typeSpeed: Number of milliseconds between each character
  • width and height: Size of the dialogue box

Additional props are available when using the command parser.

Command Parser

The text array can contain commands as well as regular text. These commands can do a variety of things:

  • alert: Display an alert box with the text following the command

You can also pass a number as the command, which will be used as a delay (in milliseconds) between the command and the next line of text.

Command-Related Props:

  • commandDeliminter: String to use as the command delimiter (character at the start of a command)
  • commandHandler: Custom Function to call when a command is entered. The current commands are all implemented in the default handler, but this allows you to pass your own if needed.

Styling

By default, the dialogue is styled with the included CSS. You can override this by applying your own styles to the following classes:

  • dialogue-outer-container
  • dialogue-inner-container
  • dialogue-text
  • dialogue-inactive