-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #3
- Loading branch information
David Clark
committed
Jan 10, 2017
1 parent
43d6040
commit 71b174a
Showing
6 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
var FocusTrap = require('../../'); | ||
|
||
var container = document.getElementById('demo-five'); | ||
|
||
var DemoFive = React.createClass({ | ||
getInitialState: function() { | ||
return { | ||
activeTrap: false, | ||
}; | ||
}, | ||
|
||
mountTrap: function() { | ||
this.setState({ activeTrap: true }); | ||
}, | ||
|
||
unmountTrap: function() { | ||
this.setState({ activeTrap: false }); | ||
}, | ||
|
||
render: function() { | ||
var trap = (this.state.activeTrap) ? ( | ||
<FocusTrap | ||
focusTrapOptions={{ | ||
onDeactivate: this.unmountTrap, | ||
}} | ||
> | ||
<div className='trap'> | ||
<button onClick={this.unmountTrap}> | ||
deactivate trap | ||
</button> | ||
<div> | ||
<a href='#'>Another focusable thing</a> | ||
</div> | ||
<div> | ||
Autofocused input: <input autoFocus={true} /> | ||
</div> | ||
</div> | ||
</FocusTrap> | ||
) : false; | ||
|
||
return ( | ||
<div> | ||
<p> | ||
<button key='button' onClick={this.mountTrap}> | ||
activate trap | ||
</button> | ||
</p> | ||
{trap} | ||
</div> | ||
); | ||
}, | ||
}); | ||
|
||
ReactDOM.render(<DemoFive />, container); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters