Commit 737a5329 authored by Ray Schamp's avatar Ray Schamp

Merge pull request #93 from rschamp/bugfix/fix-joining

Fix registration, fix upgraded react-modal
parents 23558f58 cad69eb3
@mixin modal-iframe($iframe-width, $iframe-height, $padding: 0) {
&.ReactModal__Content {
top: 50%;
right: auto;
bottom: auto;
left: 50%;
margin-top: -($iframe-height + $padding * 2)/2;
margin-left: -($iframe-width + $padding * 2)/2;
padding: $padding;
width: $iframe-width;
height: $iframe-height;
iframe {
border: 0;
width: $iframe-width;
height: $iframe-height;
}
}
}
var omit = require('lodash.omit');
var React = require('react');
var ReactIntl = require('react-intl');
var FormattedMessage = ReactIntl.FormattedMessage;
......@@ -30,6 +31,11 @@ var Intro = React.createClass({
this.setState({videoOpen: false});
},
render: function () {
var frameSettings = {
width: 570,
height: 357,
padding: 15
};
return (
<div className="intro">
<div className="content">
......@@ -114,10 +120,13 @@ var Intro = React.createClass({
<img src="//cdn.scratch.mit.edu/scratchr2/static/images/hp-video-screenshot.png" />
</div>
<Modal
className="video-modal"
isOpen={this.state.videoOpen}
onRequestClose={this.closeVideo}>
<iframe src="//player.vimeo.com/video/65583694?title=0&amp;byline=0&amp;portrait=0" />
className="video-modal"
isOpen={this.state.videoOpen}
onRequestClose={this.closeVideo}
frameSettings={frameSettings}>
<iframe
src="//player.vimeo.com/video/65583694?title=0&amp;byline=0&amp;portrait=0"
{...omit(frameSettings, 'padding')} />
</Modal>
</div>
);
......
@import "../../colors";
@import "../../mixins";
.intro {
display: flex;
......@@ -223,7 +222,3 @@
}
}
}
.video-modal {
@include modal-iframe(570px, 357px, 15px);
}
var defaults = require('lodash.defaults');
var omit = require('lodash.omit');
var React = require('react');
var ReactModal = require('react-modal');
require('./modal.scss');
var Modal = React.createClass({
type: 'Modal',
statics: {
setAppElement: ReactModal.setAppElement
},
getDefaultProps: function () {
return {
frameSettings: null,
style: {
overlay: {
zIndex: 100,
backgroundColor: 'rgba(0, 0, 0, .75)'
},
content: {
overflow: 'visible',
borderRadius: '6px'
}
}
};
},
requestClose: function () {
return this.refs.modal.portal.requestClose();
},
render: function () {
var frameSettings = this.props.frameSettings;
var style = this.props.style;
var modalProps = omit(this.props, ['frameSettings', 'style']);
if (frameSettings) {
defaults(frameSettings, {
width: 500,
height: 250,
padding: 0
});
defaults(style.content, {
top: '50%',
right: 'auto',
bottom: 'auto',
left: '50%',
marginTop: (frameSettings.height + 2*frameSettings.padding) / -2,
marginLeft: (frameSettings.width + 2*frameSettings.padding) / -2,
height: frameSettings.height,
width: frameSettings.width,
padding: frameSettings.padding
});
}
return (
<ReactModal ref="modal" {... this.props}>
<ReactModal ref="modal" style={style} {...modalProps}>
<div className="modal-close" onClick={this.requestClose}></div>
{this.props.children}
</ReactModal>
......
@import "../../colors";
$base-bg: $ui-white;
/* Copied from the un-styleable react-modal */
.ReactModal__Overlay {
z-index: 100;
background-color: $overlay-gray;
}
.ReactModal__Content {
position: absolute;
top: 40px;
right: 40px;
bottom: 40px;
left: 40px;
outline: none;
border-radius: 6px;
background: $base-bg;
padding: 20px;
overflow: visible;
-webkit-overflow-scrolling: touch;
&.ReactModal__Content {
iframe {
border: 0;
}
}
.modal-close {
......
......@@ -268,11 +268,13 @@ var Navigation = React.createClass({
</Dropdown>
</li>
] : [
<li className="link right join" key="join"><a href="/join">
<FormattedMessage
id='general.joinScratch'
defaultMessage={'Join Scratch'} />
</a></li>,
<li className="link right join" key="join">
<a href="#" onClick={this.handleJoinClick}>
<FormattedMessage
id='general.joinScratch'
defaultMessage={'Join Scratch'} />
</a>
</li>,
<Registration
key="registration"
isOpen={this.state.registrationOpen}
......
......@@ -22,12 +22,17 @@ var Registration = React.createClass({
window.removeEventListener('message', this.onMessage);
},
render: function () {
var frameSettings = {
width: 610,
height: 438
};
return (
<Modal
isOpen={this.props.isOpen}
onRequestClose={this.props.onRequestClose}
className="registration">
<iframe src="/accounts/standalone-registration/" />
className="registration"
frameSettings={frameSettings}>
<iframe src="/accounts/standalone-registration/" {...frameSettings} />
</Modal>
);
}
......
@import "../../mixins";
.registration {
@include modal-iframe(610px, 438px);
overflow: hidden;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment