Skip to content

Commit 74da2c7

Browse files
Jonathan YannesJonathan Yannes
Jonathan Yannes
authored and
Jonathan Yannes
committed
initial commit
1 parent 4dd8f62 commit 74da2c7

16 files changed

+457
-0
lines changed

.bowerrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"scripts": {
3+
"postinstall": "npm run rename-css-bower-dependencies"
4+
}
5+
}

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[*]
2+
indent_style = space
3+
indent_size = 2
4+
charset = utf-8
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true

.eslintrc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
// I want to use babel-eslint for parsing!
3+
"parser": "babel-eslint",
4+
5+
"env": {
6+
"browser": true,
7+
"node": true,
8+
"jasmine": true
9+
},
10+
11+
// To give you an idea how to override rule options:
12+
"rules": {
13+
"quotes": [2, "single"],
14+
"strict": [2, "never"],
15+
"eol-last": [0],
16+
"no-mixed-requires": [0],
17+
"no-underscore-dangle": [0],
18+
"no-use-before-define": [2, "nofunc"],
19+
20+
"no-alert": 0,
21+
22+
// react
23+
"react/display-name": 0,
24+
"react/jsx-boolean-value": 1,
25+
"react/jsx-quotes": 1,
26+
"react/jsx-no-undef": 1,
27+
"react/jsx-sort-props": 0,
28+
"react/jsx-sort-prop-types": 1,
29+
"react/jsx-uses-react": 1,
30+
"react/jsx-uses-vars": 1,
31+
"react/no-did-mount-set-state": 1,
32+
"react/no-did-update-set-state": 1,
33+
"react/no-multi-comp": 0,
34+
"react/no-unknown-property": 1,
35+
"react/prop-types": 0,
36+
"react/react-in-jsx-scope": 1,
37+
"react/self-closing-comp": 1,
38+
"react/wrap-multilines": 1
39+
},
40+
41+
"ecmaFeatures": {
42+
"jsx": true
43+
},
44+
45+
"plugins": [
46+
"react"
47+
]
48+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
bower_components
3+
.DS_Store
4+
*.log

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# react web terminal
2+
3+
Get the AMD module located at `react-web-terminal.js` and include it in your project.
4+
5+
index.html contains an example of usage. Note the commandHandler function is passed as a react property:
6+
7+
```js
8+
function commandHandler(component) {
9+
component.output('Output: ' + component.input());
10+
}
11+
12+
var webTerminalComp = ReactDOM.render(
13+
React.createElement(WebTerminal, {commandHandler: commandHandler, prompt: '~> '}),
14+
document.getElementById('main')
15+
);
16+
```
17+
18+
The handler is run when enter is pressed inside the component.
19+
The WebTerminal component is passed as a parameter to the handler. This example simply outputs the input with "Output: " prepended to it.
20+
21+
Also note that the component can be stored in a variable so the same functions can be used outside the component like in the example:
22+
23+
```js
24+
webTerminalComp.output('Welcome!');
25+
```
26+
27+
Also *also* note the styles can be overridden by prepending a selector for the component container like in the example:
28+
29+
```css
30+
#main .react-web-terminal {
31+
background-color: #004;
32+
}
33+
```
34+
35+
## Development
36+
37+
* Development server `npm start`.
38+
* Continuously run tests on file changes `npm run watch-test`;
39+
* Run tests: `npm test`;
40+
* Build `npm run build`;

bower.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "react-web-terminal",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"author": "jyann",
6+
"private": true,
7+
"ignore": [
8+
"**/.*",
9+
"node_modules",
10+
"bower_components",
11+
"spec",
12+
"test",
13+
"tests"
14+
],
15+
"moduleType": [
16+
"amd",
17+
"globals"
18+
]
19+
}

dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<html>
2+
<head>
3+
<title>React Web Terminal Demo</title>
4+
<style>
5+
html, body {
6+
height: 100%;
7+
width: 100%;
8+
margin: 0;
9+
}
10+
#main {
11+
height: 100%;
12+
width: 100%;
13+
}
14+
#main .react-web-terminal {
15+
background-color: #004;
16+
}
17+
</style>
18+
</head>
19+
<body>
20+
<div id="main"></div>
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js"></script>
22+
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js"></script>
23+
<script src="dist/index.js"></script>
24+
<script>
25+
function commandHandler(component) {
26+
component.output('Output: ' + component.input());
27+
}
28+
29+
var webTerminalComp = ReactDOM.render(
30+
React.createElement(WebTerminal, {commandHandler: commandHandler, prompt: '~> '}),
31+
document.getElementById('main')
32+
);
33+
34+
webTerminalComp.output('Welcome!');
35+
</script>
36+
</body>
37+
</html>

karma.conf.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = function(config) {
2+
config.set({
3+
basePath: '.',
4+
5+
frameworks: ['jasmine'],
6+
browsers: ['PhantomJS'],
7+
8+
files: [
9+
// shim to workaroud PhantomJS 1.x lack of `bind` support
10+
// see: https://github.com/ariya/phantomjs/issues/10522
11+
'node_modules/es5-shim/es5-shim.js',
12+
13+
// React is an external dependency of the component
14+
'node_modules/react/dist/react-with-addons.js',
15+
16+
'spec/spec-helper.js',
17+
'spec/**/*.spec.*',
18+
{ pattern: 'lib/**/*', watched: true, included: false }
19+
],
20+
21+
preprocessors: {
22+
// add webpack as preprocessor
23+
'spec/**/*.spec.*': ['webpack', 'sourcemap']
24+
},
25+
26+
webpack: loadWebpackConfig(),
27+
28+
webpackServer: {
29+
noInfo: true
30+
},
31+
32+
singleRun: true
33+
});
34+
};
35+
36+
37+
/**
38+
Loads configuration while ensuring sounce-map is enabled
39+
*/
40+
function loadWebpackConfig () {
41+
var webpackConfig = require('./webpack.config.js');
42+
webpackConfig.devtool = 'inline-source-map';
43+
return webpackConfig;
44+
}

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./react-web-terminal.jsx');

0 commit comments

Comments
 (0)