mirror of
https://github.com/zadam/trilium.git
synced 2025-11-08 14:25:51 +01:00
refactor(client): add support for optional children in layout
This commit is contained in:
@@ -40,6 +40,21 @@ class BasicWidget extends Component {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditionally adds the given components as children to this component.
|
||||
*
|
||||
* @param {boolean} condition whether to add the components.
|
||||
* @param {...any} components the components to be added as children to this component provided the condition is truthy.
|
||||
* @returns self for chaining.
|
||||
*/
|
||||
optChild(condition, ...components) {
|
||||
if (condition) {
|
||||
return this.child(...components);
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
id(id) {
|
||||
this.attrs.id = id;
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user