Notes/apps/client/src/widgets/containers/left_pane_container.ts

37 lines
1.2 KiB
TypeScript
Raw Normal View History

import options from "../../services/options.js";
2020-02-07 22:19:35 +01:00
import FlexContainer from "./flex_container.js";
import appContext, { type EventData } from "../../components/app_context.js";
import type Component from "../../components/component.js";
export default class LeftPaneContainer extends FlexContainer<Component> {
private currentLeftPaneVisible: boolean;
2021-05-22 21:35:25 +02:00
constructor() {
2025-01-09 18:07:02 +02:00
super("column");
this.currentLeftPaneVisible = options.is("leftPaneVisible");
2025-01-09 18:07:02 +02:00
this.id("left-pane");
this.css("height", "100%");
2021-06-13 22:55:31 +02:00
this.collapsible();
}
isEnabled() {
return super.isEnabled() && this.currentLeftPaneVisible;
}
setLeftPaneVisibilityEvent({ leftPaneVisible }: EventData<"setLeftPaneVisibility">) {
this.currentLeftPaneVisible = leftPaneVisible ?? !this.currentLeftPaneVisible;
const visible = this.isEnabled();
this.toggleInt(visible);
if (visible) {
this.triggerEvent("focusTree", {});
} else {
this.triggerEvent("focusOnDetail", { ntxId: appContext.tabManager.getActiveContext()?.ntxId });
}
options.save("leftPaneVisible", this.currentLeftPaneVisible.toString());
}
}