- {renderTopLeftUI?.(true, appState)}
+
+
+ {renderTopLeftUI?.(true, appState)}
+
+
);
diff --git a/packages/excalidraw/components/Stats/Stats.scss b/packages/excalidraw/components/Stats/Stats.scss
index 384e0fd3c5..03fff62339 100644
--- a/packages/excalidraw/components/Stats/Stats.scss
+++ b/packages/excalidraw/components/Stats/Stats.scss
@@ -1,14 +1,18 @@
.exc-stats {
width: 204px;
- position: absolute;
- top: 60px;
font-size: 12px;
z-index: var(--zIndex-layerUI);
pointer-events: var(--ui-pointerEvents);
- :root[dir="rtl"] & {
- left: 12px;
- right: initial;
+ // bounded by its region (down to the footer band), scrolling past it
+ display: flex;
+ flex-direction: column;
+ max-height: 100%;
+ min-height: 0;
+
+ & > .Island {
+ min-height: 0;
+ overflow-y: auto;
}
h2 {
diff --git a/packages/excalidraw/components/Toast.scss b/packages/excalidraw/components/Toast.scss
index 5584a52b66..60e3832e9b 100644
--- a/packages/excalidraw/components/Toast.scss
+++ b/packages/excalidraw/components/Toast.scss
@@ -4,6 +4,8 @@
$closeButtonPadding: 0.4rem;
animation: Toast-fade-in 0.5s;
+ // containing block for the close button
+ position: relative;
min-width: 220px;
max-width: min(360px, calc(100vw - 32px));
border-radius: var(--border-radius-lg);
diff --git a/packages/excalidraw/components/Toolbar.scss b/packages/excalidraw/components/Toolbar.scss
index 1f31724bc2..87a8058302 100644
--- a/packages/excalidraw/components/Toolbar.scss
+++ b/packages/excalidraw/components/Toolbar.scss
@@ -50,6 +50,8 @@
margin-top: 0.375rem;
right: 0;
min-width: 11.875rem;
- z-index: 1;
+ // above the region panels it can drop over (stats, styles panel) — the
+ // popper wrapper copies this z-index
+ z-index: var(--zIndex-ui-top);
}
}
diff --git a/packages/excalidraw/components/Toolbar.tsx b/packages/excalidraw/components/Toolbar.tsx
index 42ff3a6439..042d5cc6b5 100644
--- a/packages/excalidraw/components/Toolbar.tsx
+++ b/packages/excalidraw/components/Toolbar.tsx
@@ -3,7 +3,9 @@ import { useState } from "react";
import { KEYS } from "@excalidraw/common";
+import { trackEvent } from "../analytics";
import { useTunnels } from "../context/tunnels";
+import { TOOLBAR_FOLD_ORDER } from "../hooks/useToolbarFolding";
import { t } from "../i18n";
import { useEditorInterface, useStylesPanelMode } from "./App.context";
@@ -32,6 +34,7 @@ import {
EraserToolButton,
FreedrawToolPopover,
FreedrawToolButton,
+ getToolLetter,
getToolShortcut,
HandToolButton,
LassoToolButton,
@@ -41,9 +44,12 @@ import {
SelectionToolPopover,
StickyNoteToolButton,
TextToolButton,
+ TOOLS,
} from "./Tools";
import { isToolButtonDisabled } from "./toolButtons";
+import type { FoldableToolType } from "../hooks/useToolbarFolding";
+
import type {
AppClassProperties,
AppProps,
@@ -56,11 +62,14 @@ const ExtraToolsDropdown = ({
activeTool,
setAppState,
UIOptions,
+ foldedTools,
}: {
app: AppClassProperties;
activeTool: UIAppState["activeTool"];
setAppState: React.Component
["setState"];
UIOptions: AppProps["UIOptions"];
+ /** toolbar tools that didn't fit the toolbar, in toolbar order */
+ foldedTools: readonly FoldableToolType[];
}) => {
const [isExtraToolsMenuOpen, setIsExtraToolsMenuOpen] = useState(false);
const isFullStylesPanel = useStylesPanelMode() === "full";
@@ -76,12 +85,16 @@ const ExtraToolsDropdown = ({
activeTool.type === "lasso" &&
app.state.preferredSelectionTool.type !== "lasso";
const embeddableToolSelected = activeTool.type === "embeddable";
+ const foldedToolSelected = foldedTools.find(
+ (type) => activeTool.type === type,
+ );
return (
- {imageToolSelected
+ {foldedToolSelected
+ ? TOOLS[foldedToolSelected].icon
+ : imageToolSelected
? ImageIcon
: frameToolSelected
? frameToolIcon
@@ -120,6 +135,25 @@ const ExtraToolsDropdown = ({
onSelect={() => setIsExtraToolsMenuOpen(false)}
className="App-toolbar__extra-tools-dropdown"
>
+ {foldedTools.map((type) => (
+ {
+ if (app.state.activeTool.type !== type) {
+ trackEvent("toolbar", type, "ui");
+ app.setActiveTool({ type });
+ }
+ }}
+ icon={<>{TOOLS[type].icon}>}
+ shortcut={getToolLetter(type) || TOOLS[type].numericKey}
+ data-testid={`toolbar-${type}`}
+ selected={activeTool.type === type}
+ disabled={isToolButtonDisabled(app, type)}
+ >
+ {t(`toolBar.${type}`)}
+
+ ))}
+ {foldedTools.length > 0 && }
{UIOptions.tools?.image !== false && (
app.setActiveTool({ type: "image" })}
@@ -228,6 +262,7 @@ export const Toolbar = ({
onPenModeToggle,
onLockToggle,
heading,
+ foldedCount = 0,
}: {
app: AppClassProperties;
appState: UIAppState;
@@ -236,6 +271,11 @@ export const Toolbar = ({
onPenModeToggle: AppClassProperties["togglePenMode"];
onLockToggle: () => void;
heading: React.ReactNode;
+ /**
+ * how many tools (in `TOOLBAR_FOLD_ORDER`) didn't fit the toolbar's column
+ * and render in the extra-tools dropdown instead (see `useToolbarFolding`)
+ */
+ foldedCount?: number;
}) => {
const editorInterface = useEditorInterface();
const isCompactStylesPanel = useStylesPanelMode() === "compact";
@@ -243,6 +283,15 @@ export const Toolbar = ({
const activeTool = appState.activeTool;
const toolProps = { app, activeTool };
+ const folded = new Set(
+ TOOLBAR_FOLD_ORDER.slice(0, foldedCount),
+ );
+ // in toolbar order
+ const foldedTools = [...TOOLBAR_FOLD_ORDER]
+ .reverse()
+ .filter((type) => folded.has(type));
+ const shows = (type: FoldableToolType) => !folded.has(type);
+
return (
)}
-
-
-
-
-
- {isCompactStylesPanel ? (
-
- ) : (
-
- )}
-
-
-
+ {shows("rectangle") && }
+ {shows("diamond") && }
+ {shows("ellipse") && }
+ {shows("arrow") && }
+ {shows("line") && }
+ {shows("freedraw") &&
+ (isCompactStylesPanel ? (
+
+ ) : (
+
+ ))}
+ {shows("text") && }
+ {shows("stickynote") && }
+ {shows("eraser") && }
diff --git a/packages/excalidraw/components/UserList.scss b/packages/excalidraw/components/UserList.scss
index 6662d2945d..43bdb85652 100644
--- a/packages/excalidraw/components/UserList.scss
+++ b/packages/excalidraw/components/UserList.scss
@@ -20,6 +20,10 @@
.UserList__wrapper {
display: flex;
width: 100%;
+ // as tall as the buttons it shares a row with — the list's padding makes
+ // it taller than them on smaller screens (it overflows, centered), and
+ // the row would grow, nudging the buttons, when the list appears
+ height: var(--lg-button-size);
justify-content: flex-end;
align-items: center;
pointer-events: none !important;
diff --git a/packages/excalidraw/components/UserList.tsx b/packages/excalidraw/components/UserList.tsx
index 0042a08dcd..94f8b74e42 100644
--- a/packages/excalidraw/components/UserList.tsx
+++ b/packages/excalidraw/components/UserList.tsx
@@ -1,6 +1,7 @@
import { Popover } from "radix-ui";
import clsx from "clsx";
import React, { useLayoutEffect } from "react";
+import { flushSync } from "react-dom";
import { isShallowEqual } from "@excalidraw/common";
@@ -35,6 +36,23 @@ const AVATAR_SLOT_WIDTH = 38;
// from ever being the item that tips the row over and wraps onto its own
// line (chevron 15px + pill's right padding 4px + pill's border 2px)
const PILL_EXTRA_WIDTH = 21;
+// a single avatar (28px) + the list's padding (2 × 4px)
+const SINGLE_AVATAR_WIDTH = 36;
+
+/**
+ * The narrowest the list renders at: a single avatar — the current user's
+ * pill, if they're in the list (it's always shown).
+ */
+export const getUserListMinWidth = (
+ collaborators: ReadonlyMap,
+) => {
+ for (const collaborator of collaborators.values()) {
+ if (collaborator.isCurrentUser && collaborator.username?.trim()) {
+ return SINGLE_AVATAR_WIDTH + PILL_EXTRA_WIDTH;
+ }
+ }
+ return SINGLE_AVATAR_WIDTH;
+};
const ConditionalTooltipWrapper = ({
shouldWrap,
@@ -166,10 +184,15 @@ export const UserList = React.memo(
}
const resizeObserver = new ownerWindow.ResizeObserver((entries) => {
- for (const entry of entries) {
- const { width } = entry.contentRect;
- updateWrapperWidth(width);
- }
+ // rendered right away (the observer runs before the frame is
+ // painted) — otherwise the list is painted with the avatars that
+ // fit its previous width, for a frame
+ flushSync(() => {
+ for (const entry of entries) {
+ const { width } = entry.contentRect;
+ updateWrapperWidth(width);
+ }
+ });
});
resizeObserver.observe(userListWrapper.current);
diff --git a/packages/excalidraw/components/footer/Footer.tsx b/packages/excalidraw/components/footer/Footer.tsx
deleted file mode 100644
index 428ff87aad..0000000000
--- a/packages/excalidraw/components/footer/Footer.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import clsx from "clsx";
-
-import { actionShortcuts } from "../../actions";
-import { useTunnels } from "../../context/tunnels";
-import { ExitZenModeButton, UndoRedoActions, ZoomActions } from "../Actions";
-import { useApp } from "../App.context";
-import { HelpButton } from "../HelpButton";
-import { Minimap } from "../Minimap/Minimap";
-import { Section } from "../Section";
-import Stack from "../Stack";
-
-import type { ActionManager } from "../../actions/manager";
-import type { UIAppState } from "../../types";
-
-const Footer = ({
- appState,
- actionManager,
- showExitZenModeBtn,
- renderWelcomeScreen,
- defaultUIEnabled,
- zoomUIEnabled,
- minimapUIEnabled,
-}: {
- appState: UIAppState;
- actionManager: ActionManager;
- showExitZenModeBtn: boolean;
- renderWelcomeScreen: boolean;
- defaultUIEnabled: boolean;
- zoomUIEnabled: boolean;
- /** whether the minimap (when toggled on) and its toggle are rendered */
- minimapUIEnabled: boolean;
-}) => {
- const { FooterCenterTunnel, WelcomeScreenHelpHintTunnel } = useTunnels();
- const app = useApp();
-
- return (
-
- );
-};
-
-export default Footer;
-Footer.displayName = "Footer";
diff --git a/packages/excalidraw/components/footer/FooterCenter.scss b/packages/excalidraw/components/footer/FooterCenter.scss
index 7fd17a5edc..a784adef56 100644
--- a/packages/excalidraw/components/footer/FooterCenter.scss
+++ b/packages/excalidraw/components/footer/FooterCenter.scss
@@ -1,8 +1,12 @@
+// Host-supplied footer content owns the flexible space between the editor's
+// left and right footer controls. Hosts can position their content at either
+// edge (or both) with flex alignment and auto margins.
.footer-center {
pointer-events: none;
display: flex;
width: 100%;
+ align-items: center;
justify-content: flex-start;
margin-inline-end: 0.6rem;
diff --git a/packages/excalidraw/components/footer/FooterCenter.tsx b/packages/excalidraw/components/footer/FooterCenter.tsx
index 6a44581de3..79182025bf 100644
--- a/packages/excalidraw/components/footer/FooterCenter.tsx
+++ b/packages/excalidraw/components/footer/FooterCenter.tsx
@@ -12,8 +12,7 @@ const FooterCenter = ({ children }: { children?: React.ReactNode }) => {
{children}
diff --git a/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.tsx b/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.tsx
index 3a611be04b..879475cb60 100644
--- a/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.tsx
+++ b/packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.tsx
@@ -13,17 +13,25 @@ const LiveCollaborationTrigger = ({
isCollaborating,
onSelect,
editorInterface,
+ iconOnly,
...rest
}: {
isCollaborating: boolean;
onSelect: () => void;
editorInterface?: EditorInterface;
+ /**
+ * force the icon-only (`true`) or labeled (`false`) variant, e.g. from a
+ * `
`; by default it's derived from the
+ * form factor and editor width
+ */
+ iconOnly?: boolean;
} & React.ButtonHTMLAttributes) => {
const appState = useUIAppState();
const showIconOnly =
- editorInterface?.formFactor !== "desktop" ||
- appState.width < MQ_MIN_WIDTH_DESKTOP;
+ iconOnly ??
+ (editorInterface?.formFactor !== "desktop" ||
+ appState.width < MQ_MIN_WIDTH_DESKTOP);
return (