Skip to content

Build your personal knowledge base with Trilium Notes

feat(react/widgets): port toggle sidebar

Elian Doranec646809dd5b
diff --git a/apps/client/src/layouts/mobile_layout.tsx b/apps/client/src/layouts/mobile_layout.tsx
index e80c605fe4..4bfddc3a61 100644
--- a/apps/client/src/layouts/mobile_layout.tsx
+++ b/apps/client/src/layouts/mobile_layout.tsx
@@ -3,7 +3,6 @@ import NoteTitleWidget from "../widgets/note_title.js";
import NoteDetailWidget from "../widgets/note_detail.js";
import QuickSearchWidget from "../widgets/quick_search.js";
import NoteTreeWidget from "../widgets/note_tree.js";
-import ToggleSidebarButtonWidget from "../widgets/mobile_widgets/toggle_sidebar_button.js";
import MobileDetailMenuWidget from "../widgets/mobile_widgets/mobile_detail_menu.js";
import ScreenContainer from "../widgets/mobile_widgets/screen_container.js";
import ScrollingContainer from "../widgets/containers/scrolling_container.js";
@@ -23,6 +22,7 @@ import FilePropertiesTab from "../widgets/ribbon/FilePropertiesTab.jsx";
import { useNoteContext } from "../widgets/react/hooks.jsx";
import FloatingButtons from "../widgets/FloatingButtons.jsx";
import { MOBILE_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.jsx";
+import ToggleSidebarButton from "../widgets/mobile_widgets/toggle_sidebar_button.jsx";
const MOBILE_CSS = `
<style>
@@ -139,7 +139,7 @@ export default class MobileLayout {
.contentSized()
.css("font-size", "larger")
.css("align-items", "center")
- .child(new ToggleSidebarButtonWidget().contentSized())
+ .child(<ToggleSidebarButton />)
.child(<NoteTitleWidget />)
.child(new MobileDetailMenuWidget(true).contentSized())
)
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 2162bce241..461baa957a 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1682,7 +1682,8 @@
"hoist-this-note-workspace": "Hoist this note (workspace)",
"refresh-saved-search-results": "Refresh saved search results",
"create-child-note": "Create child note",
- "unhoist": "Unhoist"
+ "unhoist": "Unhoist",
+ "toggle-sidebar": "Toggle sidebar"
},
"title_bar_buttons": {
"window-on-top": "Keep Window on Top"
diff --git a/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.ts b/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.ts
deleted file mode 100644
index b2a8039a12..0000000000
--- a/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import BasicWidget from "../basic_widget.js";
-
-const TPL = /*html*/`
-<button type="button" class="action-button bx bx-sidebar"></button>`;
-
-class ToggleSidebarButtonWidget extends BasicWidget {
- doRender() {
- this.$widget = $(TPL);
-
- this.$widget.on("click", () =>
- this.triggerCommand("setActiveScreen", {
- screen: "tree"
- })
- );
- }
-}
-
-export default ToggleSidebarButtonWidget;
diff --git a/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx b/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx
new file mode 100644
index 0000000000..d22f3df8c9
--- /dev/null
+++ b/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx
@@ -0,0 +1,18 @@
+import { useContext } from "preact/hooks";
+import ActionButton from "../react/ActionButton";
+import { ParentComponent } from "../react/react_utils";
+import { t } from "../../services/i18n";
+
+export default function ToggleSidebarButton() {
+ const parentComponent = useContext(ParentComponent);
+
+ return (
+ <ActionButton
+ icon="bx bx-sidebar"
+ text={t("note_tree.toggle-sidebar")}
+ onClick={() => parentComponent?.triggerCommand("setActiveScreen", {
+ screen: "tree"
+ })}
+ />
+ )
+}