Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-monnot committed Jan 23, 2018
0 parents commit 8433c65
Show file tree
Hide file tree
Showing 26 changed files with 8,297 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
"es2015",
"react"
],
"plugins": [
"syntax-dynamic-import"
]
}
5 changes: 5 additions & 0 deletions .bithoundrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore": [
"dist/*.js"
]
}
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
26 changes: 26 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"browser": true,
"jasmine": true,
"node": true
},
"plugins": [
"react"
],
"rules": {
"comma-dangle": ["error", "never"],
"global-require": 0,
"prefer-arrow-callback": 0,
"func-names": 0,
"import/no-extraneous-dependencies": 0,
"no-underscore-dangle": 0,
"no-unused-expressions": 0,
"no-use-before-define": 0,
"react/jsx-filename-extension": 0,
"react/sort-comp": 0,
"react/no-multi-comp": 0,
"react/require-extension": 0
}
};
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
bin/* eol=lf
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
docs/build/
dist-es6/
dist-modules/
node_modules/
coverage/
/.idea/
npm-debug.log
.eslintcache
style.min.css
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
demo/
dist/
tests/
src/
.*

10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: node_js
node_js:
- "6"
- "7"
- "8"
script:
- npm run test:lint
- npm run test:coverage
after_success:
- bash <(curl -s https://codecov.io/bash)
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2016 Stéphane Monnot

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:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

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.
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[![build status](https://secure.travis-ci.org/stephane-monnot/react-fake-code-typing.svg)](http://travis-ci.org/stephane-monnot/react-fake-code-typing) [![bitHound Score](https://www.bithound.io/github/stephane-monnot/react-fake-code-typing/badges/score.svg)](https://www.bithound.io/github/stephane-monnot/react-fake-code-typing) [![Dependency Status](https://david-dm.org/stephane-monnot/react-fake-code-typing.svg)](https://david-dm.org/stephane-monnot/react-fake-code-typing)

# react-fake-code-typing - Fake code typing for React.js

## Full documentation & Demo

[React Fake Code Typing documentation](https://stephane-monnot.github.io/react-fake-code-typing/)


## Install

```code
$ npm i react-fake-code-typing
```


## Usage

```code|lang-jsx
---
import { FakeCodeTyping } from 'react-fake-code-typing';
import 'react-fake-code-typing/style.min.css';
const testCode = `
function setError($errorcode) {
      $this->errorcode = $errorcode;
      $this->error = $this->errors[$errorcode];
      }
}
function getError($errormessage = '') {
      $error = $this->errorcode.$this->errormessage;
      return $error;
      exit;
}
/**
* @link Home
* @todo ..write a 404 page that actually makes sense.
*/
$err->setError(404);
$err->getError("Page Not Found");`;
...
<FakeCodeTyping>
<pre>
{testCode}
</pre>
</FakeCodeTyping>
```


## FakeCodeTyping Props

### `speed={ Number }`

Typing speed (default: 12).


## Showcase

* Coming soon


## For development
### Launch the demo with catalog
```code
$ yarn start
```

### Run the tests
```code
$ yarn test
```

### Watch and Run the tests
```code
$ yarn test:watch
```

### Run lint
```code
$ yarn test:lint
```

### Publish new version (only for maintainers)
```code
$ yarn publish
```

## License

*react-fake-code-typing* is available under MIT. See LICENSE for more details.
18 changes: 18 additions & 0 deletions __tests__/FakeCodeTypingLine_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import {
renderIntoDocument,
findRenderedDOMComponentWithClass
} from 'react-dom/test-utils';

import FakeCodeTypingLine from '../src/FakeCodeTypingLine';

describe('FakeCodeTypingLine', function () {
it('should have the fake-code-typing-line classname', function () {
const component = renderIntoDocument(
<FakeCodeTypingLine delay={2} duration={2} count={3} keepBorder={false}>
test1
</FakeCodeTypingLine>
);
findRenderedDOMComponentWithClass(component, 'fake-code-typing-line');
});
});
16 changes: 16 additions & 0 deletions __tests__/FakeCodeTyping_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import {
renderIntoDocument,
findRenderedDOMComponentWithClass
} from 'react-dom/test-utils';

