|
| 1 | +# React Typical |
| 2 | + |
| 3 | +> Typist library made in React with TypeScript support by [@deadcoder0904](https://twitter.com/deadcoder0904) |
| 4 | +
|
| 5 | +## Highlights |
| 6 | + |
| 7 | +- **Written in TypeScript** |
| 8 | +- **Zero dependencies** |
| 9 | +- **MIT licensed** |
| 10 | +- **Emoji support** |
| 11 | +- **Pausing**: pause between steps |
| 12 | +- **Looping**: easily loop from any point |
| 13 | +- **Humanity**: slightly varied typing speed |
| 14 | + |
| 15 | +## Install |
| 16 | + |
| 17 | +```bash |
| 18 | +$ npm install @deadcoder0904/react-typical |
| 19 | +``` |
| 20 | + |
| 21 | +## Usage |
| 22 | + |
| 23 | +### Basic |
| 24 | + |
| 25 | +```tsx |
| 26 | +import React from 'react' |
| 27 | +import { ReactTypical } from '@deadcoder0904/react-typical' |
| 28 | + |
| 29 | +const Index = () => ( |
| 30 | + <ReactTypical |
| 31 | + steps={['Hello', 'React Typical']} |
| 32 | + wrapper="p" |
| 33 | + /> |
| 34 | +) |
| 35 | +``` |
| 36 | + |
| 37 | +### Emoji Support |
| 38 | + |
| 39 | +```tsx |
| 40 | +import React from 'react' |
| 41 | +import { ReactTypical } from '@deadcoder0904/react-typical' |
| 42 | + |
| 43 | +const Index = () => ( |
| 44 | + <ReactTypical |
| 45 | + steps={['💩',1000, '🙈',1000,'💖',1000,'🚀',1000,'👨🎤',1000]} |
| 46 | + wrapper="p" |
| 47 | + /> |
| 48 | +) |
| 49 | +``` |
| 50 | + |
| 51 | +### Pausing |
| 52 | + |
| 53 | +In order to pause at any point, pass a number of milliseconds to `steps` prop to pause. |
| 54 | + |
| 55 | +```tsx |
| 56 | +import React from 'react' |
| 57 | +import { ReactTypical } from '@deadcoder0904/react-typical' |
| 58 | + |
| 59 | +const Index = () => ( |
| 60 | + <ReactTypical |
| 61 | + steps={['Hello', 1000, 'React Typical', 2000]} |
| 62 | + wrapper="p" |
| 63 | + /> |
| 64 | +) |
| 65 | +``` |
| 66 | + |
| 67 | +### Looping |
| 68 | + |
| 69 | +In order to loop, just pass a number to `loop` prop, for example, if you want to loop 3 times. |
| 70 | + |
| 71 | +```tsx |
| 72 | +import React from 'react' |
| 73 | +import { ReactTypical } from '@deadcoder0904/react-typical' |
| 74 | + |
| 75 | +const Index = () => ( |
| 76 | + <ReactTypical |
| 77 | + steps={['Hello', 1000, 'React Typical', 2000]} |
| 78 | + loop={3} |
| 79 | + wrapper="p" |
| 80 | + /> |
| 81 | +) |
| 82 | +``` |
| 83 | + |
| 84 | +Or pass `Infinity` to loop infinitely. |
| 85 | + |
| 86 | +```tsx |
| 87 | +import React from 'react' |
| 88 | +import { ReactTypical } from '@deadcoder0904/react-typical' |
| 89 | + |
| 90 | +const Index = () => ( |
| 91 | + <ReactTypical |
| 92 | + steps={['Hello', 1000, 'React Typical', 2000]} |
| 93 | + loop={Infinity} |
| 94 | + wrapper="p" |
| 95 | + /> |
| 96 | +) |
| 97 | +``` |
| 98 | + |
| 99 | +## API |
| 100 | + |
| 101 | +| property | required | type | example | |
| 102 | +| --------- | -------- | ------ | --------------------------------------- | |
| 103 | +| `steps` | yes | [] | `['Hello', 1000, 'React Typical', 500]` | |
| 104 | +| `wrapper` | no | string | `'p'` or `'div'` | |
| 105 | +| `loop` | no | number | `3` or `Infinity` | |
| 106 | + |
| 107 | +## Motivation & Inspiration |
| 108 | + |
| 109 | +I wanted to use a typist library in React with TypeScript but couldn't find any. I found out there was a React Typist library known as [React Typical](https://github.com/catalinmiron/react-typical/) which used [@camwiegert/typical](https://github.com/camwiegert/typical) but both libraries weren't written in TypeScript. So I made this library which just uses the exact same code but in TypeScript & it was too much hassle to convert it into TypeScript. 10/10 wouldn't recommend. |
0 commit comments