update design bundle for router

This commit is contained in:
Eric Hulburd
2016-03-01 13:16:31 -06:00
parent c890132f2b
commit 916a8dc255
15 changed files with 130 additions and 55 deletions

View File

@@ -0,0 +1 @@
export const COMPONENT_MAP = {"about":"dashboard/about/about","energy":"dashboard/energy/energy","energy_graph":"dashboard/energy/graph/graph","energy_table":"dashboard/energy/table/table","house":"dashboard/house/house","layout":"dashboard/layout/layout","power_graph":"dashboard/power/graph/graph","power":"dashboard/power/power","power_table":"dashboard/power/table/table"}

View File

@@ -1,16 +1,11 @@
const STYLE_ROUTES = Object.freeze({
energy: 'dashboard/energy/energy.scss',
layout: 'dashboard/layout/layout.scss',
power: 'dashboard/power/power.scss',
app: 'dashboard/app.scss'
});
import {COMPONENT_MAP} from './component_map';
class Styles {
static sync(){
var all = [],
css = '';
for (var view in STYLE_ROUTES){
for (var view in COMPONENT_MAP){
var done = new Promise((fnResolve, fnReject)=>{
Styles.addCss(view, fnResolve)
}).then((result)=>{
@@ -26,7 +21,7 @@ class Styles {
static addCss(view, fnResolve){
return jQuery.ajax({
url: STYLE_ROUTES[view]
url: COMPONENT_MAP[view] + '.scss'
}).then((scss)=>{
var sass = new Sass();
if (!scss) return fnResolve("");

View File

@@ -0,0 +1 @@
export const TEMPLATE_MAP = {"about":"dashboard/about/about.rt","energy":"dashboard/energy/energy.rt","energy_graph":"dashboard/energy/graph/graph.rt","energy_table":"dashboard/energy/table/table.rt","house":"dashboard/house/house.rt","layout":"dashboard/layout/layout.rt","power_graph":"dashboard/power/graph/graph.rt","power":"dashboard/power/power.rt","power_table":"dashboard/power/table/table.rt"}

View File

@@ -2,14 +2,7 @@ import rt from 'react-templates';
import React from 'react';
import _ from 'lodash';
import Energy from './../../dashboard/energy/energy';
import Power from './../../dashboard/power/power';
const TEMPLATE_ROUTES = Object.freeze({
energy: 'dashboard/energy/energy.rt',
layout: 'dashboard/layout/layout.rt',
power: 'dashboard/power/power.rt'
});
import {COMPONENT_MAP} from './component_map';
var TEMPLATES = {};
@@ -17,32 +10,32 @@ class Templates {
static sync(){
var all = [];
for (var view in TEMPLATE_ROUTES){
for (var component_name in COMPONENT_MAP){
var done = new Promise((fnResolve, fnReject)=>{
Templates.evalTemplate(view, fnResolve);
Templates.evalTemplate(component_name, fnResolve);
});
all.push(done);
}
return Promise.all(all);
}
static forComponent(view){
return TEMPLATES[view];
static forComponent(name){
return TEMPLATES[name];
}
static evalTemplate(view, fnResolve){
static evalTemplate(component_name, fnResolve){
jQuery.ajax({
url: TEMPLATE_ROUTES[view]
url: COMPONENT_MAP[component_name] + '.rt'
}).done((template)=>{
var code = rt.convertTemplateToReact(template, {modules: 'none', name: view}),
var code = rt.convertTemplateToReact(template, {modules: 'none', name: component_name}),
eval_context = {};
code = code.replace('var ' + view + ' = ', 'eval_context.' + view + ' = ');
code = code.replace('var ' + component_name + ' = ', 'eval_context.' + component_name + ' = ');
new Function('with(this){ ' + code + ' } ').call({
eval_context: eval_context,
'_': _,
'React': React
});
TEMPLATES[view] = eval_context[view];
TEMPLATES[component_name] = eval_context[component_name];
fnResolve();
});
}

View File

@@ -0,0 +1,3 @@
#about {
}

View File

@@ -0,0 +1,3 @@
#energy_graph {
}

View File

@@ -1,4 +1,4 @@
<table rt-if="this.context.house" class="table">
<table id="energy_table" rt-if="this.context.house" class="table">
<thead>
<tr>
<th></th>

View File

@@ -0,0 +1,3 @@
#energy_table {
}

View File

@@ -0,0 +1 @@
#house {}

View File

@@ -0,0 +1,3 @@
#power_graph {
}

View File

@@ -1,4 +1,4 @@
<table class="table" rt-if="this.context.house">
<table id="power_table" class="table" rt-if="this.context.house">
<thead>
<tr>
<th></th>

View File

@@ -0,0 +1,3 @@
#power_table {
}