Make Login & Sign Up as modal layovers (#122)

* make Login & Sign Up as modal layovers

* delete extra signupForm.js in original path

* deleted extra comments
This commit is contained in:
Yining Shi 2016-10-08 18:03:39 -04:00 committed by Cassie Tarakajian
parent 64be537db7
commit 96321ca767
8 changed files with 58 additions and 26 deletions

View file

@ -1,22 +1,28 @@
import React from 'react'; import React from 'react';
import { reduxForm } from 'redux-form'; import { reduxForm } from 'redux-form';
import { validateAndLoginUser } from '../actions'; import { validateAndLoginUser } from '../../User/actions';
import LoginForm from '../components/LoginForm'; import LoginForm from '../components/LoginForm';
// import GithubButton from '../components/GithubButton'; // import GithubButton from '../components/GithubButton';
import { Link } from 'react-router'; import { Link } from 'react-router';
function LoginView(props) { class LoginView extends React.Component {
componentDidMount() {
this.refs.login.focus();
}
render() {
return ( return (
<div className="login"> <div className="login" ref="login" tabIndex="0">
<h1>Login</h1> <h1>Login</h1>
<LoginForm {...props} /> <LoginForm {...this.props} />
{/* <h2 className="login__divider">Or</h2> {/* <h2 className="login__divider">Or</h2>
<GithubButton buttonText="Login with Github" /> */} <GithubButton buttonText="Login with Github" /> */}
<Link className="form__cancel-button" to="/">Cancel</Link> <Link className="form__cancel-button" to="/">Cancel</Link>
</div> </div>
); );
} }
}
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {

View file

@ -1,20 +1,26 @@
import React from 'react'; import React from 'react';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import * as UserActions from '../actions'; import * as UserActions from '../../User/actions';
import { reduxForm } from 'redux-form'; import { reduxForm } from 'redux-form';
import SignupForm from '../components/SignupForm'; import SignupForm from '../components/SignupForm';
import axios from 'axios'; import axios from 'axios';
import { Link } from 'react-router'; import { Link } from 'react-router';
function SignupView(props) { class SignupView extends React.Component {
componentDidMount() {
this.refs.signup.focus();
}
render() {
return ( return (
<div className="signup"> <div className="signup" ref="signup" tabIndex="0">
<h1>Sign Up</h1> <h1>Sign Up</h1>
<SignupForm {...props} /> <SignupForm {...this.props} />
<Link to="/">Cancel</Link> <Link className="form__cancel-button" to="/">Cancel</Link>
</div> </div>
); );
} }
}
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {

View file

@ -27,6 +27,8 @@ import SplitPane from 'react-split-pane';
import Overlay from '../../App/components/Overlay'; import Overlay from '../../App/components/Overlay';
import SketchList from '../components/SketchList'; import SketchList from '../components/SketchList';
import About from '../components/About'; import About from '../components/About';
import LoginView from '../components/LoginView';
import SignupView from '../components/SignupView';
class IDEView extends React.Component { class IDEView extends React.Component {
constructor(props) { constructor(props) {
@ -391,6 +393,24 @@ class IDEView extends React.Component {
); );
} }
})()} })()}
{(() => { // eslint-disable-line
if (this.props.location.pathname === '/login') {
return (
<Overlay>
<LoginView />
</Overlay>
);
}
})()}
{(() => { // eslint-disable-line
if (this.props.location.pathname === '/signup') {
return (
<Overlay>
<SignupView />
</Overlay>
);
}
})()}
</div> </div>
); );

View file

@ -3,8 +3,6 @@ import React from 'react';
import App from './modules/App/App'; import App from './modules/App/App';
import IDEView from './modules/IDE/pages/IDEView'; import IDEView from './modules/IDE/pages/IDEView';
import FullView from './modules/IDE/pages/FullView'; import FullView from './modules/IDE/pages/FullView';
import LoginView from './modules/User/pages/LoginView';
import SignupView from './modules/User/pages/SignupView';
// import SketchListView from './modules/Sketch/pages/SketchListView'; // import SketchListView from './modules/Sketch/pages/SketchListView';
import { getUser } from './modules/User/actions'; import { getUser } from './modules/User/actions';
@ -16,8 +14,8 @@ const routes = (store) =>
( (
<Route path="/" component={App}> <Route path="/" component={App}>
<IndexRoute component={IDEView} onEnter={checkAuth(store)} /> <IndexRoute component={IDEView} onEnter={checkAuth(store)} />
<Route path="/login" component={LoginView} /> <Route path="/login" component={IDEView} />
<Route path="/signup" component={SignupView} /> <Route path="/signup" component={IDEView} />
<Route path="/projects/:project_id" component={IDEView} /> <Route path="/projects/:project_id" component={IDEView} />
<Route path="/full/:project_id" component={FullView} /> <Route path="/full/:project_id" component={FullView} />
<Route path="/sketches" component={IDEView} /> <Route path="/sketches" component={IDEView} />

View file

@ -1,9 +1,10 @@
.login { .login {
@extend %modal;
text-align: center; text-align: center;
height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
padding: #{20 / $base-font-size}rem;
align-items: center; align-items: center;
} }

View file

@ -1,9 +1,10 @@
.signup { .signup {
@extend %modal;
text-align: center; text-align: center;
height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
padding: #{20 / $base-font-size}rem;
align-items: center; align-items: center;
} }