mirror of
https://github.com/discourse/discourse.git
synced 2025-02-14 05:12:45 +08:00
![Joffrey JAFFEUX](/assets/img/avatar_default.png)
- Introduces ComponentConnector to use a component inside a widget - Use css to set size of components instead of properties - Smarted positionning - Style tweaks
36 lines
832 B
JavaScript
36 lines
832 B
JavaScript
export default class ComponentConnector {
|
|
constructor(widget, componentName, opts) {
|
|
this.widget = widget;
|
|
this.opts = opts;
|
|
this.componentName = componentName;
|
|
}
|
|
|
|
init() {
|
|
const $elem = $('<div style="display: inline-block;" class="widget-component-connector"></div>');
|
|
const elem = $elem[0];
|
|
const { opts, widget, componentName } = this;
|
|
|
|
Ember.run.next(() => {
|
|
const mounted = widget._findView();
|
|
|
|
const view = widget
|
|
.register
|
|
.lookupFactory(`component:${componentName}`)
|
|
.create(opts);
|
|
|
|
if (Ember.setOwner) {
|
|
Ember.setOwner(view, Ember.getOwner(mounted));
|
|
}
|
|
|
|
mounted._connected.push(view);
|
|
view.renderer.appendTo(view, $elem[0]);
|
|
});
|
|
|
|
return elem;
|
|
}
|
|
|
|
update() { }
|
|
}
|
|
|
|
ComponentConnector.prototype.type = 'Widget';
|