Compare commits
No commits in common. "3522448a7f01cab73b2c73f14f4bc7acd7a385e7" and "d4ae3569ed5148f478f18340382c999b1a8a4bca" have entirely different histories.
3522448a7f
...
d4ae3569ed
30
src/components/CompositeWidget.ts
Normal file
30
src/components/CompositeWidget.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// components/MergedWidget.ts
|
||||||
|
import { Widget } from './Widget';
|
||||||
|
|
||||||
|
export class MergedWidget extends Widget {
|
||||||
|
private children: Widget[] = [];
|
||||||
|
|
||||||
|
constructor(sizeType: 'default' | 'icon' = 'default') {
|
||||||
|
super(sizeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
addWidget(widget: Widget): void {
|
||||||
|
this.children.push(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): HTMLElement {
|
||||||
|
// Clear current container contents (in case render is called more than once)
|
||||||
|
this.container.innerHTML = '';
|
||||||
|
|
||||||
|
for (const widget of this.children) {
|
||||||
|
const rendered = widget.render();
|
||||||
|
|
||||||
|
// Move child nodes (not the container itself)
|
||||||
|
while (rendered.firstChild) {
|
||||||
|
this.container.appendChild(rendered.firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.container;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -59,7 +59,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.widget-header {
|
.widget-header {
|
||||||
font-size: 24px;
|
font-size: 18px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user