├── .editorconfig ├── .eslintrc ├── .gitattributes ├── .gitignore ├── .mversionrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── examples ├── index.html ├── index.js └── main.scss ├── karma.conf.js ├── package.json ├── src ├── Backspace.jsx ├── Cursor.jsx ├── Cursor.scss ├── Delay.jsx ├── Typist.jsx └── utils.js ├── test ├── Typist.spec.js ├── tests.bundle.js └── utils.spec.js ├── webpack.config.js ├── webpack.dist.config.js ├── webpack.standalone.config.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # http://editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 2 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": "airbnb", 4 | "globals": { 5 | "__DEV__": true 6 | }, 7 | "env": { 8 | "browser": true, 9 | "node": true, 10 | "jasmine": true 11 | }, 12 | "rules": { 13 | "react/prop-types": [2, {"ignore": ["children"]}], 14 | "eqeqeq": [2, "smart"], 15 | "id-length": [0], 16 | "no-loop-func": [0], 17 | "new-cap": [2, {"capIsNew": false}], 18 | "no-shadow": [1] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Automatically normalize line endings for all text-based files 2 | # http://git-scm.com/docs/gitattributes#_end_of_line_conversion 3 | * text=auto 4 | 5 | # For the following file types, normalize line endings to LF on 6 | # checkin and prevent conversion to CRLF when they are checked out 7 | # (this is required in order to prevent newline related issues like, 8 | # for example, after the build script is run) 9 | .* text eol=lf 10 | *.css text eol=lf 11 | *.html text eol=lf 12 | *.jade text eol=lf 13 | *.js text eol=lf 14 | *.json text eol=lf 15 | *.less text eol=lf 16 | *.md text eol=lf 17 | *.sh text eol=lf 18 | *.txt text eol=lf 19 | *.xml text eol=lf 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # node-waf configuration 18 | .lock-wscript 19 | 20 | # Compiled binary addons (http://nodejs.org/api/addons.html) 21 | build/Release 22 | 23 | # Dependency directory 24 | # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git 25 | node_modules 26 | 27 | tmp 28 | examples/dist 29 | dist 30 | -------------------------------------------------------------------------------- /.mversionrc: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "precommit": "npm run dist && npm run standalone && git add dist", 4 | "postcommit": "git push origin master --tags && npm publish", 5 | "postupdate": "echo 'Updated to version %s in manifest files'" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - iojs 5 | - '0.12' 6 | - '0.10' 7 | matrix: 8 | allow_failures: 9 | - node_js: iojs 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # React Typist Changelog 2 | 3 | ### v1.1.1 (05/29/17) 4 | 5 | - Fixes 6 | + Updated dist code 7 | 8 | - Development: 9 | + Added dist command to the contribution section 10 | + Added prop-types to package dependencies 11 | 12 | 13 | ### v1.1.0 (03/26/17) 14 | 15 | - Features: 16 | + Add new options: `onCharacterTyped` and `onLineTyped` (#22) 17 | 18 | - Fixes 19 | + Fix text rendering issue in webkit/blink under certain widths (#13) 20 | 21 | - Development: 22 | + Remove bower package 23 | 24 | 25 | ### v1.0.3 (10/29/16) 26 | 27 | - Fixes 28 | + Component no longer sets `isDone` state if unmounted 29 | 30 | 31 | ### v1.0.1 (10/01/16) 32 | 33 | - Fixes 34 | + Move `promise-mock` to `devDependencies` 35 | 36 | 37 | ### v1.0.0 (10/01/16) 38 | 39 | This version should have no breaking changes, but given that we've bumped a 40 | major version of React, we decided to make this release opt-in, in case 41 | unexpected errors occur. 42 | 43 | - Fixes: 44 | + Can now use server rendering 45 | + Component no longer sets state after being unmounted 46 | 47 | - Development: 48 | + Upgrade to React 15 49 | + Upgrade to Babel 6, and other tooling upgrades 50 | + Switch to promises to make code more concise and readable 51 | 52 | 53 | ### v0.3.0 (10/30/15) 54 | 55 | - Features: 56 | 57 | + Typist can now render and animate any React element (not just strings). 58 | + You can now pass new options for the cursor: 59 | + `hideWhenDone` 60 | + `hideWhenDoneDelay` 61 | + Typist now supports a `delayGenerator` function to customize the delay 62 | between keystrokes. 63 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | Source: http://opensource.org/licenses/MIT -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Typist [![npm](https://img.shields.io/npm/dm/react-typist.svg)]() [![npm](https://img.shields.io/npm/v/react-typist.svg)]() 2 | React Component for making typing animations. Wrap `Typist` around your text or any 3 | element tree to animate text inside the tree. Easily stylable and highly 4 | configurable. 5 | 6 | 7 | ## Install 8 | ```shell 9 | npm install react-typist --save 10 | ``` 11 | 12 | 13 | ## Live Example 14 | * Basic example 15 | 16 | 17 | ## Basic Usage 18 | #### CommonJS Module (using webpack or browserify): 19 | ```jsx 20 | import React, {Component} from 'react'; 21 | import Typist from 'react-typist'; 22 | 23 | export default class MyComponent extends Component { 24 | 25 | render() { 26 | return ( 27 | 28 | Animate this text. 29 | 30 | ); 31 | } 32 | } 33 | ``` 34 | 35 | #### UMD module: 36 | Include `dist/standalone/Typist.js` into your build, using whatever build tool 37 | or manually entering a ` 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import Typist from 'react-typist'; 4 | import './main.scss'; 5 | 6 | class TypistExample extends React.Component { 7 | state = { 8 | renderMsg: false, 9 | } 10 | 11 | onHeaderTyped = () => { 12 | this.setState({ renderMsg: true }); 13 | } 14 | 15 | render() { 16 | const docs = '//github.com/jstejada/react-typist'; 17 | return ( 18 |
19 | 25 | React Typist 26 | 27 |
28 | {this.state.renderMsg ? ( 29 | 33 | * Easy to style 34 | 35 |
36 | * Easy to customize 37 | 38 |
39 | * Easy to use backspace 40 | 41 | 42 | space 43 | 44 |
45 | * docs 46 |
47 | {''} 48 |
49 | ) : null } 50 |
51 |
52 | ); 53 | } 54 | 55 | } 56 | 57 | ReactDOM.render(, document.getElementById('content')); 58 | -------------------------------------------------------------------------------- /examples/main.scss: -------------------------------------------------------------------------------- 1 | $bg-color: #333; 2 | $bl-color: #22BAD9; 3 | 4 | 5 | body { 6 | font-family: monospace; 7 | font-size: 18px; 8 | line-height: 1.7; 9 | background-color: #333333; 10 | padding: 25px 50px; 11 | } 12 | 13 | .TypistExample { 14 | 15 | a { 16 | color: inherit; 17 | &:hover { 18 | background-color: $bl-color; 19 | color: white; 20 | text-decoration: none; 21 | } 22 | } 23 | &-header { 24 | margin-top: 5%; 25 | margin-bottom: 15%; 26 | text-align: center; 27 | font-size: 3em; 28 | cursor: pointer; 29 | color: $bl-color; 30 | } 31 | &-message { 32 | color: hotpink; 33 | width: 400px; 34 | margin: auto; 35 | .flash { 36 | color: $bl-color; 37 | font-weight: bold; 38 | text-decoration: underline; 39 | 40 | animation-name: blinker; 41 | animation-duration: 0.7s; 42 | animation-timing-function: linear; 43 | animation-iteration-count: infinite; 44 | @keyframes blinker { 45 | 0% { opacity: 1.0; } 46 | 50% { opacity: 0.0; } 47 | 100% { opacity: 1.0; } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | const webpackConfig = require('./webpack.config'); 2 | webpackConfig.devtool = 'inline-source-map'; 3 | 4 | module.exports = function(config) { 5 | config.set({ 6 | browsers: [ 'Chrome' ], 7 | files: [ 8 | { 9 | pattern: 'test/tests.bundle.js', 10 | watched: false, 11 | }, 12 | ], 13 | frameworks: [ 'jasmine' ], 14 | preprocessors: { 15 | 'test/tests.bundle.js': [ 'webpack', 'sourcemap' ], 16 | }, 17 | reporters: [ 'dots' ], 18 | singleRun: true, 19 | webpack: webpackConfig, 20 | webpackServer: { 21 | noInfo: true, 22 | }, 23 | }); 24 | }; 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-typist", 3 | "version": "2.0.5", 4 | "description": "Typing animations with React", 5 | "main": "dist/Typist.js", 6 | "files": ["dist", "src"], 7 | "style": "dist/Typist.css", 8 | "scripts": { 9 | "dist": "webpack --config webpack.dist.config.js", 10 | "standalone": "webpack --config webpack.standalone.config.js", 11 | "examples": "webpack --devtool inline-source-map", 12 | "start": "webpack-dev-server --devtool inline-source-map --progress --colors --inline --hot --public typist.dev:8080 --content-base examples", 13 | "test": "karma start karma.conf.js" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/jstejada/react-typist" 18 | }, 19 | "keywords": [ 20 | "react", 21 | "reactjs", 22 | "react-typist", 23 | "react typist", 24 | "typing", 25 | "typing animation", 26 | "typing animations", 27 | "animation", 28 | "animations", 29 | "typist", 30 | "typewriter", 31 | "typewriter animation", 32 | "typewriter animations" 33 | ], 34 | "author": "Juan Tejada", 35 | "license": "MIT", 36 | "peerDependencies": { 37 | "react": "^0.14 || ^15.0 || ^16.0", 38 | "react-dom": "^0.14 || ^15.0 || ^16.0" 39 | }, 40 | "devDependencies": { 41 | "autoprefixer": "^6.3.3", 42 | "babel-core": "^6.7.2", 43 | "babel-eslint": "^6.0.0-beta.6", 44 | "babel-loader": "^6.2.4", 45 | "babel-plugin-transform-class-properties": "^6.16.0", 46 | "babel-preset-es2015": "^6.6.0", 47 | "babel-preset-react": "^6.5.0", 48 | "babel-preset-stage-0": "^6.16.0", 49 | "css-loader": "^0.23.1", 50 | "eslint": "^2.4.0", 51 | "eslint-config-airbnb": "^6.1.0", 52 | "eslint-loader": "^1.3.0", 53 | "eslint-plugin-react": "^4.2.3", 54 | "eslint_d": "^4.1.0", 55 | "extract-text-webpack-plugin": "^1.0.1", 56 | "jasmine-core": "^2.3.4", 57 | "jasmine-react-matchers": "^1.0.2", 58 | "karma": "^0.13.10", 59 | "karma-chrome-launcher": "^0.2.0", 60 | "karma-cli": "^0.1.1", 61 | "karma-jasmine": "^0.3.6", 62 | "karma-sourcemap-loader": "^0.3.5", 63 | "karma-webpack": "^1.7.0", 64 | "mock-promises": "^0.6.1", 65 | "node-sass": "^3.4.2", 66 | "postcss-loader": "^0.8.2", 67 | "promise-mock": "^1.1.0", 68 | "react": "^16.0.0", 69 | "react-dom": "^16.0.0", 70 | "sass-loader": "^3.2.0", 71 | "style-loader": "^0.13.0", 72 | "webpack": "^1.12.14", 73 | "webpack-dev-server": "^1.14.1" 74 | }, 75 | "dependencies": { 76 | "prop-types": "^15.5.10" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Backspace.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import PropTypes from 'prop-types'; 3 | 4 | const Backspace = () =>