[Ivan Diaz] - Add signup page and callback util
This commit is contained in:
parent
c8fe247e54
commit
cc2654d3f5
|
@ -6,13 +6,15 @@ import DemoPage from 'app/demo/components-demo-page'
|
||||||
|
|
||||||
import MainLayout from 'app/main/main-layout';
|
import MainLayout from 'app/main/main-layout';
|
||||||
import MainHomePage from 'app/main/main-home-page';
|
import MainHomePage from 'app/main/main-home-page';
|
||||||
|
import MainSignUpPage from 'app/main/main-signup-page';
|
||||||
|
|
||||||
|
|
||||||
export default (
|
export default (
|
||||||
<Route handler={App} path='/'>
|
<Route handler={App} path='/'>
|
||||||
|
|
||||||
<Route name='main' path='/app' handler={MainLayout}>
|
<Route name='main' path='/app' handler={MainLayout}>
|
||||||
<DefaultRoute handler={MainHomePage} />
|
<DefaultRoute name='home' handler={MainHomePage} />
|
||||||
|
<Route name='signup' path='/app/signup' handler={MainSignUpPage}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route name='Demo' path='/demo' handler={DemoPage} />
|
<Route name='Demo' path='/demo' handler={DemoPage} />
|
||||||
|
|
|
@ -7,7 +7,8 @@ var MainLayoutHeader = React.createClass({
|
||||||
return (
|
return (
|
||||||
<div className="main-layout-header">
|
<div className="main-layout-header">
|
||||||
<div className="main-layout-header--login-links">
|
<div className="main-layout-header--login-links">
|
||||||
<Button type="light">Sign up</Button>
|
<Button type="light" route={{to:'home'}}>Log in</Button>
|
||||||
|
<Button type="light" route={{to:'signup'}}>Sign up</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import React from 'react/addons';
|
||||||
|
import {RouteHandler} from 'react-router';
|
||||||
|
|
||||||
|
var MainSignUpPage = React.createClass({
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
this is the sing up page
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default MainSignUpPage;
|
|
@ -1,19 +1,24 @@
|
||||||
/**
|
import React from 'react/addons';
|
||||||
* Created by ivan on 16/08/15.
|
import classNames from 'classnames';
|
||||||
*/
|
import {Navigation} from 'react-router';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import React from 'react/addons';
|
import callback from 'utils/callback';
|
||||||
import classNames from 'classnames';
|
|
||||||
|
|
||||||
var Button = React.createClass({
|
var Button = React.createClass({
|
||||||
|
|
||||||
|
mixins: [Navigation],
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
children: React.PropTypes.node,
|
children: React.PropTypes.node,
|
||||||
type: React.PropTypes.oneOf([
|
type: React.PropTypes.oneOf([
|
||||||
'primary',
|
'primary',
|
||||||
'light'
|
'light'
|
||||||
])
|
]),
|
||||||
|
route: React.PropTypes.shape({
|
||||||
|
to: React.PropTypes. string.isRequired,
|
||||||
|
params: React.PropTypes.object,
|
||||||
|
query: React.PropTypes.query
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
|
@ -24,7 +29,7 @@ var Button = React.createClass({
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<button {...this.props} className={this.getClass()}>
|
<button {...this.props} onClick={callback(this.handleClick, this.props.onClick)} className={this.getClass()}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
@ -39,6 +44,12 @@ var Button = React.createClass({
|
||||||
classes[this.props.className] = (this.props.className);
|
classes[this.props.className] = (this.props.className);
|
||||||
|
|
||||||
return classNames(classes);
|
return classNames(classes);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleClick() {
|
||||||
|
if (this.props.route) {
|
||||||
|
this.transitionTo(this.props.route.to, this.props.route.param, this.props.route.query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
export default function (defaultFunction, callback, options = {}, extraPreventions = []) {
|
||||||
|
return function (nativeEvent) {
|
||||||
|
var preventions = {'default': false};
|
||||||
|
var event = _.extend({}, nativeEvent, options, {
|
||||||
|
preventDefault() {
|
||||||
|
nativeEvent.preventDefault();
|
||||||
|
preventions['default'] = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
extraPreventions.forEach((prevention) => {
|
||||||
|
preventions[prevention] = false;
|
||||||
|
|
||||||
|
event['is' + prevention.capitalize() + 'Prevented'] = () => preventions[prevention];
|
||||||
|
event['prevent' + prevention.capitalize()] = () => (preventions[prevention] = true);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (typeof callback === 'function') callback(event);
|
||||||
|
|
||||||
|
if (!preventions['default']) defaultFunction(event);
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue