core-ui
Version:
Core UI is a dead-simple wrapper around your (React) component library, which aims to provide two benefits: simple, flat paths for import statements and 'switchable' presentational components
31 lines (27 loc) • 777 B
JavaScript
var assign = require('object-assign');
var coreUI = {
registerComponent: function(name, src) {
if (coreUI[name]) {
throw new Error('Component ' + name + ' already exists in coreUI. Use a different name.');
}
coreUI[name] = src;
return coreUI;
},
unregisterComponent: function(name) {
delete coreUI[name];
return coreUI;
},
registerComponents: function(obj) {
Object.keys(obj).map(function(component) {
coreUI.registerComponent(component, obj[component]);
});
},
getComponents: function() {
var components = Object.assign({}, coreUI);
delete components.registerComponent;
delete components.registerdComponents;
delete components.getComponents;
return components;
}
};
module.exports = coreUI;