aboutsummaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/components/Sidebar/common.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/excalidraw/components/Sidebar/common.ts')
-rw-r--r--packages/excalidraw/components/Sidebar/common.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/packages/excalidraw/components/Sidebar/common.ts b/packages/excalidraw/components/Sidebar/common.ts
new file mode 100644
index 0000000..35c0c8b
--- /dev/null
+++ b/packages/excalidraw/components/Sidebar/common.ts
@@ -0,0 +1,42 @@
+import type { JSX } from "react";
+import React from "react";
+import type { AppState, SidebarName, SidebarTabName } from "../../types";
+
+export type SidebarTriggerProps = {
+ name: SidebarName;
+ tab?: SidebarTabName;
+ icon?: JSX.Element;
+ children?: React.ReactNode;
+ title?: string;
+ className?: string;
+ onToggle?: (open: boolean) => void;
+ style?: React.CSSProperties;
+};
+
+export type SidebarProps<P = {}> = {
+ name: SidebarName;
+ children: React.ReactNode;
+ /**
+ * Called on sidebar open/close or tab change.
+ */
+ onStateChange?: (state: AppState["openSidebar"]) => void;
+ /**
+ * supply alongside `docked` prop in order to make the Sidebar user-dockable
+ */
+ onDock?: (docked: boolean) => void;
+ docked?: boolean;
+ className?: string;
+ // NOTE sidebars we use internally inside the editor must have this flag set.
+ // It indicates that this sidebar should have lower precedence over host
+ // sidebars, if both are open.
+ /** @private internal */
+ __fallback?: boolean;
+} & P;
+
+export type SidebarPropsContextValue = Pick<
+ SidebarProps,
+ "onDock" | "docked"
+> & { onCloseRequest: () => void; shouldRenderDockButton: boolean };
+
+export const SidebarPropsContext =
+ React.createContext<SidebarPropsContextValue>({} as SidebarPropsContextValue);