embed an appetize.io simulator for AlertIOS documentation

This commit is contained in:
Joshua Sierles 2015-10-14 19:57:17 +02:00
parent 529687f923
commit d9ee81c127
6 changed files with 175 additions and 11 deletions

View File

@ -51,7 +51,7 @@ var Site = React.createClass({
{this.props.children} {this.props.children}
<footer className="wrap"> <footer className="wrap">
<div className="right">© 2015 Facebook Inc.</div> <div className="center">© 2015 Facebook Inc.</div>
</footer> </footer>
</div> </div>
@ -68,6 +68,7 @@ var Site = React.createClass({
){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js"; ){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
`}} /> `}} />
<script src="/react-native/js/scripts.js" />
</body> </body>
</html> </html>
); );

View File

@ -451,10 +451,55 @@ var Autodocs = React.createClass({
{metadata.next && <a className="docs-next" href={metadata.next + '.html#content'}>Next &rarr;</a>} {metadata.next && <a className="docs-next" href={metadata.next + '.html#content'}>Next &rarr;</a>}
</div> </div>
</div> </div>
<EmbeddedSimulator shouldRender={metadata.runnable} metadata={metadata} />
</section> </section>
</Site> </Site>
); );
} }
}); });
var EmbeddedSimulator = React.createClass({
render: function() {
if (!this.props.shouldRender) {
return null;
}
var metadata = this.props.metadata;
return (
<div className="column-left">
<p><strong>Run this example</strong></p>
<div className="modal-button-open">
<img src="/react-native/img/alertIOS.png" />
</div>
<Modal />
</div>
);
}
});
var Modal = React.createClass({
render: function() {
var appParams = {route: 'AlertIOS'};
var encodedParams = encodeURIComponent(JSON.stringify(appParams));
var url = `https://appetize.io/embed/bypdk4jnjra5uwyj2kzd2aenv4?device=iphone5s&scale=70&autoplay=false&orientation=portrait&deviceColor=white&params=${encodedParams}`;
return (
<div>
<div className="modal">
<div className="modal-content">
<button className="modal-button-close">&times;</button>
<div className="center">
<iframe className="simulator" src={url} width="274" height="550" frameborder="0" scrolling="no"></iframe>
</div>
</div>
</div>
<div className="modal-backdrop" />
</div>
);
}
});
module.exports = Autodocs; module.exports = Autodocs;

View File

@ -22,7 +22,7 @@ server.noconvert = true;
// requests. // requests.
var queue = Promise.resolve(); var queue = Promise.resolve();
glob('src/**/*.*', function(er, files) { glob('src/**/*.*', { ignore: 'src/react-native/js/**/*' }, function(er, files) {
files.forEach(function(file) { files.forEach(function(file) {
var targetFile = file.replace(/^src/, 'build'); var targetFile = file.replace(/^src/, 'build');

View File

@ -185,15 +185,13 @@ html * {
.container { .container {
padding-top: 50px; padding-top: 50px;
min-width: 960px; min-width: 1160px;
} }
.wrap { .wrap {
width: 960px; max-width: 1260px;
margin-left: auto; margin: 0 auto;
margin-right: auto; padding: 0 20px;
padding-left: 20px;
padding-right: 20px;
} }
.skinnyWrap { .skinnyWrap {
@ -363,7 +361,7 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li
font-size: 14px; font-size: 14px;
float: left; float: left;
width: 210px; width: 210px;
margin-top: 5px; margin: 5px 48px 0 0;
} }
.nav-docs ul { .nav-docs ul {
@ -550,7 +548,7 @@ h1:hover .hash-link, h2:hover .hash-link, h3:hover .hash-link, h4:hover .hash-li
float: right; float: right;
} }
footer { footer.wrap {
font-size: 13px; font-size: 13px;
font-weight: 600; font-weight: 600;
padding-top: 36px; padding-top: 36px;
@ -699,7 +697,7 @@ figure {
} }
.inner-content { .inner-content {
float: right; float: left;
width: 650px; width: 650px;
} }
@ -845,6 +843,91 @@ small code, li code, p code {
text-decoration: none !important; text-decoration: none !important;
} }
.column-left, .column-left * {
box-sizing: border-box;
}
.column-left p {
text-align: center;
color: #999;
}
.column-left {
float: left;
padding: 20px;
width: 210px;
}
/* Modal */
.modal-backdrop {
background: rgba(0,0,0,.4);
display: none;
height: 100%;
left: 0;
overflow: auto;
position: fixed;
top: 0;
width: 100%;
z-index: 9900;
}
.modal {
background: #F6F6F6;
bottom: 0;
box-shadow: 2px 2px 4px 0 rgba(0,0,0,.11);
display: none;
border-radius: 10px;
height: 95%;
left: 0;
margin: auto;
max-height: 620px;
max-width: 460px;
overflow: auto;
position: fixed;
right: 0;
top: 0;
width: 80%;
z-index: 9999;
}
.modal-open {
display: block;
}
.modal-content {
padding: 40px 24px 24px 24px;
position: relative;
}
.modal-content iframe {
margin: 0 auto;
}
.modal-button-open {
text-align: center;
}
.modal-button-close {
background: transparent;
border-radius: 0 0 0 4px;
border: 0;
color: #555;
font-size: 1.2em;
font-weight: bolder;
line-height: 32px;
margin: 0;
padding: 0 12px;
position: absolute;
right: 0;
top: 0;
}
.modal-button-close:active,
.modal-button-close:focus,
.modal-button-close:hover {
background: #EAF8FD;
outline: none;
}
@media screen and (max-width: 960px) { @media screen and (max-width: 960px) {
.nav-main { .nav-main {
position: static; position: static;

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

35
website/src/react-native/js/scripts.js vendored Normal file
View File

@ -0,0 +1,35 @@
(function(){
// Not on browser
if (typeof document === 'undefined') {
return;
}
document.addEventListener('DOMContentLoaded', init);
function init() {
var backdrop = document.querySelector('.modal-backdrop');
var modalButtonOpen = document.querySelector('.modal-button-open');
var modalButtonClose = document.querySelector('.modal-button-close');
backdrop.addEventListener('click', hideModal);
modalButtonOpen.addEventListener('click', showModal);
modalButtonClose.addEventListener('click', hideModal);
}
function showModal(e) {
var backdrop = document.querySelector('.modal-backdrop');
var modal = document.querySelector('.modal');
backdrop.classList.add('modal-open');
modal.classList.add('modal-open');
}
function hideModal(e) {
var backdrop = document.querySelector('.modal-backdrop');
var modal = document.querySelector('.modal');
backdrop.classList.remove('modal-open');
modal.classList.remove('modal-open');
}
}());