Skip to content

Commit 716c199

Browse files
committed
[add] Active prop, new build config
1 parent d2f3e19 commit 716c199

File tree

7 files changed

+120
-29
lines changed

7 files changed

+120
-29
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# CHANGELOG
2+
3+
## 0.1.0
4+
5+
- Added an `active` property. This is true by default, however allows
6+
the FocusTrap to be eliminated if not active

CONTRIBUTING.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Contribution Guidelines
2+
3+
Thanks you for considering a contribution to FocusTrap!
4+
5+
FocusTrap is built using tools written for
6+
[nodejs](http://nodejs.org). We recommend installing Node with
7+
[nvm](https://github.com/creationix/nvm). this also means that
8+
dependencies are managed with an [`npm`](https://npmjs.org) `package.json`
9+
file.
10+
11+
You can install dependencies with:
12+
13+
```bash
14+
npm install
15+
```
16+
17+
## Running
18+
19+
A production build can be built by running:
20+
21+
```bash
22+
npm run prepublish
23+
```
24+
25+
However most of the time developing with FocusTrap, you will want
26+
to reference the example app:
27+
28+
```bash
29+
npm start
30+
```
31+
32+
This will host the demo at `http://localhost:8080`.
33+
34+
## Testing
35+
36+
FocusTrap uses [Karma](https://karma-runner.github.io). You can run tests
37+
with:
38+
39+
```bash
40+
npm test
41+
```
42+
43+
Be sure to check the `./coverage` folder to verify all code paths are
44+
touched.
45+
46+
## Conventions
47+
48+
**Consider master unsafe**, use [`npm`](https://www.npmjs.com/package/microcosm) for the latest stable version.
49+
50+
### Javascript
51+
52+
FocusTrap uses ES6 Javascript (compiled using [Babel](babeljs.io)). As
53+
for style, shoot for:
54+
55+
- No semicolons
56+
- Commas last,
57+
- 2 spaces for indentation (no tabs)
58+
- Prefer ' over ", use string interpolation
59+
- 80 character line length
60+
61+
### Testing
62+
63+
Additionally, we aspire for 100% code coverage. However 100% code
64+
coverage is not a foolproof indicator of good testing. Tests that
65+
cover as much surface area as possible (for the sake of coverage)
66+
should be avoided. This is a much softer measure than a style guide,
67+
and will fall to code review for enforcement.
68+
69+
### Reviews
70+
71+
All changes should be submitted through pull request. Ideally, at
72+
least two :+1:s should be given before a pull request is merge.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Viget Labs
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

dist/focus-trap.js

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

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
{
22
"name": "react-focus-trap",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "",
55
"main": "dist/focus-trap.js",
66
"scripts": {
7-
"start": "webpack -wd",
8-
"example": "webpack -wd --config webpack.example.config.js",
7+
"start": "webpack -wd --config webpack.example.config.js",
98
"prepublish": "./scripts/production"
109
},
1110
"repository": {
1211
"type": "git",
13-
"url": "git@github.com:vigetlabs/react-modal.git"
12+
"url": "git@github.com:vigetlabs/react-focus-trap.git"
1413
},
1514
"keywords": [
1615
"react"
1716
],
1817
"author": "Nate Hunzaker",
1918
"license": "MIT",
2019
"devDependencies": {
21-
"6to5": "^2.9.4",
22-
"6to5-loader": "^2.0.0",
23-
"exports-loader": "^0.6.2",
24-
"imports-loader": "^0.6.3",
25-
"webpack": "^1.4.15",
26-
"webpack-dev-server": "^1.6.6"
20+
"babel-loader": "^5.x.x",
21+
"webpack": "^1.x.x",
22+
"webpack-dev-server": "^1.x.x"
2723
},
2824
"peerDependencies": {
2925
"react": ">= 0.11.x"

src/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import Focus from './mixins/focus'
22
import React from 'react'
33

4-
let Types = React.PropTypes
5-
6-
let FocusTrap = React.createClass({
4+
export default React.createClass({
75

86
mixins: [ Focus ],
97

108
propTypes: {
11-
onExit : Types.func.isRequired,
12-
role : Types.string.isRequired
9+
active : React.PropTypes.boolean,
10+
onExit : React.PropTypes.func.isRequired,
11+
role : React.PropTypes.string.isRequired
1312
},
1413

1514
getDefaultProps() {
1615
return {
17-
role: "dialog"
16+
active : true,
17+
role : "dialog"
1818
}
1919
},
2020

2121
render() {
22-
let { role } = this.props
22+
let { active, role } = this.props
2323

24-
return (
24+
return active ? (
2525
<div className="focus-trap" tabIndex="0" role={ role } onKeyUp={ this._onKeyUp }>
2626

2727
<div className="focus-trap-backdrop" aria-hidden={ true } onClick={ this.props.onExit }></div>
@@ -31,7 +31,7 @@ let FocusTrap = React.createClass({
3131
</section>
3232

3333
</div>
34-
)
34+
) : null
3535
},
3636

3737
_onKeyUp(e) {
@@ -41,5 +41,3 @@ let FocusTrap = React.createClass({
4141
}
4242

4343
})
44-
45-
export default FocusTrap

webpack.config.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@ module.exports = {
2020
modulesDirectories: [ 'web_modules', 'node_modules' ]
2121
},
2222

23-
plugins: [
24-
new Webpack.ProvidePlugin({
25-
to5Runtime: "imports?global=>{}!exports-loader?global.to5Runtime!6to5/runtime"
26-
})
27-
],
28-
2923
module: {
3024
loaders: [
3125
{
3226
test : /\.jsx*$/,
3327
exclude : /node_modules/,
34-
loader : '6to5-loader?experimental&runtime&modules=common',
28+
loader : 'babel-loader',
29+
query : {
30+
stage : 1,
31+
loose : true
32+
}
3533
},
3634
{
3735
test : /\.json$/,

0 commit comments

Comments
 (0)