diff --git a/src/components/App.tsx b/src/components/App.tsx index 51b8c302..e0ce0ee9 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -539,8 +539,7 @@ class App extends React.Component { this.scene.getNonDeletedElements(), this.state, ); - const { onCollabButtonClick, renderTopRightUI, renderCustomStats } = - this.props; + const { renderTopRightUI, renderCustomStats } = this.props; return (
{ setAppState={this.setAppState} actionManager={this.actionManager} elements={this.scene.getNonDeletedElements()} - onCollabButtonClick={onCollabButtonClick} onLockToggle={this.toggleLock} onPenModeToggle={this.togglePenMode} onInsertElements={(elements) => diff --git a/src/components/CollabButton.tsx b/src/components/CollabButton.tsx deleted file mode 100644 index 34521383..00000000 --- a/src/components/CollabButton.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { t } from "../i18n"; -import { UsersIcon } from "./icons"; - -import "./CollabButton.scss"; -import clsx from "clsx"; -import { Button } from "./Button"; - -const CollabButton = ({ - isCollaborating, - collaboratorCount, - onClick, -}: { - isCollaborating: boolean; - collaboratorCount: number; - onClick: () => void; -}) => { - return ( - - ); -}; - -export default CollabButton; diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index d75b8b41..8aa8809f 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -18,7 +18,6 @@ import { } from "../types"; import { isShallowEqual, muteFSAbortError, getReactChildren } from "../utils"; import { SelectedShapeActions, ShapesSwitcher } from "./Actions"; -import CollabButton from "./CollabButton"; import { ErrorDialog } from "./ErrorDialog"; import { ExportCB, ImageExportDialog } from "./ImageExportDialog"; import { FixedSideContainer } from "./FixedSideContainer"; @@ -59,7 +58,6 @@ interface LayerUIProps { canvas: HTMLCanvasElement | null; setAppState: React.Component["setState"]; elements: readonly NonDeletedExcalidrawElement[]; - onCollabButtonClick?: () => void; onLockToggle: () => void; onPenModeToggle: () => void; onInsertElements: (elements: readonly NonDeletedExcalidrawElement[]) => void; @@ -86,7 +84,6 @@ const LayerUI = ({ setAppState, elements, canvas, - onCollabButtonClick, onLockToggle, onPenModeToggle, onInsertElements, @@ -207,12 +204,6 @@ const LayerUI = ({ {UIOptions.canvasActions.saveAsImage && ( )} - {onCollabButtonClick && ( - - )} @@ -351,13 +342,6 @@ const LayerUI = ({ )} > - {onCollabButtonClick && ( - - )} {renderTopRightUI?.(device.isMobile, appState)} {!appState.viewModeEnabled && ( diff --git a/src/components/icons.tsx b/src/components/icons.tsx index 55650385..cc43aaa4 100644 --- a/src/components/icons.tsx +++ b/src/components/icons.tsx @@ -883,7 +883,7 @@ export const CenterHorizontallyIcon = createIcon( modifiedTablerIconProps, ); -export const UsersIcon = createIcon( +export const usersIcon = createIcon( diff --git a/src/components/CollabButton.scss b/src/components/live-collaboration/LiveCollaborationTrigger.scss similarity index 97% rename from src/components/CollabButton.scss rename to src/components/live-collaboration/LiveCollaborationTrigger.scss index 94e52d53..138d6459 100644 --- a/src/components/CollabButton.scss +++ b/src/components/live-collaboration/LiveCollaborationTrigger.scss @@ -1,4 +1,4 @@ -@import "../css/variables.module"; +@import "../../css/variables.module"; .excalidraw { .collab-button { diff --git a/src/components/live-collaboration/LiveCollaborationTrigger.tsx b/src/components/live-collaboration/LiveCollaborationTrigger.tsx new file mode 100644 index 00000000..87f696d8 --- /dev/null +++ b/src/components/live-collaboration/LiveCollaborationTrigger.tsx @@ -0,0 +1,40 @@ +import { t } from "../../i18n"; +import { usersIcon } from "../icons"; +import { Button } from "../Button"; + +import clsx from "clsx"; +import { useExcalidrawAppState } from "../App"; + +import "./LiveCollaborationTrigger.scss"; + +const LiveCollaborationTrigger = ({ + isCollaborating, + onSelect, + ...rest +}: { + isCollaborating: boolean; + onSelect: () => void; +} & React.ButtonHTMLAttributes) => { + const appState = useExcalidrawAppState(); + + return ( + + ); +}; + +export default LiveCollaborationTrigger; +LiveCollaborationTrigger.displayName = "LiveCollaborationTrigger"; diff --git a/src/components/main-menu/DefaultItems.tsx b/src/components/main-menu/DefaultItems.tsx index e35108be..6342b31d 100644 --- a/src/components/main-menu/DefaultItems.tsx +++ b/src/components/main-menu/DefaultItems.tsx @@ -1,4 +1,3 @@ -import clsx from "clsx"; import { getShortcutFromShortcutName } from "../../actions/shortcuts"; import { t } from "../../i18n"; import { @@ -15,7 +14,7 @@ import { save, SunIcon, TrashIcon, - UsersIcon, + usersIcon, } from "../icons"; import { GithubIcon, DiscordIcon, TwitterIcon } from "../icons"; import DropdownMenuItem from "../dropdownMenu/DropdownMenuItem"; @@ -31,6 +30,7 @@ import { import "./DefaultItems.scss"; import { useState } from "react"; import ConfirmDialog from "../ConfirmDialog"; +import clsx from "clsx"; export const LoadScene = () => { // FIXME Hack until we tie "t" to lang state @@ -258,7 +258,7 @@ export const Socials = () => ( ); Socials.displayName = "Socials"; -export const LiveCollaboration = ({ +export const LiveCollaborationTrigger = ({ onSelect, isCollaborating, }: { @@ -271,7 +271,7 @@ export const LiveCollaboration = ({ return ( { }; MenuItemLoadScene.displayName = "MenuItemLoadScene"; +const MenuItemLiveCollaborationTrigger = ({ + onSelect, +}: { + onSelect: () => any; +}) => { + // FIXME when we tie t() to lang state + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const appState = useExcalidrawAppState(); + + return ( + + {t("labels.liveCollaboration")} + + ); +}; +MenuItemLiveCollaborationTrigger.displayName = + "MenuItemLiveCollaborationTrigger"; + // ----------------------------------------------------------------------------- Center.Logo = Logo; @@ -172,5 +190,6 @@ Center.MenuItem = WelcomeScreenMenuItem; Center.MenuItemLink = WelcomeScreenMenuItemLink; Center.MenuItemHelp = MenuItemHelp; Center.MenuItemLoadScene = MenuItemLoadScene; +Center.MenuItemLiveCollaborationTrigger = MenuItemLiveCollaborationTrigger; export { Center }; diff --git a/src/excalidraw-app/index.tsx b/src/excalidraw-app/index.tsx index beef0943..8f2d8cbc 100644 --- a/src/excalidraw-app/index.tsx +++ b/src/excalidraw-app/index.tsx @@ -26,6 +26,7 @@ import { defaultLang, Footer, MainMenu, + LiveCollaborationTrigger, WelcomeScreen, } from "../packages/excalidraw/index"; import { @@ -87,7 +88,7 @@ import { parseLibraryTokensFromUrl, useHandleLibrary } from "../data/library"; import { EncryptedIcon } from "./components/EncryptedIcon"; import { ExcalidrawPlusAppLink } from "./components/ExcalidrawPlusAppLink"; import { LanguageList } from "./components/LanguageList"; -import { PlusPromoIcon, UsersIcon } from "../components/icons"; +import { PlusPromoIcon } from "../components/icons"; polyfill(); @@ -610,7 +611,7 @@ const ExcalidrawWrapper = () => { - setCollabDialogShown(true)} /> @@ -675,15 +676,9 @@ const ExcalidrawWrapper = () => { - - setCollabDialogShown(true)} - icon={UsersIcon} - > - {t("labels.liveCollaboration")} - - + /> {!isExcalidrawPlusSignedUser && ( { ref={excalidrawRefCallback} onChange={onChange} initialData={initialStatePromiseRef.current.promise} - onCollabButtonClick={() => setCollabDialogShown(true)} isCollaborating={isCollaborating} onPointerUpdate={collabAPI?.onPointerUpdate} UIOptions={{ @@ -744,8 +738,20 @@ const ExcalidrawWrapper = () => { onLibraryChange={onLibraryChange} autoFocus={true} theme={theme} + renderTopRightUI={(isMobile) => { + if (isMobile) { + return null; + } + return ( + setCollabDialogShown(true)} + /> + ); + }} > {renderMenu()} +