Add basic UI

This includes the login form, registration, and a simple nav bar when
you're logged in. I'm just sort of figuring all this stuff out
This commit is contained in:
Eli Ribble 2016-05-17 16:38:20 -06:00
parent ca2b5cdabb
commit 867df0fc57
17 changed files with 715 additions and 0 deletions

14
lib/store/root.js Normal file
View file

@ -0,0 +1,14 @@
import { combineReducers } from 'redux';
import createStoreWithMiddleware from 'vanth/middleware';
import SessionReducer from 'vanth/store/session';
import URLReducer from 'vanth/store/url';
const root = combineReducers({
session : SessionReducer,
url : URLReducer,
});
const store = createStoreWithMiddleware(root);
module.exports = store;

19
lib/store/session.js Normal file
View file

@ -0,0 +1,19 @@
import _ from 'lodash';
import * as Constants from 'vanth/constants';
const emptyState = {
name : null,
username : null,
uri : null,
};
var reducer = function(state = emptyState, action) {
switch (action.type) {
case Constants.ActionType.SESSION_GET_COMPLETE:
return _.assign({}, state, action.data);
default:
return state;
}
}
module.exports = reducer;

34
lib/store/url.js Normal file
View file

@ -0,0 +1,34 @@
import urllite from 'urllite';
import { ActionType } from 'vanth/constants';
let _parseSearch = function(location) {
let search = {};
let query = location.search.substring(1);
let vars = query.split('&');
for(var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
search[pair[0]] = decodeURIComponent(pair[1]);
}
return search;
}
const initialState = {
location : urllite(window.location),
search : _parseSearch(urllite(window.location)),
};
var reducer = function(state = initialState, action) {
switch (action.type) {
case ActionType.URL_CHANGE:
let location = urllite(action.data.newURL);
return _.assign({}, state, {
location: location,
search: _parseSearch(location)
});
default:
return state;
}
}
module.exports = reducer;