mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 05:46:10 +01:00
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
import "./left_pane_toggle.css";
|
|
import { useEffect, useState } from "preact/hooks";
|
|
import ActionButton from "../react/ActionButton";
|
|
import options from "../../services/options";
|
|
import { t } from "../../services/i18n";
|
|
import { useTriliumEvent } from "../react/hooks";
|
|
import resizer from "../../services/resizer";
|
|
|
|
export default function LeftPaneToggle({ isHorizontalLayout }: { isHorizontalLayout: boolean }) {
|
|
const [ currentLeftPaneVisible, setCurrentLeftPaneVisible ] = useState(options.is("leftPaneVisible"));
|
|
|
|
useTriliumEvent("setLeftPaneVisibility", ({ leftPaneVisible }) => {
|
|
setCurrentLeftPaneVisible(leftPaneVisible ?? !currentLeftPaneVisible);
|
|
});
|
|
|
|
useEffect(() => {
|
|
resizer.setupLeftPaneResizer(currentLeftPaneVisible);
|
|
}, [ currentLeftPaneVisible ]);
|
|
|
|
return (
|
|
<ActionButton
|
|
className={`${isHorizontalLayout ? "toggle-button" : "launcher-button"} left-pane-toggle-button ${currentLeftPaneVisible ? "action-collapse" : "action-expand"}`}
|
|
text={currentLeftPaneVisible ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel")}
|
|
triggerCommand={currentLeftPaneVisible ? "hideLeftPane" : "showLeftPane"}
|
|
icon={isHorizontalLayout ? "bx bx-sidebar" : "bx bx-chevrons-left"}
|
|
/>
|
|
)
|
|
} |