Create all components

This commit is contained in:
hamid zarghami
2025-11-18 14:38:08 +03:30
parent 1a0c869101
commit 8070a3f837
16 changed files with 181 additions and 64 deletions
+1 -25
View File
@@ -15,30 +15,6 @@ const EditorSidebar = () => {
setTool(selectedTool);
};
const handleImageUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
const imageUrl = event.target?.result as string;
const img = new Image();
img.onload = () => {
const newImage = {
id: `image-${Date.now()}`,
type: "image" as ToolType,
x: 100,
y: 100,
width: img.width,
height: img.height,
imageUrl,
};
useEditorStore.getState().addObject(newImage);
};
img.src = imageUrl;
};
reader.readAsDataURL(file);
};
return (
<>
@@ -72,7 +48,7 @@ const EditorSidebar = () => {
onDelete={deleteObject}
/>
) : (
<ToolInstructions tool={tool} onImageUpload={handleImageUpload} />
<ToolInstructions tool={tool} />
)}
</div>
</div>