From ac34bf4eeca60c967b43c9b693c56d7ae1125353 Mon Sep 17 00:00:00 2001 From: Roald de Vries Date: Wed, 16 Nov 2016 15:12:25 +0100 Subject: mock up the first forms of signup --- web-ui/react/src/index.js | 163 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 web-ui/react/src/index.js (limited to 'web-ui/react/src') diff --git a/web-ui/react/src/index.js b/web-ui/react/src/index.js new file mode 100644 index 00000000..ae52867f --- /dev/null +++ b/web-ui/react/src/index.js @@ -0,0 +1,163 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import {createStore} from 'redux'; +import {Map} from 'immutable'; + + +class PixelatedComponent extends React.Component { + _updateStateFromStore() { + this.setState(this.props.store.getState().toJS()); + } + + componentWillMount() { + console.debug('mounting', this); + this.unsubscribe = this.props.store.subscribe(() => this._updateStateFromStore()); + this._updateStateFromStore(); + } + + componentWillUnmount() { + console.debug('unmounting', this); + this.unsubscribe() + } +} + + +class InviteCodeForm extends PixelatedComponent { + render() { + return ( +
+
+ + +
+ +
+ ); + } + + _handleClick(event) { + event.stopPropagation(); + event.preventDefault(); + this.props.store.dispatch({type: 'SUBMIT_INVITE_CODE'}); + } +} + + +class CreateAccountForm extends PixelatedComponent { + render() { + return ( +
+ @domain.com +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ ); + } + + _handleClick(event) { + event.stopPropagation(); + event.preventDefault(); + this.props.store.dispatch({type: 'SUBMIT_CREATE_ACCOUNT'}); + } +} + + +class BackupEmailForm extends PixelatedComponent { + render() { + return ( +
+ @domain.com +
+ + +
+ +
+ + +
+ + +
+ ); + } + + _handleClick(event) { + event.stopPropagation(); + event.preventDefault(); + this.props.store.dispatch({type: 'SUBMIT_CREATE_ACCOUNT'}); + } +} + + +class SignUp extends PixelatedComponent { + render() { + return ( +
+
+

{this.state.header}

+

{this.state.summary}

+
+
+ {this._form()} +
+
+ ); + } + + _form() { + switch(this.state.form) { + case 'invite_code': return ; + case 'create_account': return ; + case 'backup_email': return ; + default: throw Exception('TODO'); + } + } +} + + +const initialState = new Map({ + form: 'invite_code', + header: 'Welcome', + summary: ['Do you have an invite code?',
, 'Type it below'], +}); + + +const store = createStore((state=initialState, action) => { + switch (action.type) { + case 'SUBMIT_INVITE_CODE': + return state.merge({ + form: 'create_account', + header: 'Create your account', + summary: 'Choose your username, and be careful about your password, it must be strong and easy to remember. If you have a password manager, we strongly advise you to use one.', + }); + case 'SUBMIT_CREATE_ACCOUNT': + return state.merge({ + form: 'backup_email', + header: 'In case you lose your password...', + summary: 'Set up a backup email account. You\'ll receive an email with a code so you can recover your account in the future, other will be sent to your account administrator.', + }); + default: + return state; + } +}); + + +ReactDOM.render( + , + document.getElementById('app') +); -- cgit v1.2.3