add a renderTopLeftUI to props

This commit is contained in:
Ryan Di
2025-09-24 23:24:49 +10:00
parent e59179a55e
commit 149bce4259
3 changed files with 22 additions and 10 deletions

View File

@@ -91,6 +91,7 @@ interface LayerUIProps {
onPenModeToggle: AppClassProperties["togglePenMode"]; onPenModeToggle: AppClassProperties["togglePenMode"];
showExitZenModeBtn: boolean; showExitZenModeBtn: boolean;
langCode: Language["code"]; langCode: Language["code"];
renderTopLeftUI?: ExcalidrawProps["renderTopLeftUI"];
renderTopRightUI?: ExcalidrawProps["renderTopRightUI"]; renderTopRightUI?: ExcalidrawProps["renderTopRightUI"];
renderCustomStats?: ExcalidrawProps["renderCustomStats"]; renderCustomStats?: ExcalidrawProps["renderCustomStats"];
UIOptions: AppProps["UIOptions"]; UIOptions: AppProps["UIOptions"];
@@ -149,6 +150,7 @@ const LayerUI = ({
onHandToolToggle, onHandToolToggle,
onPenModeToggle, onPenModeToggle,
showExitZenModeBtn, showExitZenModeBtn,
renderTopLeftUI,
renderTopRightUI, renderTopRightUI,
renderCustomStats, renderCustomStats,
UIOptions, UIOptions,
@@ -584,6 +586,7 @@ const LayerUI = ({
setAppState={setAppState} setAppState={setAppState}
onHandToolToggle={onHandToolToggle} onHandToolToggle={onHandToolToggle}
onPenModeToggle={onPenModeToggle} onPenModeToggle={onPenModeToggle}
renderTopLeftUI={renderTopLeftUI}
renderTopRightUI={renderTopRightUI} renderTopRightUI={renderTopRightUI}
renderSidebars={renderSidebars} renderSidebars={renderSidebars}
renderWelcomeScreen={renderWelcomeScreen} renderWelcomeScreen={renderWelcomeScreen}

View File

@@ -36,6 +36,10 @@ type MobileMenuProps = {
isMobile: boolean, isMobile: boolean,
appState: UIAppState, appState: UIAppState,
) => JSX.Element | null; ) => JSX.Element | null;
renderTopLeftUI?: (
isMobile: boolean,
appState: UIAppState,
) => JSX.Element | null;
renderSidebars: () => JSX.Element | null; renderSidebars: () => JSX.Element | null;
renderWelcomeScreen: boolean; renderWelcomeScreen: boolean;
UIOptions: AppProps["UIOptions"]; UIOptions: AppProps["UIOptions"];
@@ -48,7 +52,7 @@ export const MobileMenu = ({
actionManager, actionManager,
setAppState, setAppState,
onHandToolToggle, onHandToolToggle,
renderTopLeftUI,
renderTopRightUI, renderTopRightUI,
renderSidebars, renderSidebars,
renderWelcomeScreen, renderWelcomeScreen,
@@ -61,19 +65,20 @@ export const MobileMenu = ({
DefaultSidebarTriggerTunnel, DefaultSidebarTriggerTunnel,
} = useTunnels(); } = useTunnels();
const renderAppTopBar = () => { const renderAppTopBar = () => {
const topRightUI = renderTopRightUI?.(true, appState) ?? (
<DefaultSidebarTriggerTunnel.Out />
);
const topLeftUI = renderTopLeftUI?.(true, appState) ?? (
<MainMenuTunnel.Out />
);
if ( if (
appState.viewModeEnabled || appState.viewModeEnabled ||
appState.openDialog?.name === "elementLinkSelector" appState.openDialog?.name === "elementLinkSelector"
) { ) {
return ( return <div className="App-toolbar-content">{topLeftUI}</div>;
<div className="App-toolbar-content">
<MainMenuTunnel.Out />
</div>
);
} }
const topRightUI = renderTopRightUI?.(true, appState);
return ( return (
<div <div
className="App-toolbar-content" className="App-toolbar-content"
@@ -83,8 +88,8 @@ export const MobileMenu = ({
justifyContent: "space-between", justifyContent: "space-between",
}} }}
> >
<MainMenuTunnel.Out /> {topLeftUI}
{topRightUI ? topRightUI : <DefaultSidebarTriggerTunnel.Out />} {topRightUI}
</div> </div>
); );
}; };

View File

@@ -571,6 +571,10 @@ export interface ExcalidrawProps {
/** excludes the duplicated elements */ /** excludes the duplicated elements */
prevElements: readonly ExcalidrawElement[], prevElements: readonly ExcalidrawElement[],
) => ExcalidrawElement[] | void; ) => ExcalidrawElement[] | void;
renderTopLeftUI?: (
isMobile: boolean,
appState: UIAppState,
) => JSX.Element | null;
renderTopRightUI?: ( renderTopRightUI?: (
isMobile: boolean, isMobile: boolean,
appState: UIAppState, appState: UIAppState,