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 = {};
function load(name) {
var types = [
'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;
return module;
} catch (err) {
ex = err;
}
}
throw ex;
var module = require("./"+name);
components[name] = module;
return module;
};
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/RoomView');
require('./molecules/MatrixToolbar');
require('./templates/Login');

View File

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

View File

@ -1,13 +1,15 @@
var React = require('react');
var MessageTimestamp = require('../atoms/MessageTimestamp');
var SenderProfile = require('../molecules/SenderProfile');
var ComponentBroker = require('../ComponentBroker');
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 = {
'm.text': require('../molecules/MTextTile'),
'm.emote': require('../molecules/MEmoteTile')
'm.text': ComponentBroker.get('molecules/MTextTile'),
'm.emote': ComponentBroker.get('molecules/MEmoteTile')
};
module.exports = React.createClass({

View File

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

View File

@ -1,9 +1,12 @@
var React = require('react');
var MessageTile = require('../molecules/MessageTile');
var RoomHeader = require('../molecules/RoomHeader');
var MessageComposer = require('../molecules/MessageComposer');
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({
getInitialState: function() {

View File

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