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.
Merge pull request reactjs#12 from cavneb/example-bootstrap
Bootstrap-style modal example
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
body { | ||
font-family: "Helvetica Neue", Arial; | ||
font-weight: 200; | ||
background: #ccc; | ||
} | ||
|
||
.ReactModal__Overlay { | ||
-webkit-perspective: 600; | ||
perspective: 600; | ||
opacity: 0; | ||
overflow-x: hidden; | ||
overflow-y: auto; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
} | ||
|
||
.ReactModal__Overlay--after-open { | ||
opacity: 1; | ||
transition: opacity 150ms ease-out; | ||
} | ||
|
||
.ReactModal__Content { | ||
-webkit-transform: scale(0.5) rotateX(-30deg); | ||
} | ||
|
||
.ReactModal__Content--after-open { | ||
-webkit-transform: scale(1) rotateX(0deg); | ||
transition: all 150ms ease-in; | ||
} | ||
|
||
.ReactModal__Overlay--before-close { | ||
opacity: 0; | ||
} | ||
|
||
.ReactModal__Content--before-close { | ||
-webkit-transform: scale(0.5) rotateX(30deg); | ||
transition: all 150ms ease-in; | ||
} | ||
|
||
.ReactModal__Content.modal-dialog { | ||
border: none; | ||
background-color: transparent; | ||
} |
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,69 @@ | ||
/** @jsx React.DOM */ | ||
var React = require('react'); | ||
var Modal = require('../../lib/index'); | ||
|
||
var appElement = document.getElementById('example'); | ||
|
||
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}); | ||
}, | ||
|
||
handleSaveClicked: function(e) { | ||
alert('Save button was clicked'); | ||
}, | ||
|
||
render: function() { | ||
return ( | ||
<div> | ||
<button onClick={this.openModal}>Open Modal</button> | ||
<Modal | ||
className="Modal__Bootstrap modal-dialog" | ||
closeTimeoutMS={150} | ||
isOpen={this.state.modalIsOpen} | ||
onRequestClose={this.handleModalCloseRequest} | ||
> | ||
<div className="modal-content"> | ||
<div className="modal-header"> | ||
<button type="button" className="close" onClick={this.handleModalCloseRequest}> | ||
<span aria-hidden="true">×</span> | ||
<span className="sr-only">Close</span> | ||
</button> | ||
<h4 className="modal-title">Modal title</h4> | ||
</div> | ||
<div className="modal-body"> | ||
<h4>Really long content...</h4> | ||
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p> | ||
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p> | ||
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p> | ||
</div> | ||
<div className="modal-footer"> | ||
<button type="button" className="btn btn-default" onClick={this.handleModalCloseRequest}>Close</button> | ||
<button type="button" className="btn btn-primary" onClick={this.handleSaveClicked}>Save changes</button> | ||
</div> | ||
</div> | ||
</Modal> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
React.renderComponent(<App/>, appElement); |
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,10 @@ | ||
<!doctype html public "embarassment"> | ||
<title>Bootstrap-Style Example</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> | ||
<link href="app.css" rel="stylesheet"/> | ||
<body> | ||
<div id="example"></div> | ||
<script src="/__build__/shared.js"></script> | ||
<script src="/__build__/bootstrap.js"></script> | ||
|