import FakeCodeTyping from '../src/FakeCodeTyping';

describe('FakeCodeTyping', function () {
it('should have the fake-code-typing classname', function () {
const component = renderIntoDocument(
<FakeCodeTyping><pre>test1</pre></FakeCodeTyping>
);
findRenderedDOMComponentWithClass(component, 'fake-code-typing');
});
});
3 changes: 3 additions & 0 deletions __tests__/shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
global.requestAnimationFrame = (callback) => {
setTimeout(callback, 0);
};
7 changes: 7 additions & 0 deletions catalog.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint no-param-reassign: 0 */
module.exports = {
webpack: (catalogWebpackConfig) => {
catalogWebpackConfig.output.publicPath = '';
return catalogWebpackConfig;
}
};
12 changes: 12 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>React Fake Code Typing</title>
</head>
<body>
<div id="catalog"></div>
</body>
</html>
79 changes: 79 additions & 0 deletions docs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable global-require, import/no-unresolved, react/no-multi-comp */
/* eslint-disable no-irregular-whitespace */
import React from 'react';
import ReactDOM from 'react-dom';
import GithubCorner from 'react-github-corner';
import { Catalog, CodeSpecimen, ReactSpecimen, pageLoader } from 'catalog';
import 'purecss/build/pure.css';

import { FakeCodeTyping } from '../src/index';
import './main.css';
import '../style.css';

const testCode = `
function setError($errorcode) {
      $this->errorcode = $errorcode;
      $this->error = $this->errors[$errorcode];
      }
}
function getError($errormessage = '') {
      $error = $this->errorcode.$this->errormessage;
      return $error;
      exit;
}
/**
* @link Home
* @todo ..write a 404 page that actually makes sense.
*/
$err->setError(404);
$err->getError("Page Not Found");`;

// Add your documentation imports here. These are available to
// React specimen. Do NOT pass React here as Catalog does that.
const documentationImports = {};
const pages = [
{
path: '/',
title: 'Introduction',
content: pageLoader(() => import('../README.md'))
},
{
path: '/demo',
title: 'Demo',
content: () => (
<FakeCodeTyping>
<pre>
{testCode}
</pre>
</FakeCodeTyping>
)
}
];

// Catalog - logoSrc="../images/logo.png"
ReactDOM.render(
<div>
<GithubCorner
href="https://github.com/stephane-monnot/react-fake-code-typing"
bannerColor="#fff"
octoColor="#000"
width={80}
height={80}
direction="right"
/>
<Catalog
imports={documentationImports}
pages={pages}
theme={{ background: '#e3e3e3' }}
specimens={{
javascript: props => <CodeSpecimen {...props} lang="javascript" />,
js: props => <CodeSpecimen {...props} lang="javascript" />,
jsx: props => <ReactSpecimen {...props} />
}}
title="Fake Code Typing"

/>
</div>,
document.getElementById('catalog')
);
3 changes: 3 additions & 0 deletions docs/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.github-corner svg {
z-index: 1000;
}
28 changes: 28 additions & 0 deletions lib/post_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable */
// adapted based on rackt/history (MIT)
// Node 0.10+
var execSync = require('child_process').execSync;
var stat = require('fs').stat;

// Node 0.10 check
if (!execSync) {
execSync = require('sync-exec');
}

function exec(command) {
execSync(command, {
stdio: [0, 1, 2]
});
}

stat('dist-modules', function(error, stat) {
// Skip building on Travis
if (process.env.TRAVIS) {
return;
}

if (error || !stat.isDirectory()) {
exec('npm i babel-cli babel-preset-es2015 babel-preset-react');
exec('npm run dist:modules');
}
});
Loading

0 comments on commit 8433c65

Please sign in to comment.