Skip to content

Commit 278cfbc

Browse files
committed
Merge pull request #10 from rackt/bug-9
Closes #9
2 parents 5497538 + 9616a8c commit 278cfbc

File tree

9 files changed

+81
-22
lines changed

9 files changed

+81
-22
lines changed

Diff for: CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ always be in sync.
2828

2929
### Development
3030

31-
- `script/test` will fire up a karma runner and watch for changes in the
32-
specs directory.
33-
- `npm test` will do the same but doesn't watch, just runs the tests.
34-
- `script/build-examples` does exactly that.
31+
- `npm start` runs the dev server to run/develop examples
32+
- `npm test` will run the test.
33+
- `script/test` same as `npm test` but keeps karma running and watches
34+
for changes
3535

3636
### Build
3737

Diff for: examples/basic/app.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ var App = React.createClass({
2727
this.setState({modalIsOpen: false});
2828
},
2929

30+
handleInputChange: function() {
31+
this.setState({foo: 'bar'});
32+
},
33+
3034
render: function() {
3135
return (
3236
<div>
@@ -40,7 +44,7 @@ var App = React.createClass({
4044
<button onClick={this.closeModal}>close</button>
4145
<div>I am a modal</div>
4246
<form>
43-
<input />
47+
<input onChange={this.handleInputChange} />
4448
<input />
4549
<input />
4650
<input />

Diff for: examples/basic/index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<link href="app.css" rel="stylesheet"/>
55
<body>
66
<div id="example"></div>
7-
<script src="../global-bundle.js"></script>
8-
<script src="app-bundle.js"></script>
7+
<script src="/__build__/shared.js"></script>
8+
<script src="/__build__/basic.js"></script>
9+

Diff for: lib/components/Modal.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ var Modal = module.exports = React.createClass({
5050
ariaAppHider.toggle(props.isOpen, props.appElement);
5151
}
5252
sanitizeProps(props);
53-
this.portal = React.renderComponent(ModalPortal(props), this.node);
53+
if (this.portal)
54+
this.portal.setProps(props);
55+
else
56+
this.portal = React.renderComponent(ModalPortal(props), this.node);
5457
},
5558

5659
render: function () {
@@ -61,4 +64,3 @@ var Modal = module.exports = React.createClass({
6164
function sanitizeProps(props) {
6265
delete props.ref;
6366
}
64-

Diff for: lib/components/ModalPortal.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ var ModalPortal = module.exports = React.createClass({
7070
},
7171

7272
maybeFocus: function() {
73-
if (this.props.isOpen)
73+
if (this.props.isOpen &&
74+
!this.refs.content.getDOMNode().contains(document.activeElement)) {
7475
this.focusContent();
76+
}
7577
},
7678

7779
focusContent: function() {
@@ -109,7 +111,7 @@ var ModalPortal = module.exports = React.createClass({
109111
},
110112

111113
requestClose: function() {
112-
if (this.ownerHandlesClose)
114+
if (this.ownerHandlesClose())
113115
this.props.onRequestClose();
114116
},
115117

@@ -152,4 +154,3 @@ var ModalPortal = module.exports = React.createClass({
152154
);
153155
}
154156
});
155-

Diff for: package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"example": "examples"
1414
},
1515
"scripts": {
16-
"test": "script/test --browsers Firefox --single-run"
16+
"test": "script/test --browsers Firefox --single-run",
17+
"start": "script/dev-examples"
1718
},
1819
"authors": [
1920
"Ryan Florence"
@@ -24,6 +25,7 @@
2425
"browserify-shim": "3.6.0",
2526
"envify": "1.2.0",
2627
"expect": "0.1.1",
28+
"jsx-loader": "0.11.2",
2729
"karma": "0.12.16",
2830
"karma-browserify": "^0.2.1",
2931
"karma-chrome-launcher": "0.1.4",
@@ -32,10 +34,10 @@
3234
"karma-mocha": "0.1.3",
3335
"mocha": "1.20.1",
3436
"react": ">=0.11.0",
35-
"react-tap-event-plugin": "git://github.com/appsforartists/react-tap-event-plugin",
3637
"reactify": "^0.14.0",
3738
"rf-release": "0.3.1",
38-
"uglify-js": "2.4.15"
39+
"uglify-js": "2.4.15",
40+
"webpack-dev-server": "1.6.5"
3941
},
4042
"peerDependencies": {
4143
"react": ">=0.11.0"
@@ -55,4 +57,4 @@
5557
"browserify-shim": {
5658
"react": "global:React"
5759
}
58-
}
60+
}

Diff for: script/build-examples

-6
This file was deleted.

Diff for: script/dev-examples

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
node_modules/.bin/webpack-dev-server --inline --content-base examples/
3+

Diff for: webpack.config.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var webpack = require('webpack');
4+
5+
var EXAMPLES_DIR = path.resolve(__dirname, 'examples');
6+
7+
function isDirectory(dir) {
8+
return fs.lstatSync(dir).isDirectory();
9+
}
10+
11+
function buildEntries() {
12+
return fs.readdirSync(EXAMPLES_DIR).reduce(function (entries, dir) {
13+
if (dir === 'build')
14+
return entries;
15+
16+
var isDraft = dir.charAt(0) === '_';
17+
18+
if (!isDraft && isDirectory(path.join(EXAMPLES_DIR, dir)))
19+
entries[dir] = path.join(EXAMPLES_DIR, dir, 'app.js');
20+
21+
return entries;
22+
}, {});
23+
}
24+
25+
module.exports = {
26+
27+
entry: buildEntries(),
28+
29+
output: {
30+
filename: '[name].js',
31+
chunkFilename: '[id].chunk.js',
32+
path: 'examples/__build__',
33+
publicPath: '/__build__/'
34+
},
35+
36+
module: {
37+
loaders: [
38+
{ test: /\.js$/, loader: 'jsx-loader?harmony' }
39+
]
40+
},
41+
42+
resolve: {
43+
alias: {
44+
'react-router': '../../modules/index'
45+
}
46+
},
47+
48+
plugins: [
49+
new webpack.optimize.CommonsChunkPlugin('shared.js')
50+
]
51+
52+
};

0 commit comments

Comments
 (0)