tool bar fixes: icon and width

This commit is contained in:
Ryan Di
2025-11-04 14:16:34 +11:00
parent d53a1f792b
commit 5132bce0a1

View File

@@ -101,8 +101,6 @@ export const MobileToolBar = ({
"arrow" | "line" "arrow" | "line"
>("arrow"); >("arrow");
const toolbarRef = useRef<HTMLDivElement>(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(() => {
if ( if (
@@ -143,8 +141,8 @@ export const MobileToolBar = ({
} }
}; };
const toolbarWidth = const [toolbarWidth, setToolbarWidth] = useState(0);
toolbarRef.current?.getBoundingClientRect()?.width ?? 0 - 8;
const WIDTH = 36; const WIDTH = 36;
const GAP = 4; const GAP = 4;
@@ -164,6 +162,9 @@ export const MobileToolBar = ({
"laser", "laser",
"magicframe", "magicframe",
].filter((tool) => { ].filter((tool) => {
if (showTextToolOutside && tool === "text") {
return false;
}
if (showImageToolOutside && tool === "image") { if (showImageToolOutside && tool === "image") {
return false; return false;
} }
@@ -174,21 +175,30 @@ export const MobileToolBar = ({
}); });
const extraToolSelected = extraTools.includes(activeTool.type); const extraToolSelected = extraTools.includes(activeTool.type);
const extraIcon = extraToolSelected const extraIcon = extraToolSelected
? activeTool.type === "frame" ? activeTool.type === "text"
? TextIcon
: activeTool.type === "image"
? ImageIcon
: activeTool.type === "frame"
? frameToolIcon ? frameToolIcon
: activeTool.type === "embeddable" : activeTool.type === "embeddable"
? EmbedIcon ? EmbedIcon
: activeTool.type === "laser" : activeTool.type === "laser"
? laserPointerToolIcon ? laserPointerToolIcon
: activeTool.type === "text"
? TextIcon
: activeTool.type === "magicframe" : activeTool.type === "magicframe"
? MagicIcon ? MagicIcon
: extraToolsIcon : extraToolsIcon
: extraToolsIcon; : extraToolsIcon;
return ( return (
<div className="mobile-toolbar" ref={toolbarRef}> <div
className="mobile-toolbar"
ref={(div) => {
if (div) {
setToolbarWidth(div.getBoundingClientRect().width);
}
}}
>
{/* Hand Tool */} {/* Hand Tool */}
<HandButton <HandButton
checked={isHandToolActive(app.state)} checked={isHandToolActive(app.state)}