1.0.2 • Published 5 years ago

react-hacker-text v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

react-hacker-text

NPM JavaScript Style Guide

npm.io npm.io

Install

npm install --save react-hacker-text
or
yarn add react-hacker-text

Usage

To render a hacker text in the page we have to import HackerText:

import React, { Component } from 'react'
import HackerText, { hackerTextFunction } from 'react-hacker-text'

class Example extends Component {
  render () {
    return (
      <HackerText text='react-hacker-text 😄🎉' />
    )
  }
}

HackerText props:

PropTypeDescription
textstringText that will be rendered.
elementstringElement that will be rendered. Default is span.
speednumberSpeed in milliseconds between characters is changed. Default is 50.
delaynumberDelay in milliseconds before the text is rendered.
changesnumberQuantity of characters to be rendered in each character.
charactersstringThe type of characters that will be showed(all, capital-letters, lower-letters, numbers, symbols). Default is all.
onStartfunctionFunction called before the render began
onFinishedfunctionFunction called when finishes the text

To render a hacker text in a input we have to import hackerTextFunction:

import React, { Component } from 'react'
import HackerText, { hackerTextFunction } from 'react-hacker-text'

class Example extends Component {
  state = {
    text: ''
  }
  
  setText = value => this.setState( {text: value} )
  
  render () {
    const options = {changes: 5, speed: 100, characters: 'symbols'}
    
    return (
      <input 
        value={this.state.text} 
        onChange={e => 
          hackerTextFunction(e.target.value, this.setText, options)
        }
      />
    )
  }
}

hackerTextFunction receive 3 params:

ParamTypeDescription
textstringText that will be displayed.
callbackfunctionFunction called with the changed text.
optionsobjectObject that accepts 3 configurations: speed, changes, and characters. Read the HackerText props to know how to use them.

License

MIT © daniellrs