mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-25 06:01:40 +08:00
refactor(client): add support for optional children in layout
This commit is contained in:
parent
79b31bda76
commit
8300acd30b
@ -92,15 +92,17 @@ export default class DesktopLayout {
|
|||||||
getRootWidget(appContext) {
|
getRootWidget(appContext) {
|
||||||
appContext.noteTreeWidget = new NoteTreeWidget();
|
appContext.noteTreeWidget = new NoteTreeWidget();
|
||||||
|
|
||||||
|
const launcherPaneIsHorizontal = true;
|
||||||
|
const launcherPane = new FlexContainer("column")
|
||||||
|
.id("launcher-pane")
|
||||||
|
.css("width", "53px")
|
||||||
|
.child(new GlobalMenuWidget())
|
||||||
|
.child(new LauncherContainer())
|
||||||
|
.child(new LeftPaneToggleWidget());
|
||||||
|
|
||||||
return new RootContainer()
|
return new RootContainer()
|
||||||
.setParent(appContext)
|
.setParent(appContext)
|
||||||
.child(new FlexContainer("column")
|
.optChild(!launcherPaneIsHorizontal, launcherPane)
|
||||||
.id("launcher-pane")
|
|
||||||
.css("width", "53px")
|
|
||||||
.child(new GlobalMenuWidget())
|
|
||||||
.child(new LauncherContainer())
|
|
||||||
.child(new LeftPaneToggleWidget())
|
|
||||||
)
|
|
||||||
.child(new LeftPaneContainer()
|
.child(new LeftPaneContainer()
|
||||||
.child(new QuickSearchWidget())
|
.child(new QuickSearchWidget())
|
||||||
.child(appContext.noteTreeWidget)
|
.child(appContext.noteTreeWidget)
|
||||||
|
@ -40,6 +40,21 @@ class BasicWidget extends Component {
|
|||||||
return this;
|
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) {
|
id(id) {
|
||||||
this.attrs.id = id;
|
this.attrs.id = id;
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user