Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/sidebar): basic right panel widget implementation

Elian Doran5fc10fe04147
diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsx
index 17c77f8d8c..cbce8fb18a 100644
--- a/apps/client/src/layouts/desktop_layout.tsx
+++ b/apps/client/src/layouts/desktop_layout.tsx
@@ -44,6 +44,7 @@ import UploadAttachmentsDialog from "../widgets/dialogs/upload_attachments.js";
import utils from "../services/utils.js";
import WatchedFileUpdateStatusWidget from "../widgets/watched_file_update_status.js";
import NoteDetail from "../widgets/NoteDetail.jsx";
+import RightPanelWidget from "../widgets/sidebar/RightPanelWidget.jsx";
export default class DesktopLayout {
diff --git a/apps/client/src/widgets/sidebar/RightPanelWidget.tsx b/apps/client/src/widgets/sidebar/RightPanelWidget.tsx
new file mode 100644
index 0000000000..94a5cf04c4
--- /dev/null
+++ b/apps/client/src/widgets/sidebar/RightPanelWidget.tsx
@@ -0,0 +1,33 @@
+import { useContext, useRef } from "preact/hooks";
+import { ParentComponent } from "../react/react_utils";
+import { ComponentChildren } from "preact";
+
+interface RightPanelWidgetProps {
+ title: string;
+ children: ComponentChildren;
+ buttons?: ComponentChildren;
+}
+
+export default function RightPanelWidget({ title, buttons, children }: RightPanelWidgetProps) {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const parentComponent = useContext(ParentComponent);
+
+ if (parentComponent) {
+ parentComponent.initialized = Promise.resolve();
+ }
+
+ return (
+ <div ref={containerRef} class="card widget" style={{contain: "none"}}>
+ <div class="card-header">
+ <div class="card-header-title">{title}</div>
+ <div class="card-header-buttons">{buttons}</div>
+ </div>
+
+ <div id={parentComponent?.componentId} class="body-wrapper">
+ <div class="card-body">
+ {children}
+ </div>
+ </div>
+ </div>
+ );
+}