refactoring of layout finished

This commit is contained in:
zadam
2020-02-27 10:03:14 +01:00
parent 637010577b
commit 368d0c55da
13 changed files with 82 additions and 85 deletions

View File

@@ -4,12 +4,12 @@ export default class FlexContainer extends BasicWidget {
constructor(direction) {
super();
if (!direction) {
throw new Error(`Direction argument missing, use either 'row' or 'column'`);
if (!direction || !['row', 'column'].includes(direction)) {
throw new Error(`Direction argument given as "${direction}", use either 'row' or 'column'`);
}
this.attrs = {
style: 'display: flex;'
style: `display: flex; flex-direction: ${direction};`,
};
this.children = [];
@@ -25,13 +25,8 @@ export default class FlexContainer extends BasicWidget {
return this;
}
rowFlex() {
this.css('flex-direction', 'row');
return this;
}
columnFlex() {
this.css('flex-direction', 'column');
collapsible() {
this.css('min-height', '0');
return this;
}
@@ -40,10 +35,6 @@ export default class FlexContainer extends BasicWidget {
return this;
}
child(widgetFactory) {
this.children = widgetFactory(this);
}
doRender() {
this.$widget = $(`<div>`);
@@ -55,8 +46,6 @@ export default class FlexContainer extends BasicWidget {
this.$widget.attr(key, this.attrs[key]);
}
if (!this.children)
for (const widget of this.children) {
this.$widget.append(widget.render());
}