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

preact-component-console

v1.0.0

Published

A console emulator component for preact.

Downloads

5

Readme

preact-component-console

Console emulator preact component. Emulates realistic typing via dynamic char-typing delays.

NPM

npm version Build Status

Intro

Quick Start

  1. Install the package

    via NPM

    npm i --save preact-component-console

    via yarn

    yarn add preact-component-console
  2. Use the component

import Console from 'preact-component-console';

// ...

  render() {
    <Console lines={[
      'Hi there!',
      'How are you today?'
    ]} />
  }

Options

lines Array<string> | string

The lines to write.

Example

<Console
  lines={[
    'Hi there!',
    'How are you today?'
  ]}
/>

console Object

Set options on the console component.

Signature

{
  append: false, // whether to append lines
  classes: {
    element: 'console' // class to set on the root element
  },
  typing: {
    char: { // options concerning typing of individual characters
      avgMs: 150, // average duration for typing a char in milliseconds
      deviation: 0.3, // average deviation to apply to avgMs
      minMs: 50, // minimum duration for typing a char in milliseconds
      maxMs: Infinity // maximum duration for typing a char in milliseconds
    },
    line: { // options concerning typing of a line
      delay: { // options concerning the delay between lines
        avgMs: 1000, // average delay between to lines in milliseconds
        deviation: 0.5, // average deviation to apply to avgMs
        minMs: 500, // minimum delay between to lines in milliseconds
        maxMs: 1500 // maximum delay between to lines in milliseconds
      }
    }
  }
}

Example

<Console
  console={{
    classes: {
      element: 'my-console' // set console component class to 'my-console'
    }
    typing={
      char: {
        avgMs: 200 // set average duration for typing a char to 200ms
      }
    }
  }}
  lines={[
    'Hi there!',
    'How are you today?'
  ]}
/>

line Object

Set options for the line component(s).

Signature

{
  classes: {
    element: 'console-line', // class to set on a line component
    content: 'console-line-content' // class to set on the line's text content
  }
}

Example

<Console
  lines={[
    'Hi there!',
    'How are you today?'
  ]}
  line={{
    classes: {
      element: 'line-text' // set the css class name for line text to 'line-text'
    }
  }}
/>

ps1 Object

Set options for the PS1 component.

Signature

{
  classes: {
    element: 'console-ps1', // class to set on a ps1 component
  },
  content: '$' // string to display as ps1
}

Example

<Console
  lines={[
    'Hi there!',
    'How are you today?'
  ]}
  ps1={{
    content: "∆" // set the ps1 string to ∆
  }}
/>

cursor Object

Set options for the cursor.

Signature

{
  classes: {
    blink: 'console-cursor--blink', // class to set on the cursor component when visible (in addition to the class set in element)
    element: 'console-cursor', // class to set on a cursor component
    write: 'console-cursor--write' // class to set on the cursor component while writing (in additon to the class set in element)
    
  },
  intervalMs: 400 // duration between blink cycles in milliseconds
}

Example

<Console
  lines={[
    'Hi there!',
    'How are you today?'
  ]}
  cursor={{
    intervalMs: 250 // set interval for cursor blinking to 250ms
  }}
/>

Changelog

License