SRC_DIR=js
BUILD_DIR=build/js
-JSX_SRC= main.jsx signup.jsx signin.jsx otp.jsx poloniex.jsx password_reset.jsx change_password.jsx
+JSX_SRC= header_footer.jsx main.jsx signup.jsx signin.jsx otp.jsx poloniex.jsx password_reset.jsx change_password.jsx
JS_SRC= cookies.js app.js api.js
STATIC_FILES= index.html style.css
JSX_OBJS=$(addprefix $(BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
import page from 'page';
import React from 'react';
import ReactDOM from 'react-dom';
+import {Header, Footer} from './header_footer.js';
var App = {};
var cookieExpire = 60 * 60 * 24 * 7;
var root = React.createElement(
'div',
{className: 'container'},
- app
+ [
+ React.createElement(Header, {key: 'header', isLoggedIn: App.isUserSignedIn()}),
+ React.createElement(React.Fragment, {key: 'app'}, app),
+ React.createElement(Footer, {key: 'footer', isLoggedIn: App.isUserSignedIn()})
+ ],
);
ReactDOM.unmountComponentAtNode(document.getElementById('app'));
var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk});
return (
<div className="row sign-in">
- <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center">
+ <div className="offset-1 col-10 offset-md-4 col-md-4 text-center">
<form role="form" onSubmit={this.handleSubmit}>
<input className="form-control" type="password" placeholder="password" onChange={this.handlePasswordChange} />
<input className="form-control submit" type="submit" value="Change password" />
--- /dev/null
+import React from 'react';
+
+class Signout extends React.Component {
+ render = () => {
+ return <a href="/signout"><u>Logout</u></a>;
+ }
+}
+
+class Logo extends React.Component {
+ render() {
+ return <div id="logo" className="w-100 h-100 align-self-center">
+ <h1><a href="/">CryptoPF</a></h1>
+ </div>;
+ }
+}
+
+class Footer extends React.Component {
+ render = () => {
+ var elements = this.props.elements;
+ if (elements === undefined) {
+ elements = [];
+ }
+
+ if (this.props.isLoggedIn === true) {
+ elements = elements.concat(<Signout />);
+ }
+
+ if (elements.length > 0) {
+ elements = [<hr key="hr"/>].concat(elements);
+ }
+
+ var rows = elements.map(function(element, i) {
+ return <div className="row text-center" key={'footer-el-' + i}>
+ <div className="col-12">
+ {element}
+ </div>
+ </div>;
+ });
+ return <div id="footer" className="row">
+ <div className="offset-4 col-4 d-sm-none">
+ {rows}
+ </div>
+ </div>;
+ }
+}
+
+class Header extends React.Component {
+ render = () => {
+ var elements = this.props.elements;
+ if (elements === undefined) {
+ elements = [];
+ }
+
+ if (this.props.isLoggedIn === true) {
+ elements = elements.concat(<Signout />);
+ }
+
+ elements = elements.map(function(element, i) {
+ return <div className="text-center" key={'header-el-' + i}>
+ {element}
+ </div>;
+ });
+
+ return <div id="header" className="row">
+ <div className="offset-3 col-6 offset-md-4 col-md-4">
+ <Logo />
+ </div>
+ <div className="col-3 col-md-4 align-self-center h-100 d-none d-sm-flex justify-content-end">
+ {elements}
+ </div>
+ </div>;
+ }
+}
+
+export {
+ Header,
+ Footer,
+};
import React from 'react';
import qs from 'qs';
-class Header extends React.Component {
- render = () => {
- if (this.props.displayLogout === true) {
- return <div id="header" className="row">
- <div className="offset-4 col-4">
- <Logo />
- </div>
- <div className="offset-2 col-2 align-self-center h-100">
- <a href="/signout"><u>Logout</u></a>
- </div>
- </div>;
- }
- return <div id="header" className="row">
- <div className="offset-4 col-4">
- <Logo />
- </div>
- </div>;
-
- }
-}
-
-class Logo extends React.Component {
- render() {
- return <div id="logo" className="w-100 h-100 align-self-center">
- <h1><a href="/">CryptoPF</a></h1>
- </div>;
- }
-}
-
App.page('/signup', false, function(context) {
if (App.isUserSignedIn()) {
App.go('/me');
}
App.mount(<div>
- <Header />
<SignupForm onSuccess={App.onUserSignUp}/>
</div>);
});
}
App.mount(<div>
- <Header />
<SigninForm onSuccess={App.onUserSignIn}/>
</div>);
});
}
App.mount(<div>
- <Header />
<PasswordResetForm />
</div>);
});
}
App.mount(<div>
- <Header />
<ChangePasswordForm token={token} onSuccess={App.go.bind(App, '/signin')}/>
</div>);
});
App.page('/me', true, function(context) {
App.mount(<div>
- <Header displayLogout={true} />
<PoloniexController/>
</div>);
});
App.page('/not_confirmed', true, function(context) {
App.mount(<div>
- <Header displayLogout={true}/>
<div className="row">
<div className="box offset-3 col-6 text-center">
<p>Please be patient, you account is being confirmed...</p>
}
App.mount(<div>
- <Header displayLogout={true}/>
<OtpEnrollForm onSuccess={App.onUserValidateOtp} img={'data:image/png;base64,' + data.base64img} secret={data.secret}/>
</div>);
App.page('/otp/validate', true, function(context) {
App.mount(<div>
- <Header displayLogout={true}/>
<OtpEnrollForm onSuccess={App.onUserValidateOtp} />
</div>);
});
var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk});
return (
<div className="row sign-in">
- <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center">
+ <div className="offset-1 col-10 offset-md-4 col-md-4 text-center">
<form role="form" onSubmit={this.handleSubmit}>
<input className="form-control" type="email" placeholder="email" onChange={this.handleEmailChange} />
<input className="form-control submit" type="submit" value="Reset" />
}
}
-export default PasswordResetForm;
\ No newline at end of file
+export default PasswordResetForm;
var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk});
return (
<div className="row sign-in">
- <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center">
+ <div className="offset-1 col-10 offset-md-4 col-md-4 text-center">
<form role="form" onSubmit={this.handleSubmit}>
<input className="form-control" type="email" placeholder="email" onChange={this.handleEmailChange} />
<input className="form-control" type="password" placeholder="password" onChange={this.handlePasswordChange} />
var cName = classNames('form-message', {'hidden': this.state.hideMsg, 'message-ok': this.state.msgOk});
return (
<div className="row sign-in">
- <div className="offset-4 col-4 col-xs-offset-1 col-xs-10 text-center">
+ <div className="offset-1 col-10 offset-md-4 col-md-4 text-center">
<form role="form" onSubmit={this.handleSubmit}>
<input className="form-control" type="email" placeholder="email" onChange={this.handleEmailChange} />
<input className="form-control" type="password" placeholder="password" onChange={this.handlePasswordChange} />