mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-17 19:24:30 +01:00
add a dedicated mobile toolbar
This commit is contained in:
@@ -8,22 +8,18 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
max-width: 400px;
|
|
||||||
border-radius: var(--space-factor);
|
border-radius: var(--space-factor);
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
-ms-overflow-style: none;
|
-ms-overflow-style: none;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
@media screen and (min-width: 350px) {
|
@media screen and (min-width: 340px) {
|
||||||
gap: 8px;
|
gap: 6px;
|
||||||
padding: 4px 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a media query to increase the gaps on larger mobile devices
|
@media screen and (min-width: 380px) {
|
||||||
@media screen and (min-width: 400px) {
|
gap: 8px;
|
||||||
gap: 12px;
|
|
||||||
padding: 4px 8px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +28,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mobile-toolbar .ToolIcon {
|
.mobile-toolbar .ToolIcon {
|
||||||
min-width: 32px;
|
min-width: 2rem;
|
||||||
min-height: 32px;
|
min-height: 2rem;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -41,19 +37,19 @@
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
||||||
.ToolIcon__icon {
|
.ToolIcon__icon {
|
||||||
width: 32px;
|
width: 2rem;
|
||||||
height: 32px;
|
height: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
width: 16px;
|
width: 1rem;
|
||||||
height: 16px;
|
height: 1rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reuse existing dropdown styles */
|
|
||||||
.mobile-toolbar .App-toolbar__extra-tools-dropdown {
|
.mobile-toolbar .App-toolbar__extra-tools-dropdown {
|
||||||
min-width: 160px;
|
min-width: 160px;
|
||||||
|
z-index: var(--zIndex-layerUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile-toolbar-separator {
|
.mobile-toolbar-separator {
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
|
||||||
import { KEYS, capitalizeString } from "@excalidraw/common";
|
import { KEYS, capitalizeString } from "@excalidraw/common";
|
||||||
|
|
||||||
import { HandButton } from "./HandButton";
|
import { HandButton } from "./HandButton";
|
||||||
import { ToolButton } from "./ToolButton";
|
import { ToolButton } from "./ToolButton";
|
||||||
import { ShapesSwitcher } from "./Actions";
|
|
||||||
import DropdownMenu from "./dropdownMenu/DropdownMenu";
|
import DropdownMenu from "./dropdownMenu/DropdownMenu";
|
||||||
import { ShapeTypePopup } from "./ShapeTypePopup";
|
import { ToolWithPopup } from "./ToolWithPopup";
|
||||||
import { SelectionTypePopup } from "./SelectionTypePopup";
|
|
||||||
import { LinearElementTypePopup } from "./LinearElementTypePopup";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SelectionIcon,
|
SelectionIcon,
|
||||||
@@ -36,26 +33,61 @@ import { t } from "../i18n";
|
|||||||
import { isHandToolActive } from "../appState";
|
import { isHandToolActive } from "../appState";
|
||||||
import { useTunnels } from "../context/tunnels";
|
import { useTunnels } from "../context/tunnels";
|
||||||
|
|
||||||
import type { ActionManager } from "../actions/manager";
|
import type { AppClassProperties, UIAppState } from "../types";
|
||||||
import type { AppClassProperties, AppProps, UIAppState } from "../types";
|
|
||||||
|
|
||||||
import "./ToolIcon.scss";
|
import "./ToolIcon.scss";
|
||||||
import "./MobileToolBar.scss";
|
import "./MobileToolBar.scss";
|
||||||
|
|
||||||
|
const SHAPE_TOOLS = [
|
||||||
|
{
|
||||||
|
type: "rectangle",
|
||||||
|
icon: RectangleIcon,
|
||||||
|
title: capitalizeString(t("toolBar.rectangle")),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "diamond",
|
||||||
|
icon: DiamondIcon,
|
||||||
|
title: capitalizeString(t("toolBar.diamond")),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "ellipse",
|
||||||
|
icon: EllipseIcon,
|
||||||
|
title: capitalizeString(t("toolBar.ellipse")),
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const SELECTION_TOOLS = [
|
||||||
|
{
|
||||||
|
type: "selection",
|
||||||
|
icon: SelectionIcon,
|
||||||
|
title: capitalizeString(t("toolBar.selection")),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "lasso",
|
||||||
|
icon: LassoIcon,
|
||||||
|
title: capitalizeString(t("toolBar.lasso")),
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const LINEAR_ELEMENT_TOOLS = [
|
||||||
|
{
|
||||||
|
type: "arrow",
|
||||||
|
icon: ArrowIcon,
|
||||||
|
title: capitalizeString(t("toolBar.arrow")),
|
||||||
|
},
|
||||||
|
{ type: "line", icon: LineIcon, title: capitalizeString(t("toolBar.line")) },
|
||||||
|
] as const;
|
||||||
|
|
||||||
type MobileToolBarProps = {
|
type MobileToolBarProps = {
|
||||||
appState: UIAppState;
|
appState: UIAppState;
|
||||||
app: AppClassProperties;
|
app: AppClassProperties;
|
||||||
actionManager: ActionManager;
|
|
||||||
onHandToolToggle: () => void;
|
onHandToolToggle: () => void;
|
||||||
UIOptions: AppProps["UIOptions"];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MobileToolBar = ({
|
export const MobileToolBar = ({
|
||||||
appState,
|
appState,
|
||||||
app,
|
app,
|
||||||
actionManager,
|
|
||||||
onHandToolToggle,
|
onHandToolToggle,
|
||||||
UIOptions,
|
|
||||||
}: MobileToolBarProps) => {
|
}: MobileToolBarProps) => {
|
||||||
const activeTool = appState.activeTool;
|
const activeTool = appState.activeTool;
|
||||||
const [isOtherShapesMenuOpen, setIsOtherShapesMenuOpen] = useState(false);
|
const [isOtherShapesMenuOpen, setIsOtherShapesMenuOpen] = useState(false);
|
||||||
@@ -65,17 +97,6 @@ export const MobileToolBar = ({
|
|||||||
const [lastActiveLinearElement, setLastActiveLinearElement] = useState<
|
const [lastActiveLinearElement, setLastActiveLinearElement] = useState<
|
||||||
"arrow" | "line"
|
"arrow" | "line"
|
||||||
>("arrow");
|
>("arrow");
|
||||||
const [isShapeTypePopupOpen, setIsShapeTypePopupOpen] = useState(false);
|
|
||||||
const [rectangleTriggerRef, setRectangleTriggerRef] =
|
|
||||||
useState<HTMLElement | null>(null);
|
|
||||||
const [isLinearElementTypePopupOpen, setIsLinearElementTypePopupOpen] =
|
|
||||||
useState(false);
|
|
||||||
const [linearElementTriggerRef, setLinearElementTriggerRef] =
|
|
||||||
useState<HTMLElement | null>(null);
|
|
||||||
const [isSelectionTypePopupOpen, setIsSelectionTypePopupOpen] =
|
|
||||||
useState(false);
|
|
||||||
const [selectionTriggerRef, setSelectionTriggerRef] =
|
|
||||||
useState<HTMLElement | null>(null);
|
|
||||||
|
|
||||||
// keep lastActiveGenericShape in sync with active tool if user switches via other UI
|
// keep lastActiveGenericShape in sync with active tool if user switches via other UI
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -97,8 +118,6 @@ export const MobileToolBar = ({
|
|||||||
|
|
||||||
const frameToolSelected = activeTool.type === "frame";
|
const frameToolSelected = activeTool.type === "frame";
|
||||||
const laserToolSelected = activeTool.type === "laser";
|
const laserToolSelected = activeTool.type === "laser";
|
||||||
const lassoToolSelected =
|
|
||||||
activeTool.type === "lasso" && app.defaultSelectionTool !== "lasso";
|
|
||||||
const embeddableToolSelected = activeTool.type === "embeddable";
|
const embeddableToolSelected = activeTool.type === "embeddable";
|
||||||
|
|
||||||
const { TTDDialogTriggerTunnel } = useTunnels();
|
const { TTDDialogTriggerTunnel } = useTunnels();
|
||||||
@@ -119,6 +138,39 @@ export const MobileToolBar = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showTextToolOutside = appState.width >= 400;
|
||||||
|
const showFrameToolOutside = appState.width >= 440;
|
||||||
|
|
||||||
|
const extraTools = [
|
||||||
|
"text",
|
||||||
|
"frame",
|
||||||
|
"embeddable",
|
||||||
|
"laser",
|
||||||
|
"magicframe",
|
||||||
|
].filter((tool) => {
|
||||||
|
if (showTextToolOutside && tool === "text") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (showFrameToolOutside && tool === "frame") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
const extraToolSelected = extraTools.includes(appState.activeTool.type);
|
||||||
|
const extraIcon = extraToolSelected
|
||||||
|
? appState.activeTool.type === "frame"
|
||||||
|
? frameToolIcon
|
||||||
|
: appState.activeTool.type === "embeddable"
|
||||||
|
? EmbedIcon
|
||||||
|
: appState.activeTool.type === "laser"
|
||||||
|
? laserPointerToolIcon
|
||||||
|
: appState.activeTool.type === "text"
|
||||||
|
? TextIcon
|
||||||
|
: appState.activeTool.type === "magicframe"
|
||||||
|
? MagicIcon
|
||||||
|
: extraToolsIcon
|
||||||
|
: extraToolsIcon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mobile-toolbar">
|
<div className="mobile-toolbar">
|
||||||
{/* Hand Tool */}
|
{/* Hand Tool */}
|
||||||
@@ -130,41 +182,26 @@ export const MobileToolBar = ({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Selection Tool */}
|
{/* Selection Tool */}
|
||||||
<div style={{ position: "relative" }}>
|
<ToolWithPopup
|
||||||
<div ref={setSelectionTriggerRef}>
|
app={app}
|
||||||
<ToolButton
|
options={SELECTION_TOOLS}
|
||||||
className={clsx("Shape", { fillable: false })}
|
activeTool={activeTool}
|
||||||
type="radio"
|
defaultOption={app.defaultSelectionTool}
|
||||||
icon={
|
className="Selection"
|
||||||
app.defaultSelectionTool === "selection"
|
namePrefix="selectionType"
|
||||||
? SelectionIcon
|
title={capitalizeString(t("toolBar.selection"))}
|
||||||
: LassoIcon
|
data-testid="toolbar-selection"
|
||||||
}
|
onToolChange={(type: string) => {
|
||||||
checked={
|
app.setActiveTool({ type: type as any });
|
||||||
activeTool.type === "lasso" || activeTool.type === "selection"
|
app.defaultSelectionTool = type as any;
|
||||||
}
|
}}
|
||||||
name="editor-current-shape"
|
getDisplayedOption={() =>
|
||||||
title={`${capitalizeString(t("toolBar.selection"))}`}
|
SELECTION_TOOLS.find(
|
||||||
aria-label={capitalizeString(t("toolBar.selection"))}
|
(tool) => tool.type === app.defaultSelectionTool,
|
||||||
data-testid="toolbar-selection"
|
) || SELECTION_TOOLS[0]
|
||||||
onPointerDown={() => {
|
}
|
||||||
setIsSelectionTypePopupOpen((val) => !val);
|
isActive={(type: string) => type === "lasso" || type === "selection"}
|
||||||
app.setActiveTool({ type: app.defaultSelectionTool });
|
/>
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<SelectionTypePopup
|
|
||||||
app={app}
|
|
||||||
triggerElement={selectionTriggerRef}
|
|
||||||
isOpen={isSelectionTypePopupOpen}
|
|
||||||
onClose={() => setIsSelectionTypePopupOpen(false)}
|
|
||||||
onChange={(type) => {
|
|
||||||
app.setActiveTool({ type });
|
|
||||||
app.defaultSelectionTool = type;
|
|
||||||
}}
|
|
||||||
currentType={activeTool.type === "lasso" ? "lasso" : "selection"}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Free Draw */}
|
{/* Free Draw */}
|
||||||
<ToolButton
|
<ToolButton
|
||||||
@@ -193,177 +230,148 @@ export const MobileToolBar = ({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Rectangle */}
|
{/* Rectangle */}
|
||||||
<div
|
<ToolWithPopup
|
||||||
style={{ position: "relative" }}
|
app={app}
|
||||||
ref={(el) => setRectangleTriggerRef(el as HTMLElement | null)}
|
options={SHAPE_TOOLS}
|
||||||
>
|
activeTool={activeTool}
|
||||||
|
defaultOption={lastActiveGenericShape}
|
||||||
|
className="Shape"
|
||||||
|
namePrefix="shapeType"
|
||||||
|
title={capitalizeString(
|
||||||
|
t(
|
||||||
|
lastActiveGenericShape === "rectangle"
|
||||||
|
? "toolBar.rectangle"
|
||||||
|
: lastActiveGenericShape === "diamond"
|
||||||
|
? "toolBar.diamond"
|
||||||
|
: lastActiveGenericShape === "ellipse"
|
||||||
|
? "toolBar.ellipse"
|
||||||
|
: "toolBar.rectangle",
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
data-testid="toolbar-rectangle"
|
||||||
|
onToolChange={(type: string) => {
|
||||||
|
setLastActiveGenericShape(type as any);
|
||||||
|
app.setActiveTool({ type: type as any });
|
||||||
|
}}
|
||||||
|
getDisplayedOption={() =>
|
||||||
|
SHAPE_TOOLS.find((tool) => tool.type === lastActiveGenericShape) ||
|
||||||
|
SHAPE_TOOLS[0]
|
||||||
|
}
|
||||||
|
isActive={(type: string) =>
|
||||||
|
["rectangle", "diamond", "ellipse"].includes(type)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Arrow/Line */}
|
||||||
|
<ToolWithPopup
|
||||||
|
app={app}
|
||||||
|
options={LINEAR_ELEMENT_TOOLS}
|
||||||
|
activeTool={activeTool}
|
||||||
|
defaultOption={lastActiveLinearElement}
|
||||||
|
className="LinearElement"
|
||||||
|
namePrefix="linearElementType"
|
||||||
|
title={capitalizeString(
|
||||||
|
t(
|
||||||
|
lastActiveLinearElement === "arrow"
|
||||||
|
? "toolBar.arrow"
|
||||||
|
: "toolBar.line",
|
||||||
|
),
|
||||||
|
)}
|
||||||
|
data-testid="toolbar-arrow"
|
||||||
|
fillable={true}
|
||||||
|
onToolChange={(type: string) => {
|
||||||
|
setLastActiveLinearElement(type as any);
|
||||||
|
app.setActiveTool({ type: type as any });
|
||||||
|
}}
|
||||||
|
getDisplayedOption={() =>
|
||||||
|
LINEAR_ELEMENT_TOOLS.find(
|
||||||
|
(tool) => tool.type === lastActiveLinearElement,
|
||||||
|
) || LINEAR_ELEMENT_TOOLS[0]
|
||||||
|
}
|
||||||
|
isActive={(type: string) => ["arrow", "line"].includes(type)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Image */}
|
||||||
|
<ToolButton
|
||||||
|
className={clsx("Shape", { fillable: false })}
|
||||||
|
type="radio"
|
||||||
|
icon={ImageIcon}
|
||||||
|
checked={activeTool.type === "image"}
|
||||||
|
name="editor-current-shape"
|
||||||
|
title={`${capitalizeString(t("toolBar.image"))}`}
|
||||||
|
aria-label={capitalizeString(t("toolBar.image"))}
|
||||||
|
data-testid="toolbar-image"
|
||||||
|
onChange={() => handleToolChange("image")}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Text Tool */}
|
||||||
|
{showTextToolOutside && (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
className={clsx("Shape", { fillable: false })}
|
className={clsx("Shape", { fillable: false })}
|
||||||
type="radio"
|
type="radio"
|
||||||
icon={
|
icon={TextIcon}
|
||||||
lastActiveGenericShape === "rectangle"
|
checked={activeTool.type === "text"}
|
||||||
? RectangleIcon
|
|
||||||
: lastActiveGenericShape === "diamond"
|
|
||||||
? DiamondIcon
|
|
||||||
: lastActiveGenericShape === "ellipse"
|
|
||||||
? EllipseIcon
|
|
||||||
: RectangleIcon
|
|
||||||
}
|
|
||||||
checked={["rectangle", "diamond", "ellipse"].includes(
|
|
||||||
activeTool.type,
|
|
||||||
)}
|
|
||||||
name="editor-current-shape"
|
name="editor-current-shape"
|
||||||
title={`${capitalizeString(
|
title={`${capitalizeString(t("toolBar.text"))}`}
|
||||||
t(
|
aria-label={capitalizeString(t("toolBar.text"))}
|
||||||
lastActiveGenericShape === "rectangle"
|
data-testid="toolbar-text"
|
||||||
? "toolBar.rectangle"
|
onChange={() => handleToolChange("text")}
|
||||||
: lastActiveGenericShape === "diamond"
|
|
||||||
? "toolBar.diamond"
|
|
||||||
: lastActiveGenericShape === "ellipse"
|
|
||||||
? "toolBar.ellipse"
|
|
||||||
: "toolBar.rectangle",
|
|
||||||
),
|
|
||||||
)}`}
|
|
||||||
aria-label={capitalizeString(
|
|
||||||
t(
|
|
||||||
lastActiveGenericShape === "rectangle"
|
|
||||||
? "toolBar.rectangle"
|
|
||||||
: lastActiveGenericShape === "diamond"
|
|
||||||
? "toolBar.diamond"
|
|
||||||
: lastActiveGenericShape === "ellipse"
|
|
||||||
? "toolBar.ellipse"
|
|
||||||
: "toolBar.rectangle",
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
data-testid="toolbar-rectangle"
|
|
||||||
onPointerDown={() => {
|
|
||||||
setIsShapeTypePopupOpen((val) => !val);
|
|
||||||
app.setActiveTool({ type: lastActiveGenericShape });
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<ShapeTypePopup
|
{/* Frame Tool */}
|
||||||
app={app}
|
{showFrameToolOutside && (
|
||||||
triggerElement={rectangleTriggerRef}
|
|
||||||
isOpen={isShapeTypePopupOpen}
|
|
||||||
onClose={() => {
|
|
||||||
setIsShapeTypePopupOpen(false);
|
|
||||||
}}
|
|
||||||
onChange={(type) => {
|
|
||||||
setLastActiveGenericShape(type);
|
|
||||||
app.setActiveTool({ type });
|
|
||||||
}}
|
|
||||||
currentType={activeTool.type}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Arrow/Line */}
|
|
||||||
<div
|
|
||||||
style={{ position: "relative" }}
|
|
||||||
ref={(el) => setLinearElementTriggerRef(el as HTMLElement | null)}
|
|
||||||
>
|
|
||||||
<ToolButton
|
<ToolButton
|
||||||
className={clsx("Shape", { fillable: true })}
|
className={clsx("Shape", { fillable: false })}
|
||||||
type="radio"
|
type="radio"
|
||||||
icon={lastActiveLinearElement === "arrow" ? ArrowIcon : LineIcon}
|
icon={frameToolIcon}
|
||||||
checked={["arrow", "line"].includes(activeTool.type)}
|
checked={frameToolSelected}
|
||||||
name="editor-current-shape"
|
name="editor-current-shape"
|
||||||
title={`${capitalizeString(
|
title={`${capitalizeString(t("toolBar.frame"))}`}
|
||||||
t(
|
aria-label={capitalizeString(t("toolBar.frame"))}
|
||||||
lastActiveLinearElement === "arrow"
|
data-testid="toolbar-frame"
|
||||||
? "toolBar.arrow"
|
onChange={() => handleToolChange("frame")}
|
||||||
: "toolBar.line",
|
|
||||||
),
|
|
||||||
)}`}
|
|
||||||
aria-label={capitalizeString(
|
|
||||||
t(
|
|
||||||
lastActiveLinearElement === "arrow"
|
|
||||||
? "toolBar.arrow"
|
|
||||||
: "toolBar.line",
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
data-testid="toolbar-arrow"
|
|
||||||
onPointerDown={() => {
|
|
||||||
setIsLinearElementTypePopupOpen((val) => !val);
|
|
||||||
app.setActiveTool({ type: lastActiveLinearElement });
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<LinearElementTypePopup
|
|
||||||
app={app}
|
|
||||||
triggerElement={linearElementTriggerRef}
|
|
||||||
isOpen={isLinearElementTypePopupOpen}
|
|
||||||
onClose={() => {
|
|
||||||
setIsLinearElementTypePopupOpen(false);
|
|
||||||
}}
|
|
||||||
onChange={(type) => {
|
|
||||||
setLastActiveLinearElement(type);
|
|
||||||
app.setActiveTool({ type });
|
|
||||||
}}
|
|
||||||
currentType={activeTool.type === "line" ? "line" : "arrow"}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Other Shapes */}
|
{/* Other Shapes */}
|
||||||
<DropdownMenu open={isOtherShapesMenuOpen} placement="top">
|
<DropdownMenu open={isOtherShapesMenuOpen} placement="top">
|
||||||
<DropdownMenu.Trigger
|
<DropdownMenu.Trigger
|
||||||
className={clsx("App-toolbar__extra-tools-trigger", {
|
className={clsx("App-toolbar__extra-tools-trigger", {
|
||||||
"App-toolbar__extra-tools-trigger--selected":
|
"App-toolbar__extra-tools-trigger--selected": extraToolSelected,
|
||||||
frameToolSelected ||
|
|
||||||
embeddableToolSelected ||
|
|
||||||
lassoToolSelected ||
|
|
||||||
activeTool.type === "text" ||
|
|
||||||
activeTool.type === "image" ||
|
|
||||||
(laserToolSelected && !app.props.isCollaborating),
|
|
||||||
})}
|
})}
|
||||||
onToggle={() => setIsOtherShapesMenuOpen(!isOtherShapesMenuOpen)}
|
onToggle={() => setIsOtherShapesMenuOpen(!isOtherShapesMenuOpen)}
|
||||||
title={t("toolBar.extraTools")}
|
title={t("toolBar.extraTools")}
|
||||||
>
|
>
|
||||||
{frameToolSelected
|
{extraIcon}
|
||||||
? frameToolIcon
|
|
||||||
: embeddableToolSelected
|
|
||||||
? EmbedIcon
|
|
||||||
: activeTool.type === "text"
|
|
||||||
? TextIcon
|
|
||||||
: activeTool.type === "image"
|
|
||||||
? ImageIcon
|
|
||||||
: laserToolSelected && !app.props.isCollaborating
|
|
||||||
? laserPointerToolIcon
|
|
||||||
: lassoToolSelected
|
|
||||||
? LassoIcon
|
|
||||||
: extraToolsIcon}
|
|
||||||
</DropdownMenu.Trigger>
|
</DropdownMenu.Trigger>
|
||||||
<DropdownMenu.Content
|
<DropdownMenu.Content
|
||||||
onClickOutside={() => setIsOtherShapesMenuOpen(false)}
|
onClickOutside={() => setIsOtherShapesMenuOpen(false)}
|
||||||
onSelect={() => setIsOtherShapesMenuOpen(false)}
|
onSelect={() => setIsOtherShapesMenuOpen(false)}
|
||||||
className="App-toolbar__extra-tools-dropdown"
|
className="App-toolbar__extra-tools-dropdown"
|
||||||
>
|
>
|
||||||
<DropdownMenu.Item
|
{!showTextToolOutside && (
|
||||||
onSelect={() => app.setActiveTool({ type: "text" })}
|
<DropdownMenu.Item
|
||||||
icon={TextIcon}
|
onSelect={() => app.setActiveTool({ type: "text" })}
|
||||||
shortcut={KEYS.T.toLocaleUpperCase()}
|
icon={TextIcon}
|
||||||
data-testid="toolbar-text"
|
shortcut={KEYS.T.toLocaleUpperCase()}
|
||||||
selected={activeTool.type === "text"}
|
data-testid="toolbar-text"
|
||||||
>
|
selected={activeTool.type === "text"}
|
||||||
{t("toolBar.text")}
|
>
|
||||||
</DropdownMenu.Item>
|
{t("toolBar.text")}
|
||||||
<DropdownMenu.Item
|
</DropdownMenu.Item>
|
||||||
onSelect={() => app.setActiveTool({ type: "image" })}
|
)}
|
||||||
icon={ImageIcon}
|
{!showFrameToolOutside && (
|
||||||
data-testid="toolbar-image"
|
<DropdownMenu.Item
|
||||||
selected={activeTool.type === "image"}
|
onSelect={() => app.setActiveTool({ type: "frame" })}
|
||||||
>
|
icon={frameToolIcon}
|
||||||
{t("toolBar.image")}
|
shortcut={KEYS.F.toLocaleUpperCase()}
|
||||||
</DropdownMenu.Item>
|
data-testid="toolbar-frame"
|
||||||
<DropdownMenu.Item
|
selected={frameToolSelected}
|
||||||
onSelect={() => app.setActiveTool({ type: "frame" })}
|
>
|
||||||
icon={frameToolIcon}
|
{t("toolBar.frame")}
|
||||||
shortcut={KEYS.F.toLocaleUpperCase()}
|
</DropdownMenu.Item>
|
||||||
data-testid="toolbar-frame"
|
)}
|
||||||
selected={frameToolSelected}
|
|
||||||
>
|
|
||||||
{t("toolBar.frame")}
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
onSelect={() => app.setActiveTool({ type: "embeddable" })}
|
onSelect={() => app.setActiveTool({ type: "embeddable" })}
|
||||||
icon={EmbedIcon}
|
icon={EmbedIcon}
|
||||||
@@ -381,16 +389,6 @@ export const MobileToolBar = ({
|
|||||||
>
|
>
|
||||||
{t("toolBar.laser")}
|
{t("toolBar.laser")}
|
||||||
</DropdownMenu.Item>
|
</DropdownMenu.Item>
|
||||||
{app.defaultSelectionTool !== "lasso" && (
|
|
||||||
<DropdownMenu.Item
|
|
||||||
onSelect={() => app.setActiveTool({ type: "lasso" })}
|
|
||||||
icon={LassoIcon}
|
|
||||||
data-testid="toolbar-lasso"
|
|
||||||
selected={lassoToolSelected}
|
|
||||||
>
|
|
||||||
{t("toolBar.lasso")}
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
)}
|
|
||||||
<div style={{ margin: "6px 0", fontSize: 14, fontWeight: 600 }}>
|
<div style={{ margin: "6px 0", fontSize: 14, fontWeight: 600 }}>
|
||||||
Generate
|
Generate
|
||||||
</div>
|
</div>
|
||||||
@@ -416,14 +414,6 @@ export const MobileToolBar = ({
|
|||||||
)}
|
)}
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
{/* Separator */}
|
|
||||||
<div className="mobile-toolbar-separator" />
|
|
||||||
|
|
||||||
{/* Undo Button */}
|
|
||||||
<div className="mobile-toolbar-undo">
|
|
||||||
{actionManager.renderAction("undo")}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user