mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Widgets implemented.
This commit is contained in:
32
tilorswift/js/menu/WidgetBar.js
Normal file
32
tilorswift/js/menu/WidgetBar.js
Normal file
@@ -0,0 +1,32 @@
|
||||
export default class WidgetBar
|
||||
{
|
||||
constructor(id)
|
||||
{
|
||||
this.id = id;
|
||||
this.widgets = [];
|
||||
}
|
||||
|
||||
addWidget(widget)
|
||||
{
|
||||
this.widgets.push(widget);
|
||||
}
|
||||
|
||||
getElement()
|
||||
{
|
||||
let htmlElement = document.createElement('div');
|
||||
htmlElement.id = this.id;
|
||||
|
||||
this.widgets.forEach(
|
||||
(widget) => {
|
||||
let container = document.createElement('div');
|
||||
|
||||
container.appendChild(widget.getTitle());
|
||||
container.appendChild(widget.getElement());
|
||||
|
||||
htmlElement.appendChild(container);
|
||||
}
|
||||
);
|
||||
|
||||
return htmlElement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user