Switch everything over to use the component broker.

This commit is contained in:
David Baker 2015-06-17 16:43:29 +01:00
parent 6542201ac6
commit ed58a59f82
6 changed files with 40 additions and 33 deletions

View File

@ -1,24 +1,9 @@
var components = {}; var components = {};
function load(name) { function load(name) {
var types = [ var module = require("./"+name);
'atoms',
'molecules',
'organisms',
'templates',
'pages'
];
var ex = null;
for (var i = 0; i < types.length; ++i) {
try {
var module = require("./"+types[i]+"/"+name);
components[name] = module; components[name] = module;
return module; return module;
} catch (err) {
ex = err;
}
}
throw ex;
}; };
module.exports = { module.exports = {
@ -34,7 +19,21 @@ module.exports = {
} }
}; };
// Statically require all the components we know about,
// otherwise browserify has no way of knowing what module to include
// Must be in this file (because the require is file-specific) and
// must be at the end because the components include this file.
require('./atoms/LogoutButton');
require('./atoms/MessageTimestamp');
require('./molecules/MatrixToolbar');
require('./molecules/RoomTile');
require('./molecules/MessageTile');
require('./molecules/SenderProfile');
require('./molecules/UnknownMessageTile');
require('./molecules/MTextTile');
require('./molecules/MEmoteTile');
require('./molecules/RoomHeader');
require('./molecules/MessageComposer');
require('./organisms/RoomList'); require('./organisms/RoomList');
require('./organisms/RoomView'); require('./organisms/RoomView');
require('./molecules/MatrixToolbar');
require('./templates/Login'); require('./templates/Login');

View File

@ -1,6 +1,8 @@
var React = require('react'); var React = require('react');
var LogoutButton = require("../atoms/LogoutButton"); var ComponentBroker = require('../ComponentBroker');
var LogoutButton = ComponentBroker.get("atoms/LogoutButton");
module.exports = React.createClass({ module.exports = React.createClass({
render: function() { render: function() {

View File

@ -1,13 +1,15 @@
var React = require('react'); var React = require('react');
var MessageTimestamp = require('../atoms/MessageTimestamp'); var ComponentBroker = require('../ComponentBroker');
var SenderProfile = require('../molecules/SenderProfile');
var UnknownMessageTile = require('../molecules/UnknownMessageTile'); var MessageTimestamp = ComponentBroker.get('atoms/MessageTimestamp');
var SenderProfile = ComponentBroker.get('molecules/SenderProfile');
var UnknownMessageTile = ComponentBroker.get('molecules/UnknownMessageTile');
var tileTypes = { var tileTypes = {
'm.text': require('../molecules/MTextTile'), 'm.text': ComponentBroker.get('molecules/MTextTile'),
'm.emote': require('../molecules/MEmoteTile') 'm.emote': ComponentBroker.get('molecules/MEmoteTile')
}; };
module.exports = React.createClass({ module.exports = React.createClass({

View File

@ -1,8 +1,9 @@
var React = require('react'); var React = require('react');
var MatrixClientPeg = require("../MatrixClientPeg"); var MatrixClientPeg = require("../MatrixClientPeg");
var ComponentBroker = require('../ComponentBroker');
var RoomTile = require("../molecules/RoomTile"); var RoomTile = ComponentBroker.get("molecules/RoomTile");
module.exports = React.createClass({ module.exports = React.createClass({
componentWillMount: function() { componentWillMount: function() {

View File

@ -1,9 +1,12 @@
var React = require('react'); var React = require('react');
var MessageTile = require('../molecules/MessageTile');
var RoomHeader = require('../molecules/RoomHeader');
var MessageComposer = require('../molecules/MessageComposer');
var MatrixClientPeg = require("../MatrixClientPeg"); var MatrixClientPeg = require("../MatrixClientPeg");
var ComponentBroker = require('../ComponentBroker');
var MessageTile = ComponentBroker.get('molecules/MessageTile');
var RoomHeader = ComponentBroker.get('molecules/RoomHeader');
var MessageComposer = ComponentBroker.get('molecules/MessageComposer');
module.exports = React.createClass({ module.exports = React.createClass({
getInitialState: function() { getInitialState: function() {

View File

@ -1,10 +1,10 @@
var React = require('react'); var React = require('react');
var ComponentBroker = require('../ComponentBroker'); var ComponentBroker = require('../ComponentBroker');
var RoomList = ComponentBroker.get('RoomList'); var RoomList = ComponentBroker.get('organisms/RoomList');
var RoomView = ComponentBroker.get('RoomView'); var RoomView = ComponentBroker.get('organisms/RoomView');
var MatrixToolbar = ComponentBroker.get('MatrixToolbar'); var MatrixToolbar = ComponentBroker.get('molecules/MatrixToolbar');
var Login = ComponentBroker.get('Login'); var Login = ComponentBroker.get('templates/Login');
// should be atomised // should be atomised
var Loader = require("react-loader"); var Loader = require("react-loader");