render according to default selection tool

This commit is contained in:
Ryan Di
2025-07-23 17:00:38 +10:00
parent 19d434c366
commit d29c8e7d32

View File

@ -63,6 +63,7 @@ import {
laserPointerToolIcon, laserPointerToolIcon,
MagicIcon, MagicIcon,
LassoIcon, LassoIcon,
LassoIconMobile,
} from "./icons"; } from "./icons";
import type { AppClassProperties, AppProps, UIAppState, Zoom } from "../types"; import type { AppClassProperties, AppProps, UIAppState, Zoom } from "../types";
@ -295,15 +296,31 @@ export const ShapesSwitcher = ({
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"; const lassoToolSelected =
activeTool.type === "lasso" && app.defaultSelectionTool !== "lasso";
const embeddableToolSelected = activeTool.type === "embeddable"; const embeddableToolSelected = activeTool.type === "embeddable";
const { TTDDialogTriggerTunnel } = useTunnels(); const { TTDDialogTriggerTunnel } = useTunnels();
// we'll need to update SHAPES to swap lasso and selection
const _SHAPES =
app.defaultSelectionTool === "lasso"
? ([
{
value: "lasso",
icon: LassoIconMobile,
key: KEYS.L,
numericKey: KEYS["1"],
fillable: true,
},
...SHAPES.slice(1),
] as const)
: SHAPES;
return ( return (
<> <>
{SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => { {_SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => {
if ( if (
UIOptions.tools?.[ UIOptions.tools?.[
value as Extract<typeof value, keyof AppProps["UIOptions"]["tools"]> value as Extract<typeof value, keyof AppProps["UIOptions"]["tools"]>
@ -418,14 +435,16 @@ export const ShapesSwitcher = ({
> >
{t("toolBar.laser")} {t("toolBar.laser")}
</DropdownMenu.Item> </DropdownMenu.Item>
<DropdownMenu.Item {app.defaultSelectionTool !== "lasso" && (
onSelect={() => app.setActiveTool({ type: "lasso" })} <DropdownMenu.Item
icon={LassoIcon} onSelect={() => app.setActiveTool({ type: "lasso" })}
data-testid="toolbar-lasso" icon={LassoIcon}
selected={lassoToolSelected} data-testid="toolbar-lasso"
> selected={lassoToolSelected}
{t("toolBar.lasso")} >
</DropdownMenu.Item> {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>