forked from reactjs/react-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10fe405
commit 58c26ae
Showing
11 changed files
with
264 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,90 @@ | ||
React Modal | ||
=========== | ||
|
||
WIP | ||
Accessible React Modal Dialog Component | ||
|
||
Usage | ||
----- | ||
|
||
```xml | ||
<Modal | ||
isOpen={this.state.modalIsOpen} | ||
onRequestClose={this.handleModalCloseRequest} | ||
closeTimeoutMS={150} | ||
> | ||
<h1>Modal Content</h1> | ||
<p>Etc.</p> | ||
</Modal> | ||
``` | ||
|
||
Accessibility Notes | ||
------------------- | ||
|
||
|
||
|
||
Inside the app: | ||
|
||
```js | ||
/** @jsx React.DOM */ | ||
|
||
var React = require('react'); | ||
var Modal = require('react-modal'); | ||
|
||
var appElement = document.getElementById('your-app-element'); | ||
|
||
Modal.setAppElement(appElement); | ||
Modal.injectCSS(); | ||
|
||
var App = React.createClass({ | ||
|
||
getInitialState: function() { | ||
return { modalIsOpen: false }; | ||
}, | ||
|
||
openModal: function() { | ||
this.setState({modalIsOpen: true}); | ||
}, | ||
|
||
closeModal: function() { | ||
this.setState({modalIsOpen: false}); | ||
}, | ||
|
||
handleModalCloseRequest: function() { | ||
// opportunity to validate something and keep the modal open even if it | ||
// requested to be closed | ||
this.setState({modalIsOpen: false}); | ||
}, | ||
|
||
render: function() { | ||
return ( | ||
<div> | ||
<button onClick={this.openModal}>Open Modal</button> | ||
<Modal | ||
closeTimeoutMS={150} | ||
isOpen={this.state.modalIsOpen} | ||
onRequestClose={this.handleModalCloseRequest} | ||
> | ||
<h1>Hello</h1> | ||
<button onClick={this.closeModal}>close</button> | ||
<div>I am a modal</div> | ||
<form> | ||
<input /> | ||
<input /> | ||
<input /> | ||
<input /> | ||
<input /> | ||
<br/> | ||
<button>hi</button> | ||
<button>hi</button> | ||
<button>hi</button> | ||
<button>hi</button> | ||
</form> | ||
</Modal> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
React.renderComponent(<App/>, appElement); | ||
``` | ||
|
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.