Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

feat: add OpenReel Image - professional graphic design editor

Augustus Otu5e6fb182b4ce
diff --git a/apps/image/index.html b/apps/image/index.html
new file mode 100644
index 00000000..566929a3
--- /dev/null
+++ b/apps/image/index.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="theme-color" content="#22c55e" />
+ <meta name="description" content="Professional browser-based graphic design editor - Create stunning visuals offline" />
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=DM+Sans:wght@400;500;700&family=Poppins:wght@300;400;500;600;700;800;900&family=Montserrat:wght@300;400;500;600;700;800;900&family=Playfair+Display:wght@400;500;600;700;800;900&family=Roboto:wght@300;400;500;700;900&family=Open+Sans:wght@300;400;600;700;800&family=Lato:wght@300;400;700;900&family=Oswald:wght@300;400;500;600;700&family=Bebas+Neue&family=Pacifico&family=Lobster&family=Dancing+Script:wght@400;700&family=Great+Vibes&display=swap" rel="stylesheet" />
+ <title>OpenReel Image - Professional Graphic Design Editor</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/src/main.tsx"></script>
+ </body>
+</html>
diff --git a/apps/image/package.json b/apps/image/package.json
new file mode 100644
index 00000000..98be759e
--- /dev/null
+++ b/apps/image/package.json
@@ -0,0 +1,61 @@
+{
+ "name": "@openreel/image",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "tsc --noEmit && vite build",
+ "preview": "vite preview",
+ "deploy": "wrangler pages deploy dist --project-name=openreel-image",
+ "deploy:preview": "wrangler pages deploy dist --project-name=openreel-image --branch=preview",
+ "test": "vitest",
+ "test:run": "vitest run",
+ "lint": "eslint src",
+ "typecheck": "tsc --noEmit",
+ "clean": "rm -rf dist node_modules/.vite"
+ },
+ "dependencies": {
+ "@openreel/ui": "workspace:*",
+ "@radix-ui/react-context-menu": "^2.2.16",
+ "@radix-ui/react-dialog": "^1.1.15",
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
+ "@radix-ui/react-popover": "^1.1.15",
+ "@radix-ui/react-select": "^2.2.6",
+ "@radix-ui/react-slider": "^1.3.6",
+ "@radix-ui/react-tabs": "^1.1.13",
+ "@radix-ui/react-tooltip": "^1.2.8",
+ "class-variance-authority": "^0.7.1",
+ "clsx": "^2.1.1",
+ "framer-motion": "^12.23.24",
+ "lucide-react": "^0.555.0",
+ "react": "^18.3.1",
+ "react-dom": "^18.3.1",
+ "tailwind-merge": "^3.4.0",
+ "uuid": "^13.0.0",
+ "zustand": "^4.5.2"
+ },
+ "devDependencies": {
+ "@eslint/js": "^9.39.2",
+ "@testing-library/jest-dom": "^6.4.6",
+ "@testing-library/react": "^16.0.0",
+ "@types/react": "^18.3.3",
+ "@types/react-dom": "^18.3.0",
+ "@types/uuid": "^11.0.0",
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
+ "@typescript-eslint/parser": "^8.53.0",
+ "@vitejs/plugin-react": "^4.3.1",
+ "autoprefixer": "^10.4.19",
+ "eslint": "^9.39.2",
+ "eslint-plugin-react-hooks": "^7.0.1",
+ "globals": "^17.0.0",
+ "jsdom": "^24.1.0",
+ "postcss": "^8.4.38",
+ "tailwindcss": "^3.4.4",
+ "tailwindcss-animate": "^1.0.7",
+ "typescript": "^5.4.5",
+ "vite": "^5.3.1",
+ "vitest": "^1.6.0",
+ "wrangler": "^3.114.17"
+ }
+}
diff --git a/apps/image/postcss.config.js b/apps/image/postcss.config.js
new file mode 100644
index 00000000..2aa7205d
--- /dev/null
+++ b/apps/image/postcss.config.js
@@ -0,0 +1,6 @@
+export default {
+ plugins: {
+ tailwindcss: {},
+ autoprefixer: {},
+ },
+};
diff --git a/apps/image/public/favicon.svg b/apps/image/public/favicon.svg
new file mode 100644
index 00000000..ed85208a
--- /dev/null
+++ b/apps/image/public/favicon.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
+ <rect width="100" height="100" rx="20" fill="#22c55e"/>
+ <rect x="20" y="20" width="60" height="60" rx="8" fill="white" fill-opacity="0.9"/>
+ <circle cx="35" cy="38" r="8" fill="#22c55e"/>
+ <path d="M20 65 L45 45 L60 55 L80 35 L80 72 A8 8 0 0 1 72 80 L28 80 A8 8 0 0 1 20 72 Z" fill="#22c55e" fill-opacity="0.8"/>
+</svg>
diff --git a/apps/image/src/App.tsx b/apps/image/src/App.tsx
new file mode 100644
index 00000000..da39063f
--- /dev/null
+++ b/apps/image/src/App.tsx
@@ -0,0 +1,34 @@
+import { useEffect } from 'react';
+import { useUIStore } from './stores/ui-store';
+import { WelcomeScreen } from './components/welcome/WelcomeScreen';
+import { EditorInterface } from './components/editor/EditorInterface';
+import { useKeyboardShortcuts } from './services/keyboard-service';
+import { useAutoSave } from './hooks/useAutoSave';
+
+export default function App() {
+ const { currentView, setCurrentView } = useUIStore();
+
+ useKeyboardShortcuts();
+ useAutoSave();
+
+ useEffect(() => {
+ document.documentElement.classList.add('dark');
+ }, []);
+
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === 'Escape' && currentView === 'editor') {
+ setCurrentView('welcome');
+ }
+ };
+ window.addEventListener('keydown', handleKeyDown);
+ return () => window.removeEventListener('keydown', handleKeyDown);
+ }, [currentView, setCurrentView]);
+
+ return (
+ <div className="h-full w-full bg-background">
+ {currentView === 'welcome' && <WelcomeScreen />}
+ {currentView === 'editor' && <EditorInterface />}
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/EditorInterface.tsx b/apps/image/src/components/editor/EditorInterface.tsx
new file mode 100644
index 00000000..a6a1f5f4
--- /dev/null
+++ b/apps/image/src/components/editor/EditorInterface.tsx
@@ -0,0 +1,49 @@
+import { Toolbar } from './toolbar/Toolbar';
+import { LeftPanel } from './panels/LeftPanel';
+import { Canvas } from './canvas/Canvas';
+import { Inspector } from './inspector/Inspector';
+import { LayerPanel } from './layers/LayerPanel';
+import { useUIStore } from '../../stores/ui-store';
+import { useProjectStore } from '../../stores/project-store';
+
+export function EditorInterface() {
+ const { isPanelCollapsed, isInspectorCollapsed } = useUIStore();
+ const { project } = useProjectStore();
+
+ if (!project) {
+ return (
+ <div className="h-full w-full flex items-center justify-center bg-background">
+ <p className="text-muted-foreground">No project loaded</p>
+ </div>
+ );
+ }
+
+ return (
+ <div className="h-full w-full flex flex-col bg-background overflow-hidden">
+ <Toolbar />
+
+ <div className="flex-1 flex overflow-hidden">
+ {!isPanelCollapsed && (
+ <div className="w-72 border-r border-border flex flex-col bg-card">
+ <LeftPanel />
+ </div>
+ )}
+
+ <div className="flex-1 flex flex-col overflow-hidden">
+ <Canvas />
+ </div>
+
+ {!isInspectorCollapsed && (
+ <div className="w-72 border-l border-border flex flex-col bg-card">
+ <div className="flex-1 overflow-y-auto">
+ <Inspector />
+ </div>
+ <div className="h-64 border-t border-border">
+ <LayerPanel />
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/canvas/Canvas.tsx b/apps/image/src/components/editor/canvas/Canvas.tsx
new file mode 100644
index 00000000..3e00c153
--- /dev/null
+++ b/apps/image/src/components/editor/canvas/Canvas.tsx
@@ -0,0 +1,431 @@
+import { useEffect, useRef, useCallback } from 'react';
+import { useProjectStore } from '../../../stores/project-store';
+import { useUIStore } from '../../../stores/ui-store';
+import { useCanvasStore } from '../../../stores/canvas-store';
+import type { Layer, ImageLayer, TextLayer, ShapeLayer } from '../../../types/project';
+
+export function Canvas() {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const canvasRef = useRef<HTMLCanvasElement>(null);
+
+ const { project, selectedLayerIds, selectedArtboardId, updateLayerTransform, selectLayer, deselectAllLayers } = useProjectStore();
+ const { zoom, panX, panY, setPan, activeTool, showGrid, gridSize } = useUIStore();
+ const { setCanvasRef, setContainerRef, startDrag, updateDrag, endDrag, isDragging, dragMode, dragCurrentX, dragCurrentY } = useCanvasStore();
+
+ const artboard = project?.artboards.find((a) => a.id === selectedArtboardId);
+
+ useEffect(() => {
+ if (canvasRef.current) {
+ setCanvasRef(canvasRef.current);
+ }
+ if (containerRef.current) {
+ setContainerRef(containerRef.current);
+ }
+ }, [setCanvasRef, setContainerRef]);
+
+ const render = useCallback(() => {
+ const canvas = canvasRef.current;
+ const ctx = canvas?.getContext('2d');
+ if (!canvas || !ctx || !artboard || !project) return;
+
+ const container = containerRef.current;
+ if (container) {
+ canvas.width = container.clientWidth;
+ canvas.height = container.clientHeight;
+ }
+
+ ctx.save();
+ ctx.fillStyle = '#18181b';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ const centerX = canvas.width / 2 + panX;
+ const centerY = canvas.height / 2 + panY;
+ const artboardX = centerX - (artboard.size.width * zoom) / 2;
+ const artboardY = centerY - (artboard.size.height * zoom) / 2;
+
+ ctx.save();
+ ctx.translate(artboardX, artboardY);
+ ctx.scale(zoom, zoom);
+
+ if (artboard.background.type === 'color') {
+ ctx.fillStyle = artboard.background.color ?? '#ffffff';
+ } else if (artboard.background.type === 'transparent') {
+ const patternSize = 10;
+ for (let y = 0; y < artboard.size.height; y += patternSize) {
+ for (let x = 0; x < artboard.size.width; x += patternSize) {
+ ctx.fillStyle = (x + y) % (patternSize * 2) === 0 ? '#ffffff' : '#e5e5e5';
+ ctx.fillRect(x, y, patternSize, patternSize);
+ }
+ }
+ } else {
+ ctx.fillStyle = '#ffffff';
+ }
+ if (artboard.background.type !== 'transparent') {
+ ctx.fillRect(0, 0, artboard.size.width, artboard.size.height);
+ }
+
+ if (showGrid) {
+ ctx.strokeStyle = 'rgba(128, 128, 128, 0.3)';
+ ctx.lineWidth = 1 / zoom;
+ for (let x = 0; x <= artboard.size.width; x += gridSize) {
+ ctx.beginPath();
+ ctx.moveTo(x, 0);
+ ctx.lineTo(x, artboard.size.height);
+ ctx.stroke();
+ }
+ for (let y = 0; y <= artboard.size.height; y += gridSize) {
+ ctx.beginPath();
+ ctx.moveTo(0, y);
+ ctx.lineTo(artboard.size.width, y);
+ ctx.stroke();
+ }
+ }
+
+ const sortedLayerIds = [...artboard.layerIds].reverse();
+ sortedLayerIds.forEach((layerId) => {
+ const layer = project.layers[layerId];
+ if (!layer || !layer.visible) return;
+ renderLayer(ctx, layer, project);
+ });
+
+ ctx.restore();
+
+ selectedLayerIds.forEach((layerId) => {
+ const layer = project.layers[layerId];
+ if (!layer) return;
+ const { x, y, width, height, rotation } = layer.transform;
+
+ ctx.save();
+ ctx.translate(artboardX + x * zoom, artboardY + y * zoom);
+ ctx.rotate((rotation * Math.PI) / 180);
+
+ ctx.strokeStyle = '#22c55e';
+ ctx.lineWidth = 2;
+ ctx.setLineDash([]);
+ ctx.strokeRect(0, 0, width * zoom, height * zoom);
+
+ const handleSize = 8;
+ ctx.fillStyle = '#ffffff';
+ ctx.strokeStyle = '#22c55e';
+ ctx.lineWidth = 2;
+
+ const handles = [
+ { x: 0, y: 0 },
+ { x: width * zoom / 2, y: 0 },
+ { x: width * zoom, y: 0 },
+ { x: width * zoom, y: height * zoom / 2 },
+ { x: width * zoom, y: height * zoom },
+ { x: width * zoom / 2, y: height * zoom },
+ { x: 0, y: height * zoom },
+ { x: 0, y: height * zoom / 2 },
+ ];
+
+ handles.forEach((h) => {
+ ctx.fillRect(h.x - handleSize / 2, h.y - handleSize / 2, handleSize, handleSize);
+ ctx.strokeRect(h.x - handleSize / 2, h.y - handleSize / 2, handleSize, handleSize);
+ });
+
+ ctx.restore();
+ });
+
+ ctx.restore();
+ }, [artboard, project, zoom, panX, panY, selectedLayerIds, showGrid, gridSize]);
+
+ useEffect(() => {
+ render();
+ }, [render]);
+
+ useEffect(() => {
+ const handleResize = () => render();
+ window.addEventListener('resize', handleResize);
+ return () => window.removeEventListener('resize', handleResize);
+ }, [render]);
+
+ const screenToCanvas = useCallback(
+ (screenX: number, screenY: number) => {
+ const canvas = canvasRef.current;
+ if (!canvas || !artboard) return { x: 0, y: 0 };
+
+ const rect = canvas.getBoundingClientRect();
+ const canvasX = screenX - rect.left;
+ const canvasY = screenY - rect.top;
+
+ const centerX = canvas.width / 2 + panX;
+ const centerY = canvas.height / 2 + panY;
+ const artboardX = centerX - (artboard.size.width * zoom) / 2;
+ const artboardY = centerY - (artboard.size.height * zoom) / 2;
+
+ return {
+ x: (canvasX - artboardX) / zoom,
+ y: (canvasY - artboardY) / zoom,
+ };
+ },
+ [artboard, zoom, panX, panY]
+ );
+
+ const findLayerAtPoint = useCallback(
+ (x: number, y: number): string | null => {
+ if (!artboard || !project) return null;
+
+ for (const layerId of artboard.layerIds) {
+ const layer = project.layers[layerId];
+ if (!layer || !layer.visible || layer.locked) continue;
+
+ const { transform } = layer;
+ if (
+ x >= transform.x &&
+ x <= transform.x + transform.width &&
+ y >= transform.y &&
+ y <= transform.y + transform.height
+ ) {
+ return layerId;
+ }
+ }
+ return null;
+ },
+ [artboard, project]
+ );
+
+ const handleMouseDown = useCallback(
+ (e: React.MouseEvent) => {
+ const canvas = canvasRef.current;
+ if (!canvas) return;
+
+ const { x, y } = screenToCanvas(e.clientX, e.clientY);
+
+ if (activeTool === 'hand' || e.button === 1) {
+ startDrag('pan', e.clientX, e.clientY);
+ return;
+ }
+
+ if (activeTool === 'select') {
+ const layerId = findLayerAtPoint(x, y);
+ if (layerId) {
+ if (e.shiftKey) {
+ selectLayer(layerId, true);
+ } else if (!selectedLayerIds.includes(layerId)) {
+ selectLayer(layerId);
+ }
+ startDrag('move', e.clientX, e.clientY);
+ } else {
+ deselectAllLayers();
+ }
+ }
+ },
+ [activeTool, screenToCanvas, findLayerAtPoint, selectLayer, deselectAllLayers, startDrag, selectedLayerIds]
+ );
+
+ const handleMouseMove = useCallback(
+ (e: React.MouseEvent) => {
+ if (!isDragging) return;
+
+ updateDrag(e.clientX, e.clientY);
+
+ if (dragMode === 'pan') {
+ const dx = e.clientX - dragCurrentX;
+ const dy = e.clientY - dragCurrentY;
+ setPan(panX + dx, panY + dy);
+ } else if (dragMode === 'move' && selectedLayerIds.length > 0) {
+ const dx = (e.clientX - dragCurrentX) / zoom;
+ const dy = (e.clientY - dragCurrentY) / zoom;
+
+ selectedLayerIds.forEach((layerId) => {
+ const layer = project?.layers[layerId];
+ if (layer) {
+ updateLayerTransform(layerId, {
+ x: layer.transform.x + dx,
+ y: layer.transform.y + dy,
+ });
+ }
+ });
+ }
+ },
+ [isDragging, dragMode, dragCurrentX, dragCurrentY, panX, panY, setPan, zoom, selectedLayerIds, project, updateLayerTransform, updateDrag]
+ );
+
+ const handleMouseUp = useCallback(() => {
+ endDrag();
+ }, [endDrag]);
+
+ const handleWheel = useCallback(
+ (e: React.WheelEvent) => {
+ if (e.ctrlKey || e.metaKey) {
+ e.preventDefault();
+ const delta = e.deltaY > 0 ? 0.9 : 1.1;
+ useUIStore.getState().setZoom(zoom * delta);
+ } else {
+ setPan(panX - e.deltaX, panY - e.deltaY);
+ }
+ },
+ [zoom, panX, panY, setPan]
+ );
+
+ return (
+ <div
+ ref={containerRef}
+ className="flex-1 overflow-hidden cursor-crosshair"
+ style={{
+ cursor: activeTool === 'hand' ? 'grab' : activeTool === 'select' ? 'default' : 'crosshair',
+ }}
+ >
+ <canvas
+ ref={canvasRef}
+ onMouseDown={handleMouseDown}
+ onMouseMove={handleMouseMove}
+ onMouseUp={handleMouseUp}
+ onMouseLeave={handleMouseUp}
+ onWheel={handleWheel}
+ className="w-full h-full"
+ />
+ </div>
+ );
+}
+
+function renderLayer(
+ ctx: CanvasRenderingContext2D,
+ layer: Layer,
+ project: { assets: Record<string, { dataUrl?: string; blobUrl?: string }> }
+) {
+ const { transform } = layer;
+
+ ctx.save();
+ ctx.translate(transform.x, transform.y);
+ ctx.rotate((transform.rotation * Math.PI) / 180);
+ ctx.scale(transform.scaleX, transform.scaleY);
+ ctx.globalAlpha = transform.opacity;
+
+ switch (layer.type) {
+ case 'image':
+ renderImageLayer(ctx, layer as ImageLayer, project);
+ break;
+ case 'text':
+ renderTextLayer(ctx, layer as TextLayer);
+ break;
+ case 'shape':
+ renderShapeLayer(ctx, layer as ShapeLayer);
+ break;
+ }
+
+ ctx.restore();
+}
+
+function renderImageLayer(
+ ctx: CanvasRenderingContext2D,
+ layer: ImageLayer,
+ project: { assets: Record<string, { dataUrl?: string; blobUrl?: string }> }
+) {
+ const asset = project.assets[layer.sourceId];
+ if (!asset) {
+ ctx.fillStyle = '#3b82f6';
+ ctx.fillRect(0, 0, layer.transform.width, layer.transform.height);
+ ctx.fillStyle = '#ffffff';
+ ctx.font = '14px sans-serif';
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText('Image', layer.transform.width / 2, layer.transform.height / 2);
+ return;
+ }
+
+ const img = new window.Image();
+ img.src = asset.dataUrl ?? asset.blobUrl ?? '';
+ if (img.complete) {
+ ctx.drawImage(img, 0, 0, layer.transform.width, layer.transform.height);
+ }
+}
+
+function renderTextLayer(ctx: CanvasRenderingContext2D, layer: TextLayer) {
+ const { style, content, transform } = layer;
+
+ ctx.fillStyle = style.color;
+ ctx.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;
+ ctx.textAlign = style.textAlign as CanvasTextAlign;
+ ctx.textBaseline = 'top';
+
+ const lines = content.split('\n');
+ const lineHeight = style.fontSize * style.lineHeight;
+
+ let textX = 0;
+ if (style.textAlign === 'center') textX = transform.width / 2;
+ else if (style.textAlign === 'right') textX = transform.width;
+
+ lines.forEach((line, i) => {
+ ctx.fillText(line, textX, i * lineHeight);
+ });
+}
+
+function renderShapeLayer(ctx: CanvasRenderingContext2D, layer: ShapeLayer) {
+ const { shapeType, shapeStyle, transform } = layer;
+ const { width, height } = transform;
+
+ ctx.beginPath();
+
+ switch (shapeType) {
+ case 'rectangle':
+ if (shapeStyle.cornerRadius > 0) {
+ const r = Math.min(shapeStyle.cornerRadius, width / 2, height / 2);
+ ctx.moveTo(r, 0);
+ ctx.lineTo(width - r, 0);
+ ctx.quadraticCurveTo(width, 0, width, r);
+ ctx.lineTo(width, height - r);
+ ctx.quadraticCurveTo(width, height, width - r, height);
+ ctx.lineTo(r, height);
+ ctx.quadraticCurveTo(0, height, 0, height - r);
+ ctx.lineTo(0, r);
+ ctx.quadraticCurveTo(0, 0, r, 0);
+ } else {
+ ctx.rect(0, 0, width, height);
+ }
+ break;
+
+ case 'ellipse':
+ ctx.ellipse(width / 2, height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);
+ break;
+
+ case 'triangle':
+ ctx.moveTo(width / 2, 0);
+ ctx.lineTo(width, height);
+ ctx.lineTo(0, height);
+ ctx.closePath();
+ break;
+
+ case 'star': {
+ const cx = width / 2;
+ const cy = height / 2;
+ const outerRadius = Math.min(width, height) / 2;
+ const innerRadius = outerRadius * 0.4;
+ const points = 5;
+ for (let i = 0; i < points * 2; i++) {
+ const radius = i % 2 === 0 ? outerRadius : innerRadius;
+ const angle = (i * Math.PI) / points - Math.PI / 2;
+ const px = cx + radius * Math.cos(angle);
+ const py = cy + radius * Math.sin(angle);
+ if (i === 0) ctx.moveTo(px, py);
+ else ctx.lineTo(px, py);
+ }
+ ctx.closePath();
+ break;
+ }
+
+ case 'line':
+ ctx.moveTo(0, height / 2);
+ ctx.lineTo(width, height / 2);
+ break;
+
+ default:
+ ctx.rect(0, 0, width, height);
+ }
+
+ if (shapeStyle.fill) {
+ ctx.fillStyle = shapeStyle.fill;
+ ctx.globalAlpha *= shapeStyle.fillOpacity;
+ ctx.fill();
+ ctx.globalAlpha /= shapeStyle.fillOpacity;
+ }
+
+ if (shapeStyle.stroke) {
+ ctx.strokeStyle = shapeStyle.stroke;
+ ctx.lineWidth = shapeStyle.strokeWidth;
+ ctx.globalAlpha *= shapeStyle.strokeOpacity;
+ ctx.stroke();
+ }
+}
diff --git a/apps/image/src/components/editor/inspector/AppearanceSection.tsx b/apps/image/src/components/editor/inspector/AppearanceSection.tsx
new file mode 100644
index 00000000..6f30cd05
--- /dev/null
+++ b/apps/image/src/components/editor/inspector/AppearanceSection.tsx
@@ -0,0 +1,184 @@
+import { useProjectStore } from '../../../stores/project-store';
+import type { Layer, BlendMode } from '../../../types/project';
+
+interface Props {
+ layer: Layer;
+}
+
+const BLEND_MODES: BlendMode['mode'][] = [
+ 'normal',
+ 'multiply',
+ 'screen',
+ 'overlay',
+ 'darken',
+ 'lighten',
+ 'color-dodge',
+ 'color-burn',
+ 'hard-light',
+ 'soft-light',
+ 'difference',
+ 'exclusion',
+];
+
+export function AppearanceSection({ layer }: Props) {
+ const { updateLayer } = useProjectStore();
+
+ const handleBlendModeChange = (mode: BlendMode['mode']) => {
+ updateLayer(layer.id, { blendMode: { mode } });
+ };
+
+ const handleShadowToggle = () => {
+ updateLayer(layer.id, {
+ shadow: { ...layer.shadow, enabled: !layer.shadow.enabled },
+ });
+ };
+
+ const handleShadowChange = (key: string, value: string | number) => {
+ updateLayer(layer.id, {
+ shadow: { ...layer.shadow, [key]: value },
+ });
+ };
+
+ const handleStrokeToggle = () => {
+ updateLayer(layer.id, {
+ stroke: { ...layer.stroke, enabled: !layer.stroke.enabled },
+ });
+ };
+
+ const handleStrokeChange = (key: string, value: string | number) => {
+ updateLayer(layer.id, {
+ stroke: { ...layer.stroke, [key]: value },
+ });
+ };
+
+ return (
+ <div className="space-y-4">
+ <h4 className="text-xs font-medium text-muted-foreground uppercase tracking-wide">
+ Appearance
+ </h4>
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Blend Mode</label>
+ <select
+ value={layer.blendMode.mode}
+ onChange={(e) => handleBlendModeChange(e.target.value as BlendMode['mode'])}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary capitalize"
+ >
+ {BLEND_MODES.map((mode) => (
+ <option key={mode} value={mode} className="capitalize">
+ {mode.replace('-', ' ')}
+ </option>
+ ))}
+ </select>
+ </div>
+
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <label className="text-[10px] text-muted-foreground">Drop Shadow</label>
+ <button
+ onClick={handleShadowToggle}
+ className={`w-8 h-5 rounded-full transition-colors ${
+ layer.shadow.enabled ? 'bg-primary' : 'bg-secondary'
+ }`}
+ >
+ <div
+ className={`w-4 h-4 bg-white rounded-full shadow transition-transform ${
+ layer.shadow.enabled ? 'translate-x-3.5' : 'translate-x-0.5'
+ }`}
+ />
+ </button>
+ </div>
+
+ {layer.shadow.enabled && (
+ <div className="pl-2 border-l-2 border-border space-y-2">
+ <div className="flex items-center gap-2">
+ <label className="text-[10px] text-muted-foreground w-12">Color</label>
+ <input
+ type="color"
+ value={layer.shadow.color.replace(/rgba?\([^)]+\)/, '#000000')}
+ onChange={(e) => handleShadowChange('color', e.target.value)}
+ className="w-6 h-6 rounded border border-input cursor-pointer"
+ />
+ </div>
+ <div className="flex items-center gap-2">
+ <label className="text-[10px] text-muted-foreground w-12">Blur</label>
+ <input
+ type="range"
+ value={layer.shadow.blur}
+ onChange={(e) => handleShadowChange('blur', Number(e.target.value))}
+ min={0}
+ max={50}
+ className="flex-1 h-1 accent-primary"
+ />
+ <span className="text-[10px] text-muted-foreground w-6 text-right">
+ {layer.shadow.blur}
+ </span>
+ </div>
+ <div className="flex items-center gap-2">
+ <label className="text-[10px] text-muted-foreground w-12">X</label>
+ <input
+ type="number"
+ value={layer.shadow.offsetX}
+ onChange={(e) => handleShadowChange('offsetX', Number(e.target.value))}
+ className="w-16 px-2 py-1 text-xs bg-background border border-input rounded-md"
+ />
+ <label className="text-[10px] text-muted-foreground w-4">Y</label>
+ <input
+ type="number"
+ value={layer.shadow.offsetY}
+ onChange={(e) => handleShadowChange('offsetY', Number(e.target.value))}
+ className="w-16 px-2 py-1 text-xs bg-background border border-input rounded-md"
+ />
+ </div>
+ </div>
+ )}
+ </div>
+
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <label className="text-[10px] text-muted-foreground">Stroke</label>
+ <button
+ onClick={handleStrokeToggle}
+ className={`w-8 h-5 rounded-full transition-colors ${
+ layer.stroke.enabled ? 'bg-primary' : 'bg-secondary'
+ }`}
+ >
+ <div
+ className={`w-4 h-4 bg-white rounded-full shadow transition-transform ${
+ layer.stroke.enabled ? 'translate-x-3.5' : 'translate-x-0.5'
+ }`}
+ />
+ </button>
+ </div>
+
+ {layer.stroke.enabled && (
+ <div className="pl-2 border-l-2 border-border space-y-2">
+ <div className="flex items-center gap-2">
+ <label className="text-[10px] text-muted-foreground w-12">Color</label>
+ <input
+ type="color"
+ value={layer.stroke.color}
+ onChange={(e) => handleStrokeChange('color', e.target.value)}
+ className="w-6 h-6 rounded border border-input cursor-pointer"
+ />
+ </div>
+ <div className="flex items-center gap-2">
+ <label className="text-[10px] text-muted-foreground w-12">Width</label>
+ <input
+ type="range"
+ value={layer.stroke.width}
+ onChange={(e) => handleStrokeChange('width', Number(e.target.value))}
+ min={1}
+ max={20}
+ className="flex-1 h-1 accent-primary"
+ />
+ <span className="text-[10px] text-muted-foreground w-6 text-right">
+ {layer.stroke.width}
+ </span>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/inspector/ArtboardSection.tsx b/apps/image/src/components/editor/inspector/ArtboardSection.tsx
new file mode 100644
index 00000000..f196b2d5
--- /dev/null
+++ b/apps/image/src/components/editor/inspector/ArtboardSection.tsx
@@ -0,0 +1,136 @@
+import { useProjectStore } from '../../../stores/project-store';
+import type { Artboard, CanvasBackground } from '../../../types/project';
+
+interface Props {
+ artboard: Artboard;
+}
+
+export function ArtboardSection({ artboard }: Props) {
+ const { updateArtboard } = useProjectStore();
+
+ const handleSizeChange = (key: 'width' | 'height', value: number) => {
+ updateArtboard(artboard.id, {
+ size: { ...artboard.size, [key]: value },
+ });
+ };
+
+ const handleBackgroundTypeChange = (type: CanvasBackground['type']) => {
+ let background: CanvasBackground;
+ switch (type) {
+ case 'color':
+ background = { type: 'color', color: '#ffffff' };
+ break;
+ case 'transparent':
+ background = { type: 'transparent' };
+ break;
+ case 'gradient':
+ background = {
+ type: 'gradient',
+ gradient: {
+ type: 'linear',
+ angle: 180,
+ stops: [
+ { offset: 0, color: '#ffffff' },
+ { offset: 1, color: '#000000' },
+ ],
+ },
+ };
+ break;
+ default:
+ background = { type: 'color', color: '#ffffff' };
+ }
+ updateArtboard(artboard.id, { background });
+ };
+
+ const handleBackgroundColorChange = (color: string) => {
+ updateArtboard(artboard.id, {
+ background: { type: 'color', color },
+ });
+ };
+
+ return (
+ <div className="space-y-4">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Name</label>
+ <input
+ type="text"
+ value={artboard.name}
+ onChange={(e) => updateArtboard(artboard.id, { name: e.target.value })}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ />
+ </div>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Width</label>
+ <input
+ type="number"
+ value={artboard.size.width}
+ onChange={(e) => handleSizeChange('width', Number(e.target.value))}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ min={1}
+ max={8000}
+ />
+ </div>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Height</label>
+ <input
+ type="number"
+ value={artboard.size.height}
+ onChange={(e) => handleSizeChange('height', Number(e.target.value))}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ min={1}
+ max={8000}
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Background</label>
+ <select
+ value={artboard.background.type}
+ onChange={(e) => handleBackgroundTypeChange(e.target.value as CanvasBackground['type'])}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary mb-2"
+ >
+ <option value="color">Solid Color</option>
+ <option value="transparent">Transparent</option>
+ <option value="gradient">Gradient</option>
+ </select>
+
+ {artboard.background.type === 'color' && (
+ <div className="flex items-center gap-2">
+ <input
+ type="color"
+ value={artboard.background.color ?? '#ffffff'}
+ onChange={(e) => handleBackgroundColorChange(e.target.value)}
+ className="w-8 h-8 rounded border border-input cursor-pointer"
+ />
+ <input
+ type="text"
+ value={artboard.background.color ?? '#ffffff'}
+ onChange={(e) => handleBackgroundColorChange(e.target.value)}
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary font-mono"
+ />
+ </div>
+ )}
+
+ {artboard.background.type === 'transparent' && (
+ <div className="p-3 rounded-md bg-background border border-input">
+ <div
+ className="h-8 rounded"
+ style={{
+ backgroundImage:
+ 'linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)',
+ backgroundSize: '10px 10px',
+ backgroundPosition: '0 0, 0 5px, 5px -5px, -5px 0px',
+ }}
+ />
+ <p className="text-[10px] text-muted-foreground mt-2 text-center">
+ Transparency pattern
+ </p>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/inspector/Inspector.tsx b/apps/image/src/components/editor/inspector/Inspector.tsx
new file mode 100644
index 00000000..dea31f0f
--- /dev/null
+++ b/apps/image/src/components/editor/inspector/Inspector.tsx
@@ -0,0 +1,77 @@
+import { useProjectStore } from '../../../stores/project-store';
+import { TransformSection } from './TransformSection';
+import { AppearanceSection } from './AppearanceSection';
+import { TextSection } from './TextSection';
+import { ShapeSection } from './ShapeSection';
+import { ArtboardSection } from './ArtboardSection';
+import type { TextLayer, ShapeLayer } from '../../../types/project';
+
+export function Inspector() {
+ const { project, selectedLayerIds, selectedArtboardId } = useProjectStore();
+
+ const selectedLayers = selectedLayerIds
+ .map((id) => project?.layers[id])
+ .filter(Boolean);
+
+ const singleLayer = selectedLayers.length === 1 ? selectedLayers[0] : null;
+
+ if (selectedLayers.length === 0) {
+ const artboard = project?.artboards.find((a) => a.id === selectedArtboardId);
+ if (artboard) {
+ return (
+ <div className="p-4">
+ <h3 className="text-sm font-medium text-foreground mb-4">Artboard</h3>
+ <ArtboardSection artboard={artboard} />
+ </div>
+ );
+ }
+
+ return (
+ <div className="p-4 text-center">
+ <p className="text-sm text-muted-foreground">
+ Select a layer to edit its properties
+ </p>
+ </div>
+ );
+ }
+
+ if (selectedLayers.length > 1) {
+ return (
+ <div className="p-4">
+ <div className="flex items-center justify-between mb-4">
+ <h3 className="text-sm font-medium text-foreground">
+ {selectedLayers.length} layers selected
+ </h3>
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Multiple selection editing coming soon
+ </p>
+ </div>
+ );
+ }
+
+ if (!singleLayer) return null;
+
+ return (
+ <div className="p-4 space-y-6">
+ <div>
+ <h3 className="text-sm font-medium text-foreground mb-1 truncate">
+ {singleLayer.name}
+ </h3>
+ <p className="text-xs text-muted-foreground capitalize">{singleLayer.type} layer</p>
+ </div>
+
+ <TransformSection layer={singleLayer} />
+
+ <AppearanceSection layer={singleLayer} />
+
+ {singleLayer.type === 'text' && (
+ <TextSection layer={singleLayer as TextLayer} />
+ )}
+
+ {singleLayer.type === 'shape' && (
+ <ShapeSection layer={singleLayer as ShapeLayer} />
+ )}
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/inspector/ShapeSection.tsx b/apps/image/src/components/editor/inspector/ShapeSection.tsx
new file mode 100644
index 00000000..aafede7a
--- /dev/null
+++ b/apps/image/src/components/editor/inspector/ShapeSection.tsx
@@ -0,0 +1,168 @@
+import { useProjectStore } from '../../../stores/project-store';
+import type { ShapeLayer, ShapeStyle } from '../../../types/project';
+
+interface Props {
+ layer: ShapeLayer;
+}
+
+export function ShapeSection({ layer }: Props) {
+ const { updateLayer } = useProjectStore();
+
+ const handleStyleChange = (updates: Partial<ShapeStyle>) => {
+ updateLayer<ShapeLayer>(layer.id, {
+ shapeStyle: { ...layer.shapeStyle, ...updates },
+ });
+ };
+
+ return (
+ <div className="space-y-4">
+ <h4 className="text-xs font-medium text-muted-foreground uppercase tracking-wide">
+ Shape
+ </h4>
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Fill Color</label>
+ <div className="flex items-center gap-2">
+ <button
+ onClick={() => handleStyleChange({ fill: layer.shapeStyle.fill ? null : '#3b82f6' })}
+ className={`w-8 h-8 rounded border border-input flex items-center justify-center ${
+ layer.shapeStyle.fill ? '' : 'bg-background'
+ }`}
+ style={{ backgroundColor: layer.shapeStyle.fill ?? undefined }}
+ title={layer.shapeStyle.fill ? 'Remove fill' : 'Add fill'}
+ >
+ {!layer.shapeStyle.fill && (
+ <span className="text-xs text-muted-foreground">∅</span>
+ )}
+ </button>
+ {layer.shapeStyle.fill && (
+ <>
+ <input
+ type="color"
+ value={layer.shapeStyle.fill}
+ onChange={(e) => handleStyleChange({ fill: e.target.value })}
+ className="w-8 h-8 rounded border border-input cursor-pointer"
+ />
+ <input
+ type="text"
+ value={layer.shapeStyle.fill}
+ onChange={(e) => handleStyleChange({ fill: e.target.value })}
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary font-mono"
+ />
+ </>
+ )}
+ </div>
+ </div>
+
+ {layer.shapeStyle.fill && (
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Fill Opacity</label>
+ <div className="flex items-center gap-2">
+ <input
+ type="range"
+ value={layer.shapeStyle.fillOpacity * 100}
+ onChange={(e) => handleStyleChange({ fillOpacity: Number(e.target.value) / 100 })}
+ min={0}
+ max={100}
+ className="flex-1 h-1 accent-primary"
+ />
+ <span className="text-[10px] text-muted-foreground w-8 text-right">
+ {Math.round(layer.shapeStyle.fillOpacity * 100)}%
+ </span>
+ </div>
+ </div>
+ )}
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Stroke Color</label>
+ <div className="flex items-center gap-2">
+ <button
+ onClick={() => handleStyleChange({ stroke: layer.shapeStyle.stroke ? null : '#000000' })}
+ className={`w-8 h-8 rounded border-2 flex items-center justify-center ${
+ layer.shapeStyle.stroke ? '' : 'border-input bg-background'
+ }`}
+ style={{ borderColor: layer.shapeStyle.stroke ?? undefined }}
+ title={layer.shapeStyle.stroke ? 'Remove stroke' : 'Add stroke'}
+ >
+ {!layer.shapeStyle.stroke && (
+ <span className="text-xs text-muted-foreground">∅</span>
+ )}
+ </button>
+ {layer.shapeStyle.stroke && (
+ <>
+ <input
+ type="color"
+ value={layer.shapeStyle.stroke}
+ onChange={(e) => handleStyleChange({ stroke: e.target.value })}
+ className="w-8 h-8 rounded border border-input cursor-pointer"
+ />
+ <input
+ type="text"
+ value={layer.shapeStyle.stroke}
+ onChange={(e) => handleStyleChange({ stroke: e.target.value })}
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary font-mono"
+ />
+ </>
+ )}
+ </div>
+ </div>
+
+ {layer.shapeStyle.stroke && (
+ <>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Stroke Width</label>
+ <div className="flex items-center gap-2">
+ <input
+ type="range"
+ value={layer.shapeStyle.strokeWidth}
+ onChange={(e) => handleStyleChange({ strokeWidth: Number(e.target.value) })}
+ min={1}
+ max={20}
+ className="flex-1 h-1 accent-primary"
+ />
+ <span className="text-[10px] text-muted-foreground w-6 text-right">
+ {layer.shapeStyle.strokeWidth}
+ </span>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Stroke Opacity</label>
+ <div className="flex items-center gap-2">
+ <input
+ type="range"
+ value={layer.shapeStyle.strokeOpacity * 100}
+ onChange={(e) => handleStyleChange({ strokeOpacity: Number(e.target.value) / 100 })}
+ min={0}
+ max={100}
+ className="flex-1 h-1 accent-primary"
+ />
+ <span className="text-[10px] text-muted-foreground w-8 text-right">
+ {Math.round(layer.shapeStyle.strokeOpacity * 100)}%
+ </span>
+ </div>
+ </div>
+ </>
+ )}
+
+ {(layer.shapeType === 'rectangle') && (
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Corner Radius</label>
+ <div className="flex items-center gap-2">
+ <input
+ type="range"
+ value={layer.shapeStyle.cornerRadius}
+ onChange={(e) => handleStyleChange({ cornerRadius: Number(e.target.value) })}
+ min={0}
+ max={100}
+ className="flex-1 h-1 accent-primary"
+ />
+ <span className="text-[10px] text-muted-foreground w-6 text-right">
+ {layer.shapeStyle.cornerRadius}
+ </span>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/inspector/TextSection.tsx b/apps/image/src/components/editor/inspector/TextSection.tsx
new file mode 100644
index 00000000..bbb02a28
--- /dev/null
+++ b/apps/image/src/components/editor/inspector/TextSection.tsx
@@ -0,0 +1,222 @@
+import { useProjectStore } from '../../../stores/project-store';
+import type { TextLayer, TextStyle } from '../../../types/project';
+import { AlignLeft, AlignCenter, AlignRight, Bold, Italic, Underline } from 'lucide-react';
+
+interface Props {
+ layer: TextLayer;
+}
+
+const FONT_FAMILIES = [
+ 'Inter',
+ 'DM Sans',
+ 'Poppins',
+ 'Montserrat',
+ 'Playfair Display',
+ 'Roboto',
+ 'Open Sans',
+ 'Lato',
+ 'Oswald',
+ 'Bebas Neue',
+ 'Pacifico',
+ 'Lobster',
+ 'Dancing Script',
+ 'Great Vibes',
+];
+
+const FONT_SIZES = [8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 96, 128];
+
+export function TextSection({ layer }: Props) {
+ const { updateLayer } = useProjectStore();
+
+ const handleContentChange = (content: string) => {
+ updateLayer<TextLayer>(layer.id, { content });
+ };
+
+ const handleStyleChange = (updates: Partial<TextStyle>) => {
+ updateLayer<TextLayer>(layer.id, {
+ style: { ...layer.style, ...updates },
+ });
+ };
+
+ const toggleBold = () => {
+ handleStyleChange({
+ fontWeight: layer.style.fontWeight >= 700 ? 400 : 700,
+ });
+ };
+
+ const toggleItalic = () => {
+ handleStyleChange({
+ fontStyle: layer.style.fontStyle === 'italic' ? 'normal' : 'italic',
+ });
+ };
+
+ const toggleUnderline = () => {
+ handleStyleChange({
+ textDecoration: layer.style.textDecoration === 'underline' ? 'none' : 'underline',
+ });
+ };
+
+ return (
+ <div className="space-y-4">
+ <h4 className="text-xs font-medium text-muted-foreground uppercase tracking-wide">
+ Text
+ </h4>
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Content</label>
+ <textarea
+ value={layer.content}
+ onChange={(e) => handleContentChange(e.target.value)}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary min-h-[60px] resize-none"
+ rows={3}
+ />
+ </div>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Font</label>
+ <select
+ value={layer.style.fontFamily}
+ onChange={(e) => handleStyleChange({ fontFamily: e.target.value })}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ >
+ {FONT_FAMILIES.map((font) => (
+ <option key={font} value={font} style={{ fontFamily: font }}>
+ {font}
+ </option>
+ ))}
+ </select>
+ </div>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Size</label>
+ <select
+ value={layer.style.fontSize}
+ onChange={(e) => handleStyleChange({ fontSize: Number(e.target.value) })}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ >
+ {FONT_SIZES.map((size) => (
+ <option key={size} value={size}>
+ {size}px
+ </option>
+ ))}
+ </select>
+ </div>
+ </div>
+
+ <div className="flex gap-1">
+ <button
+ onClick={toggleBold}
+ className={`p-2 rounded-md transition-colors ${
+ layer.style.fontWeight >= 700
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title="Bold"
+ >
+ <Bold size={14} />
+ </button>
+ <button
+ onClick={toggleItalic}
+ className={`p-2 rounded-md transition-colors ${
+ layer.style.fontStyle === 'italic'
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title="Italic"
+ >
+ <Italic size={14} />
+ </button>
+ <button
+ onClick={toggleUnderline}
+ className={`p-2 rounded-md transition-colors ${
+ layer.style.textDecoration === 'underline'
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title="Underline"
+ >
+ <Underline size={14} />
+ </button>
+
+ <div className="w-px bg-border mx-1" />
+
+ <button
+ onClick={() => handleStyleChange({ textAlign: 'left' })}
+ className={`p-2 rounded-md transition-colors ${
+ layer.style.textAlign === 'left'
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title="Align Left"
+ >
+ <AlignLeft size={14} />
+ </button>
+ <button
+ onClick={() => handleStyleChange({ textAlign: 'center' })}
+ className={`p-2 rounded-md transition-colors ${
+ layer.style.textAlign === 'center'
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title="Align Center"
+ >
+ <AlignCenter size={14} />
+ </button>
+ <button
+ onClick={() => handleStyleChange({ textAlign: 'right' })}
+ className={`p-2 rounded-md transition-colors ${
+ layer.style.textAlign === 'right'
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ title="Align Right"
+ >
+ <AlignRight size={14} />
+ </button>
+ </div>
+
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Color</label>
+ <div className="flex items-center gap-2">
+ <input
+ type="color"
+ value={layer.style.color}
+ onChange={(e) => handleStyleChange({ color: e.target.value })}
+ className="w-8 h-8 rounded border border-input cursor-pointer"
+ />
+ <input
+ type="text"
+ value={layer.style.color}
+ onChange={(e) => handleStyleChange({ color: e.target.value })}
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary font-mono"
+ />
+ </div>
+ </div>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Line Height</label>
+ <input
+ type="number"
+ value={layer.style.lineHeight}
+ onChange={(e) => handleStyleChange({ lineHeight: Number(e.target.value) })}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ step={0.1}
+ min={0.5}
+ max={3}
+ />
+ </div>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Letter Spacing</label>
+ <input
+ type="number"
+ value={layer.style.letterSpacing}
+ onChange={(e) => handleStyleChange({ letterSpacing: Number(e.target.value) })}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ step={0.1}
+ />
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/inspector/TransformSection.tsx b/apps/image/src/components/editor/inspector/TransformSection.tsx
new file mode 100644
index 00000000..f57c63dc
--- /dev/null
+++ b/apps/image/src/components/editor/inspector/TransformSection.tsx
@@ -0,0 +1,97 @@
+import { useProjectStore } from '../../../stores/project-store';
+import type { Layer } from '../../../types/project';
+
+interface Props {
+ layer: Layer;
+}
+
+export function TransformSection({ layer }: Props) {
+ const { updateLayerTransform } = useProjectStore();
+
+ const { x, y, width, height, rotation, opacity } = layer.transform;
+
+ const handleChange = (key: string, value: number) => {
+ updateLayerTransform(layer.id, { [key]: value });
+ };
+
+ return (
+ <div className="space-y-3">
+ <h4 className="text-xs font-medium text-muted-foreground uppercase tracking-wide">
+ Transform
+ </h4>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">X</label>
+ <input
+ type="number"
+ value={Math.round(x)}
+ onChange={(e) => handleChange('x', Number(e.target.value))}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ />
+ </div>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Y</label>
+ <input
+ type="number"
+ value={Math.round(y)}
+ onChange={(e) => handleChange('y', Number(e.target.value))}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ />
+ </div>
+ </div>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Width</label>
+ <input
+ type="number"
+ value={Math.round(width)}
+ onChange={(e) => handleChange('width', Number(e.target.value))}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ min={1}
+ />
+ </div>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Height</label>
+ <input
+ type="number"
+ value={Math.round(height)}
+ onChange={(e) => handleChange('height', Number(e.target.value))}
+ className="w-full px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ min={1}
+ />
+ </div>
+ </div>
+
+ <div className="grid grid-cols-2 gap-2">
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Rotation</label>
+ <div className="flex items-center gap-1">
+ <input
+ type="number"
+ value={Math.round(rotation)}
+ onChange={(e) => handleChange('rotation', Number(e.target.value))}
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ />
+ <span className="text-xs text-muted-foreground">°</span>
+ </div>
+ </div>
+ <div>
+ <label className="block text-[10px] text-muted-foreground mb-1">Opacity</label>
+ <div className="flex items-center gap-1">
+ <input
+ type="number"
+ value={Math.round(opacity * 100)}
+ onChange={(e) => handleChange('opacity', Number(e.target.value) / 100)}
+ className="flex-1 px-2 py-1.5 text-xs bg-background border border-input rounded-md focus:outline-none focus:ring-1 focus:ring-primary"
+ min={0}
+ max={100}
+ />
+ <span className="text-xs text-muted-foreground">%</span>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/layers/LayerPanel.tsx b/apps/image/src/components/editor/layers/LayerPanel.tsx
new file mode 100644
index 00000000..d45acf90
--- /dev/null
+++ b/apps/image/src/components/editor/layers/LayerPanel.tsx
@@ -0,0 +1,164 @@
+import { Eye, EyeOff, Lock, Unlock, Trash2, Copy, ChevronUp, ChevronDown } from 'lucide-react';
+import { useProjectStore } from '../../../stores/project-store';
+import type { Layer } from '../../../types/project';
+
+export function LayerPanel() {
+ const {
+ project,
+ selectedLayerIds,
+ selectedArtboardId,
+ selectLayer,
+ updateLayer,
+ removeLayer,
+ duplicateLayer,
+ moveLayerUp,
+ moveLayerDown,
+ } = useProjectStore();
+
+ const artboard = project?.artboards.find((a) => a.id === selectedArtboardId);
+ const layers = artboard?.layerIds.map((id) => project?.layers[id]).filter(Boolean) as Layer[] ?? [];
+
+ const handleToggleVisibility = (layer: Layer, e: React.MouseEvent) => {
+ e.stopPropagation();
+ updateLayer(layer.id, { visible: !layer.visible });
+ };
+
+ const handleToggleLock = (layer: Layer, e: React.MouseEvent) => {
+ e.stopPropagation();
+ updateLayer(layer.id, { locked: !layer.locked });
+ };
+
+ const handleDelete = (layerId: string, e: React.MouseEvent) => {
+ e.stopPropagation();
+ removeLayer(layerId);
+ };
+
+ const handleDuplicate = (layerId: string, e: React.MouseEvent) => {
+ e.stopPropagation();
+ duplicateLayer(layerId);
+ };
+
+ const getLayerIcon = (type: Layer['type']) => {
+ switch (type) {
+ case 'image':
+ return '🖼️';
+ case 'text':
+ return 'T';
+ case 'shape':
+ return '◆';
+ case 'group':
+ return '📁';
+ default:
+ return '•';
+ }
+ };
+
+ return (
+ <div className="h-full flex flex-col">
+ <div className="flex items-center justify-between px-3 py-2 border-b border-border">
+ <h3 className="text-xs font-medium text-foreground">Layers</h3>
+ <span className="text-[10px] text-muted-foreground">
+ {layers.length} {layers.length === 1 ? 'layer' : 'layers'}
+ </span>
+ </div>
+
+ <div className="flex-1 overflow-y-auto">
+ {layers.length === 0 ? (
+ <div className="flex flex-col items-center justify-center h-full text-center p-4">
+ <p className="text-xs text-muted-foreground">No layers yet</p>
+ <p className="text-[10px] text-muted-foreground mt-1">
+ Add text, shapes, or images
+ </p>
+ </div>
+ ) : (
+ <div className="py-1">
+ {layers.map((layer) => {
+ const isSelected = selectedLayerIds.includes(layer.id);
+
+ return (
+ <div
+ key={layer.id}
+ onClick={() => selectLayer(layer.id)}
+ className={`group flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors ${
+ isSelected
+ ? 'bg-primary/20 border-l-2 border-primary'
+ : 'hover:bg-accent border-l-2 border-transparent'
+ }`}
+ >
+ <span
+ className={`w-5 h-5 flex items-center justify-center text-xs rounded ${
+ layer.type === 'text' ? 'font-bold' : ''
+ }`}
+ >
+ {getLayerIcon(layer.type)}
+ </span>
+
+ <span
+ className={`flex-1 text-xs truncate ${
+ layer.visible ? 'text-foreground' : 'text-muted-foreground'
+ } ${layer.locked ? 'italic' : ''}`}
+ >
+ {layer.name}
+ </span>
+
+ <div className="flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity">
+ <button
+ onClick={(e) => handleToggleVisibility(layer, e)}
+ className="p-1 rounded hover:bg-background text-muted-foreground hover:text-foreground"
+ title={layer.visible ? 'Hide' : 'Show'}
+ >
+ {layer.visible ? <Eye size={12} /> : <EyeOff size={12} />}
+ </button>
+
+ <button
+ onClick={(e) => handleToggleLock(layer, e)}
+ className="p-1 rounded hover:bg-background text-muted-foreground hover:text-foreground"
+ title={layer.locked ? 'Unlock' : 'Lock'}
+ >
+ {layer.locked ? <Lock size={12} /> : <Unlock size={12} />}
+ </button>
+
+ <button
+ onClick={(e) => handleDuplicate(layer.id, e)}
+ className="p-1 rounded hover:bg-background text-muted-foreground hover:text-foreground"
+ title="Duplicate"
+ >
+ <Copy size={12} />
+ </button>
+
+ <button
+ onClick={(e) => handleDelete(layer.id, e)}
+ className="p-1 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive"
+ title="Delete"
+ >
+ <Trash2 size={12} />
+ </button>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ )}
+ </div>
+
+ {selectedLayerIds.length === 1 && (
+ <div className="flex items-center justify-center gap-1 p-2 border-t border-border">
+ <button
+ onClick={() => moveLayerUp(selectedLayerIds[0])}
+ className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground"
+ title="Move up (Cmd+])"
+ >
+ <ChevronUp size={14} />
+ </button>
+ <button
+ onClick={() => moveLayerDown(selectedLayerIds[0])}
+ className="p-1.5 rounded hover:bg-accent text-muted-foreground hover:text-foreground"
+ title="Move down (Cmd+[)"
+ >
+ <ChevronDown size={14} />
+ </button>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/panels/LeftPanel.tsx b/apps/image/src/components/editor/panels/LeftPanel.tsx
new file mode 100644
index 00000000..d45fdc29
--- /dev/null
+++ b/apps/image/src/components/editor/panels/LeftPanel.tsx
@@ -0,0 +1,311 @@
+import { useState } from 'react';
+import {
+ Layers,
+ Image,
+ LayoutTemplate,
+ Type,
+ Shapes,
+ Upload,
+ Search,
+ Plus,
+ Folder,
+} from 'lucide-react';
+import { useUIStore, Panel } from '../../../stores/ui-store';
+import { useProjectStore } from '../../../stores/project-store';
+
+const panels: { id: Panel; icon: React.ElementType; label: string }[] = [
+ { id: 'layers', icon: Layers, label: 'Layers' },
+ { id: 'assets', icon: Image, label: 'Assets' },
+ { id: 'templates', icon: LayoutTemplate, label: 'Templates' },
+ { id: 'text', icon: Type, label: 'Text' },
+ { id: 'shapes', icon: Shapes, label: 'Shapes' },
+ { id: 'uploads', icon: Upload, label: 'Uploads' },
+];
+
+export function LeftPanel() {
+ const { activePanel, setActivePanel } = useUIStore();
+
+ return (
+ <div className="h-full flex">
+ <div className="w-14 bg-background border-r border-border flex flex-col py-2">
+ {panels.map((panel) => {
+ const Icon = panel.icon;
+ return (
+ <button
+ key={panel.id}
+ onClick={() => setActivePanel(panel.id)}
+ className={`flex flex-col items-center justify-center py-3 transition-colors ${
+ activePanel === panel.id
+ ? 'text-primary bg-primary/10'
+ : 'text-muted-foreground hover:text-foreground hover:bg-accent'
+ }`}
+ title={panel.label}
+ >
+ <Icon size={20} />
+ <span className="text-[10px] mt-1 font-medium">{panel.label}</span>
+ </button>
+ );
+ })}
+ </div>
+
+ <div className="flex-1 overflow-hidden">
+ {activePanel === 'layers' && <LayersPanel />}
+ {activePanel === 'assets' && <AssetsPanel />}
+ {activePanel === 'templates' && <TemplatesPanel />}
+ {activePanel === 'text' && <TextPanel />}
+ {activePanel === 'shapes' && <ShapesPanel />}
+ {activePanel === 'uploads' && <UploadsPanel />}
+ </div>
+ </div>
+ );
+}
+
+function LayersPanel() {
+ return (
+ <div className="p-3">
+ <div className="flex items-center justify-between mb-3">
+ <h3 className="text-sm font-medium text-foreground">Layers</h3>
+ <button className="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent">
+ <Plus size={16} />
+ </button>
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Layers appear here when you add elements to the canvas.
+ </p>
+ </div>
+ );
+}
+
+function AssetsPanel() {
+ const { project } = useProjectStore();
+ const assets = project ? Object.values(project.assets) : [];
+
+ return (
+ <div className="p-3">
+ <div className="mb-3">
+ <div className="relative">
+ <Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" />
+ <input
+ type="text"
+ placeholder="Search assets..."
+ className="w-full pl-9 pr-3 py-2 text-sm bg-background border border-input rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"
+ />
+ </div>
+ </div>
+
+ {assets.length === 0 ? (
+ <div className="text-center py-8">
+ <Folder size={32} className="mx-auto text-muted-foreground mb-2" />
+ <p className="text-xs text-muted-foreground">No assets yet</p>
+ <p className="text-xs text-muted-foreground mt-1">Upload images to use in your design</p>
+ </div>
+ ) : (
+ <div className="grid grid-cols-2 gap-2">
+ {assets.map((asset) => (
+ <button
+ key={asset.id}
+ className="aspect-square rounded-lg bg-muted overflow-hidden hover:ring-2 hover:ring-primary transition-all"
+ >
+ <img
+ src={asset.thumbnailUrl}
+ alt={asset.name}
+ className="w-full h-full object-cover"
+ />
+ </button>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
+
+function TemplatesPanel() {
+ return (
+ <div className="p-3">
+ <div className="mb-3">
+ <div className="relative">
+ <Search size={16} className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground" />
+ <input
+ type="text"
+ placeholder="Search templates..."
+ className="w-full pl-9 pr-3 py-2 text-sm bg-background border border-input rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"
+ />
+ </div>
+ </div>
+
+ <div className="text-center py-8">
+ <LayoutTemplate size={32} className="mx-auto text-muted-foreground mb-2" />
+ <p className="text-xs text-muted-foreground">Templates coming soon</p>
+ </div>
+ </div>
+ );
+}
+
+function TextPanel() {
+ const { addTextLayer } = useProjectStore();
+
+ const textStyles = [
+ { label: 'Add a heading', fontSize: 48, fontWeight: 700 },
+ { label: 'Add a subheading', fontSize: 32, fontWeight: 600 },
+ { label: 'Add body text', fontSize: 18, fontWeight: 400 },
+ { label: 'Add a caption', fontSize: 14, fontWeight: 400 },
+ ];
+
+ return (
+ <div className="p-3">
+ <h3 className="text-sm font-medium text-foreground mb-3">Add Text</h3>
+ <div className="space-y-2">
+ {textStyles.map((style) => (
+ <button
+ key={style.label}
+ onClick={() => addTextLayer(style.label)}
+ className="w-full p-3 text-left rounded-lg bg-background border border-border hover:border-primary hover:bg-primary/5 transition-all"
+ >
+ <span
+ className="block text-foreground"
+ style={{ fontSize: `${Math.min(style.fontSize / 3, 16)}px`, fontWeight: style.fontWeight }}
+ >
+ {style.label}
+ </span>
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+function ShapesPanel() {
+ const { addShapeLayer } = useProjectStore();
+
+ const shapes: { type: 'rectangle' | 'ellipse' | 'triangle' | 'polygon' | 'star' | 'line'; label: string }[] = [
+ { type: 'rectangle', label: 'Rectangle' },
+ { type: 'ellipse', label: 'Circle' },
+ { type: 'triangle', label: 'Triangle' },
+ { type: 'polygon', label: 'Polygon' },
+ { type: 'star', label: 'Star' },
+ { type: 'line', label: 'Line' },
+ ];
+
+ return (
+ <div className="p-3">
+ <h3 className="text-sm font-medium text-foreground mb-3">Shapes</h3>
+ <div className="grid grid-cols-3 gap-2">
+ {shapes.map((shape) => (
+ <button
+ key={shape.type}
+ onClick={() => addShapeLayer(shape.type)}
+ className="aspect-square flex flex-col items-center justify-center rounded-lg bg-background border border-border hover:border-primary hover:bg-primary/5 transition-all"
+ >
+ <Shapes size={24} className="text-muted-foreground mb-1" />
+ <span className="text-[10px] text-muted-foreground">{shape.label}</span>
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+function UploadsPanel() {
+ const { addAsset } = useProjectStore();
+ const [isDragging, setIsDragging] = useState(false);
+
+ const handleDrop = async (e: React.DragEvent) => {
+ e.preventDefault();
+ setIsDragging(false);
+
+ const files = Array.from(e.dataTransfer.files).filter((f) =>
+ f.type.startsWith('image/')
+ );
+
+ for (const file of files) {
+ const reader = new FileReader();
+ reader.onload = () => {
+ const img = new window.Image();
+ img.onload = () => {
+ addAsset({
+ id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
+ name: file.name,
+ type: 'image',
+ mimeType: file.type,
+ size: file.size,
+ width: img.width,
+ height: img.height,
+ thumbnailUrl: reader.result as string,
+ dataUrl: reader.result as string,
+ });
+ };
+ img.src = reader.result as string;
+ };
+ reader.readAsDataURL(file);
+ }
+ };
+
+ const handleFileInput = (e: React.ChangeEvent<HTMLInputElement>) => {
+ const files = e.target.files;
+ if (!files) return;
+
+ Array.from(files).forEach((file) => {
+ const reader = new FileReader();
+ reader.onload = () => {
+ const img = new window.Image();
+ img.onload = () => {
+ addAsset({
+ id: `${Date.now()}-${Math.random().toString(36).slice(2)}`,
+ name: file.name,
+ type: 'image',
+ mimeType: file.type,
+ size: file.size,
+ width: img.width,
+ height: img.height,
+ thumbnailUrl: reader.result as string,
+ dataUrl: reader.result as string,
+ });
+ };
+ img.src = reader.result as string;
+ };
+ reader.readAsDataURL(file);
+ });
+ };
+
+ return (
+ <div className="p-3">
+ <h3 className="text-sm font-medium text-foreground mb-3">Upload Files</h3>
+
+ <div
+ onDragOver={(e) => {
+ e.preventDefault();
+ setIsDragging(true);
+ }}
+ onDragLeave={() => setIsDragging(false)}
+ onDrop={handleDrop}
+ className={`border-2 border-dashed rounded-xl p-6 text-center transition-all ${
+ isDragging
+ ? 'border-primary bg-primary/10'
+ : 'border-border hover:border-muted-foreground'
+ }`}
+ >
+ <Upload size={32} className="mx-auto text-muted-foreground mb-3" />
+ <p className="text-sm text-foreground mb-1">
+ Drag & drop files here
+ </p>
+ <p className="text-xs text-muted-foreground mb-3">
+ or click to browse
+ </p>
+ <label className="inline-block px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium cursor-pointer hover:bg-primary/90 transition-colors">
+ Browse Files
+ <input
+ type="file"
+ accept="image/*"
+ multiple
+ onChange={handleFileInput}
+ className="hidden"
+ />
+ </label>
+ </div>
+
+ <p className="text-xs text-muted-foreground mt-3 text-center">
+ Supports PNG, JPG, SVG, WebP
+ </p>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/editor/toolbar/Toolbar.tsx b/apps/image/src/components/editor/toolbar/Toolbar.tsx
new file mode 100644
index 00000000..feba8b5a
--- /dev/null
+++ b/apps/image/src/components/editor/toolbar/Toolbar.tsx
@@ -0,0 +1,176 @@
+import {
+ MousePointer2,
+ Hand,
+ Type,
+ Square,
+ PenTool,
+ Pipette,
+ ZoomIn,
+ Undo2,
+ Redo2,
+ Download,
+ PanelLeftClose,
+ PanelRightClose,
+ Home,
+ ChevronDown,
+} from 'lucide-react';
+import { useUIStore, Tool } from '../../../stores/ui-store';
+import { useProjectStore } from '../../../stores/project-store';
+import { useHistoryStore } from '../../../stores/history-store';
+
+const tools: { id: Tool; icon: React.ElementType; label: string; shortcut: string }[] = [
+ { id: 'select', icon: MousePointer2, label: 'Select', shortcut: 'V' },
+ { id: 'hand', icon: Hand, label: 'Hand', shortcut: 'H' },
+ { id: 'text', icon: Type, label: 'Text', shortcut: 'T' },
+ { id: 'shape', icon: Square, label: 'Shape', shortcut: 'S' },
+ { id: 'pen', icon: PenTool, label: 'Pen', shortcut: 'P' },
+ { id: 'eyedropper', icon: Pipette, label: 'Eyedropper', shortcut: 'I' },
+ { id: 'zoom', icon: ZoomIn, label: 'Zoom', shortcut: 'Z' },
+];
+
+export function Toolbar() {
+ const {
+ activeTool,
+ setActiveTool,
+ zoom,
+ zoomIn,
+ zoomOut,
+ togglePanelCollapsed,
+ toggleInspectorCollapsed,
+ setCurrentView,
+ } = useUIStore();
+
+ const { project, setProjectName } = useProjectStore();
+ const { canUndo, canRedo, undo, redo } = useHistoryStore();
+
+ const handleUndo = () => {
+ const state = undo();
+ if (state) {
+ useProjectStore.getState().loadProject(state);
+ }
+ };
+
+ const handleRedo = () => {
+ const state = redo();
+ if (state) {
+ useProjectStore.getState().loadProject(state);
+ }
+ };
+
+ return (
+ <div className="h-12 bg-card border-b border-border flex items-center px-3 gap-2">
+ <button
+ onClick={() => setCurrentView('welcome')}
+ className="p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
+ title="Home"
+ >
+ <Home size={18} />
+ </button>
+
+ <div className="w-px h-6 bg-border mx-1" />
+
+ <button
+ onClick={togglePanelCollapsed}
+ className="p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
+ title="Toggle left panel"
+ >
+ <PanelLeftClose size={18} />
+ </button>
+
+ <div className="w-px h-6 bg-border mx-1" />
+
+ <div className="flex items-center">
+ <input
+ type="text"
+ value={project?.name ?? 'Untitled'}
+ onChange={(e) => setProjectName(e.target.value)}
+ className="w-48 px-3 py-1.5 text-sm font-medium bg-transparent border border-transparent hover:border-border focus:border-primary focus:outline-none rounded-lg text-foreground"
+ />
+ <ChevronDown size={14} className="text-muted-foreground -ml-6" />
+ </div>
+
+ <div className="flex-1" />
+
+ <div className="flex items-center gap-1 bg-secondary/50 rounded-lg p-1">
+ {tools.map((tool) => {
+ const Icon = tool.icon;
+ return (
+ <button
+ key={tool.id}
+ onClick={() => setActiveTool(tool.id)}
+ className={`p-2 rounded-md transition-all ${
+ activeTool === tool.id
+ ? 'bg-primary text-primary-foreground shadow-sm'
+ : 'text-muted-foreground hover:text-foreground hover:bg-accent'
+ }`}
+ title={`${tool.label} (${tool.shortcut})`}
+ >
+ <Icon size={18} />
+ </button>
+ );
+ })}
+ </div>
+
+ <div className="flex-1" />
+
+ <div className="flex items-center gap-1">
+ <button
+ onClick={handleUndo}
+ disabled={!canUndo()}
+ className="p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-40 disabled:cursor-not-allowed"
+ title="Undo (Ctrl+Z)"
+ >
+ <Undo2 size={18} />
+ </button>
+ <button
+ onClick={handleRedo}
+ disabled={!canRedo()}
+ className="p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-40 disabled:cursor-not-allowed"
+ title="Redo (Ctrl+Shift+Z)"
+ >
+ <Redo2 size={18} />
+ </button>
+ </div>
+
+ <div className="w-px h-6 bg-border mx-1" />
+
+ <div className="flex items-center gap-2">
+ <button
+ onClick={zoomOut}
+ className="p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
+ title="Zoom out"
+ >
+ <span className="text-xs font-medium">-</span>
+ </button>
+ <span className="text-xs font-medium text-muted-foreground w-12 text-center">
+ {Math.round(zoom * 100)}%
+ </span>
+ <button
+ onClick={zoomIn}
+ className="p-1.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
+ title="Zoom in"
+ >
+ <span className="text-xs font-medium">+</span>
+ </button>
+ </div>
+
+ <div className="w-px h-6 bg-border mx-1" />
+
+ <button
+ onClick={() => {}}
+ className="flex items-center gap-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 active:scale-[0.98] transition-all"
+ >
+ <Download size={16} />
+ Export
+ </button>
+
+ <button
+ onClick={toggleInspectorCollapsed}
+ className="p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
+ title="Toggle right panel"
+ >
+ <PanelRightClose size={18} />
+ </button>
+ </div>
+ );
+}
diff --git a/apps/image/src/components/welcome/WelcomeScreen.tsx b/apps/image/src/components/welcome/WelcomeScreen.tsx
new file mode 100644
index 00000000..5c341f6f
--- /dev/null
+++ b/apps/image/src/components/welcome/WelcomeScreen.tsx
@@ -0,0 +1,186 @@
+import { useState } from 'react';
+import { Plus, FolderOpen, Image, Layout, FileText, Presentation, Smartphone, Monitor, Star } from 'lucide-react';
+import { useProjectStore } from '../../stores/project-store';
+import { useUIStore } from '../../stores/ui-store';
+import { CANVAS_PRESETS } from '../../types/project';
+
+type Category = 'all' | 'Social Media' | 'Presentation' | 'Print' | 'Desktop' | 'Mobile' | 'Logo';
+
+const categories: { id: Category; label: string; icon: React.ElementType }[] = [
+ { id: 'all', label: 'All', icon: Layout },
+ { id: 'Social Media', label: 'Social Media', icon: Star },
+ { id: 'Presentation', label: 'Presentation', icon: Presentation },
+ { id: 'Print', label: 'Print', icon: FileText },
+ { id: 'Desktop', label: 'Desktop', icon: Monitor },
+ { id: 'Mobile', label: 'Mobile', icon: Smartphone },
+ { id: 'Logo', label: 'Logo', icon: Image },
+];
+
+export function WelcomeScreen() {
+ const [selectedCategory, setSelectedCategory] = useState<Category>('all');
+ const [customWidth, setCustomWidth] = useState(1920);
+ const [customHeight, setCustomHeight] = useState(1080);
+ const [showCustomSize, setShowCustomSize] = useState(false);
+
+ const { createProject } = useProjectStore();
+ const { setCurrentView } = useUIStore();
+
+ const filteredPresets = selectedCategory === 'all'
+ ? CANVAS_PRESETS
+ : CANVAS_PRESETS.filter((p) => p.category === selectedCategory);
+
+ const handleCreateProject = (width: number, height: number, name: string) => {
+ createProject(name, { width, height });
+ setCurrentView('editor');
+ };
+
+ const handleCreateCustom = () => {
+ createProject('Untitled Design', { width: customWidth, height: customHeight });
+ setCurrentView('editor');
+ };
+
+ return (
+ <div className="h-full w-full bg-background flex flex-col">
+ <header className="flex items-center justify-between px-8 py-6 border-b border-border">
+ <div className="flex items-center gap-3">
+ <div className="w-10 h-10 bg-primary rounded-xl flex items-center justify-center">
+ <Image size={20} className="text-primary-foreground" />
+ </div>
+ <div>
+ <h1 className="text-xl font-semibold text-foreground">OpenReel Image</h1>
+ <p className="text-sm text-muted-foreground">Professional Graphic Design Editor</p>
+ </div>
+ </div>
+ <button
+ onClick={() => {}}
+ className="flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-accent transition-colors"
+ >
+ <FolderOpen size={18} />
+ Open Project
+ </button>
+ </header>
+
+ <div className="flex-1 overflow-auto">
+ <div className="max-w-6xl mx-auto px-8 py-8">
+ <section className="mb-10">
+ <h2 className="text-lg font-semibold text-foreground mb-4">Start a new project</h2>
+
+ <div className="flex gap-2 mb-6 flex-wrap">
+ {categories.map((cat) => {
+ const Icon = cat.icon;
+ return (
+ <button
+ key={cat.id}
+ onClick={() => setSelectedCategory(cat.id)}
+ className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all ${
+ selectedCategory === cat.id
+ ? 'bg-primary text-primary-foreground'
+ : 'bg-secondary text-secondary-foreground hover:bg-accent'
+ }`}
+ >
+ <Icon size={16} />
+ {cat.label}
+ </button>
+ );
+ })}
+ </div>
+
+ <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
+ <button
+ onClick={() => setShowCustomSize(!showCustomSize)}
+ className="group flex flex-col items-center justify-center p-6 rounded-xl border-2 border-dashed border-border hover:border-primary hover:bg-primary/5 transition-all aspect-square"
+ >
+ <div className="w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mb-3 group-hover:bg-primary/20 transition-colors">
+ <Plus size={24} className="text-primary" />
+ </div>
+ <span className="text-sm font-medium text-foreground">Custom Size</span>
+ <span className="text-xs text-muted-foreground mt-1">Set dimensions</span>
+ </button>
+
+ {filteredPresets.map((preset) => (
+ <button
+ key={preset.name}
+ onClick={() => handleCreateProject(preset.width, preset.height, preset.name)}
+ className="group flex flex-col items-center justify-center p-6 rounded-xl border border-border bg-card hover:border-primary hover:shadow-md transition-all aspect-square"
+ >
+ <div
+ className="bg-muted rounded-lg mb-3 flex items-center justify-center"
+ style={{
+ width: Math.min(80, (preset.width / Math.max(preset.width, preset.height)) * 80),
+ height: Math.min(80, (preset.height / Math.max(preset.width, preset.height)) * 80),
+ }}
+ >
+ <Layout size={20} className="text-muted-foreground" />
+ </div>
+ <span className="text-sm font-medium text-foreground text-center">{preset.name}</span>
+ <span className="text-xs text-muted-foreground mt-1">
+ {preset.width} × {preset.height}
+ </span>
+ </button>
+ ))}
+ </div>
+ </section>
+
+ {showCustomSize && (
+ <section className="mb-10 p-6 rounded-xl bg-card border border-border">
+ <h3 className="text-base font-medium text-foreground mb-4">Custom Dimensions</h3>
+ <div className="flex items-end gap-4">
+ <div>
+ <label className="block text-sm text-muted-foreground mb-2">Width (px)</label>
+ <input
+ type="number"
+ value={customWidth}
+ onChange={(e) => setCustomWidth(Number(e.target.value))}
+ className="w-32 px-3 py-2.5 rounded-lg bg-background border border-input text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"
+ min={1}
+ max={8000}
+ />
+ </div>
+ <span className="text-muted-foreground pb-2.5">×</span>
+ <div>
+ <label className="block text-sm text-muted-foreground mb-2">Height (px)</label>
+ <input
+ type="number"
+ value={customHeight}
+ onChange={(e) => setCustomHeight(Number(e.target.value))}
+ className="w-32 px-3 py-2.5 rounded-lg bg-background border border-input text-sm focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary"
+ min={1}
+ max={8000}
+ />
+ </div>
+ <button
+ onClick={handleCreateCustom}
+ className="px-6 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 active:scale-[0.98] transition-all"
+ >
+ Create Design
+ </button>
+ </div>
+ </section>
+ )}
+
+ <section>
+ <h2 className="text-lg font-semibold text-foreground mb-4">Recent Projects</h2>
+ <div className="flex flex-col items-center justify-center py-16 text-center">
+ <div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4">
+ <FolderOpen size={28} className="text-muted-foreground" />
+ </div>
+ <p className="text-muted-foreground mb-2">No recent projects</p>
+ <p className="text-sm text-muted-foreground/70">
+ Create a new project to get started
+ </p>
+ </div>
+ </section>
+ </div>
+ </div>
+
+ <footer className="px-8 py-4 border-t border-border flex items-center justify-between">
+ <p className="text-xs text-muted-foreground">
+ OpenReel Image — Professional graphic design in your browser
+ </p>
+ <p className="text-xs text-muted-foreground">
+ 100% offline • No account required
+ </p>
+ </footer>
+ </div>
+ );
+}
diff --git a/apps/image/src/hooks/useAutoSave.ts b/apps/image/src/hooks/useAutoSave.ts
new file mode 100644
index 00000000..7e57ff6f
--- /dev/null
+++ b/apps/image/src/hooks/useAutoSave.ts
@@ -0,0 +1,69 @@
+import { useEffect, useRef } from 'react';
+import { useProjectStore } from '../stores/project-store';
+import { useHistoryStore } from '../stores/history-store';
+
+const AUTO_SAVE_DELAY = 2000;
+const STORAGE_KEY_PREFIX = 'openreel-image-project-';
+
+export function useAutoSave() {
+ const { project, isDirty, markClean } = useProjectStore();
+ const { pushState } = useHistoryStore();
+ const lastSavedRef = useRef<string>('');
+ const timeoutRef = useRef<number>();
+
+ useEffect(() => {
+ if (!project || !isDirty) return;
+
+ const projectJson = JSON.stringify(project);
+ if (projectJson === lastSavedRef.current) return;
+
+ if (timeoutRef.current) {
+ clearTimeout(timeoutRef.current);
+ }
+
+ timeoutRef.current = window.setTimeout(() => {
+ try {
+ localStorage.setItem(`${STORAGE_KEY_PREFIX}${project.id}`, projectJson);
+ lastSavedRef.current = projectJson;
+ markClean();
+
+ pushState(project, 'Auto-save');
+ } catch (error) {
+ console.error('Failed to auto-save:', error);
+ }
+ }, AUTO_SAVE_DELAY);
+
+ return () => {
+ if (timeoutRef.current) {
+ clearTimeout(timeoutRef.current);
+ }
+ };
+ }, [project, isDirty, markClean, pushState]);
+}
+
+export function loadSavedProject(projectId: string) {
+ try {
+ const json = localStorage.getItem(`${STORAGE_KEY_PREFIX}${projectId}`);
+ if (json) {
+ return JSON.parse(json);
+ }
+ } catch (error) {
+ console.error('Failed to load saved project:', error);
+ }
+ return null;
+}
+
+export function getSavedProjectIds(): string[] {
+ const ids: string[] = [];
+ for (let i = 0; i < localStorage.length; i++) {
+ const key = localStorage.key(i);
+ if (key?.startsWith(STORAGE_KEY_PREFIX)) {
+ ids.push(key.replace(STORAGE_KEY_PREFIX, ''));
+ }
+ }
+ return ids;
+}
+
+export function deleteSavedProject(projectId: string): void {
+ localStorage.removeItem(`${STORAGE_KEY_PREFIX}${projectId}`);
+}
diff --git a/apps/image/src/index.css b/apps/image/src/index.css
new file mode 100644
index 00000000..adce43b2
--- /dev/null
+++ b/apps/image/src/index.css
@@ -0,0 +1,188 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+@layer base {
+ :root {
+ --background: 0 0% 100%;
+ --foreground: 0 0% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 0 0% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 0 0% 3.9%;
+ --primary: 142.1 76.2% 36.3%;
+ --primary-foreground: 355.7 100% 97.3%;
+ --secondary: 240 4.8% 95.9%;
+ --secondary-foreground: 240 5.9% 10%;
+ --muted: 240 4.8% 95.9%;
+ --muted-foreground: 240 3.8% 46.1%;
+ --accent: 240 4.8% 95.9%;
+ --accent-foreground: 240 5.9% 10%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 5.9% 90%;
+ --input: 240 5.9% 90%;
+ --ring: 142.1 76.2% 36.3%;
+ --radius: 0.5rem;
+
+ --color-background-secondary: 250 250 250;
+ --color-background-tertiary: 245 245 245;
+ --color-background-elevated: 255 255 255;
+ --color-text-primary: 10 10 10;
+ --color-text-secondary: 115 115 115;
+ --color-text-muted: 163 163 163;
+ --color-border-hover: 212 212 212;
+ --color-border-active: 163 163 163;
+ }
+
+ .dark {
+ --background: 0 0% 7%;
+ --foreground: 0 0% 95%;
+ --card: 0 0% 9%;
+ --card-foreground: 0 0% 95%;
+ --popover: 0 0% 9%;
+ --popover-foreground: 0 0% 95%;
+ --primary: 142.1 70.6% 45.3%;
+ --primary-foreground: 144.9 80.4% 10%;
+ --secondary: 240 3.7% 15.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 15%;
+ --muted-foreground: 240 5% 64.9%;
+ --accent: 0 0% 15%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 50.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 240 3.7% 20%;
+ --input: 240 3.7% 20%;
+ --ring: 142.1 70.6% 45.3%;
+
+ --color-background-secondary: 23 23 23;
+ --color-background-tertiary: 38 38 38;
+ --color-background-elevated: 32 32 32;
+ --color-text-primary: 250 250 250;
+ --color-text-secondary: 163 163 163;
+ --color-text-muted: 115 115 115;
+ --color-border-hover: 64 64 64;
+ --color-border-active: 82 82 82;
+ }
+}
+
+@layer base {
+ * {
+ @apply border-border;
+ }
+
+ body {
+ @apply bg-background text-foreground;
+ font-feature-settings: "rlig" 1, "calt" 1;
+ }
+}
+
+html, body, #root {
+ height: 100%;
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ overflow: hidden;
+}
+
+body {
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+::-webkit-scrollbar {
+ width: 8px;
+ height: 8px;
+}
+
+::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+::-webkit-scrollbar-thumb {
+ background: hsl(var(--muted-foreground) / 0.3);
+ border-radius: 4px;
+}
+
+::-webkit-scrollbar-thumb:hover {
+ background: hsl(var(--muted-foreground) / 0.5);
+}
+
+::selection {
+ background: hsl(var(--primary) / 0.3);
+}
+
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
+input[type="number"] {
+ -moz-appearance: textfield;
+}
+
+.canvas-container {
+ background-image:
+ linear-gradient(45deg, hsl(var(--muted)) 25%, transparent 25%),
+ linear-gradient(-45deg, hsl(var(--muted)) 25%, transparent 25%),
+ linear-gradient(45deg, transparent 75%, hsl(var(--muted)) 75%),
+ linear-gradient(-45deg, transparent 75%, hsl(var(--muted)) 75%);
+ background-size: 20px 20px;
+ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
+}
+
+.layer-drag-ghost {
+ opacity: 0.8;
+ background: hsl(var(--primary) / 0.2);
+ border: 2px dashed hsl(var(--primary));
+ border-radius: var(--radius);
+}
+
+.resize-handle {
+ width: 10px;
+ height: 10px;
+ background: white;
+ border: 2px solid hsl(var(--primary));
+ border-radius: 2px;
+ position: absolute;
+ cursor: pointer;
+}
+
+.resize-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
+.resize-handle-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
+.resize-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
+.resize-handle-e { top: 50%; right: -5px; transform: translateY(-50%); cursor: ew-resize; }
+.resize-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
+.resize-handle-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
+.resize-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
+.resize-handle-w { top: 50%; left: -5px; transform: translateY(-50%); cursor: ew-resize; }
+
+.rotation-handle {
+ width: 12px;
+ height: 12px;
+ background: white;
+ border: 2px solid hsl(var(--primary));
+ border-radius: 50%;
+ position: absolute;
+ top: -30px;
+ left: 50%;
+ transform: translateX(-50%);
+ cursor: grab;
+}
+
+.rotation-handle:active {
+ cursor: grabbing;
+}
+
+@keyframes pulse-selection {
+ 0%, 100% { box-shadow: 0 0 0 2px hsl(var(--primary)); }
+ 50% { box-shadow: 0 0 0 4px hsl(var(--primary) / 0.5); }
+}
+
+.selection-box {
+ border: 2px solid hsl(var(--primary));
+ animation: pulse-selection 2s ease-in-out infinite;
+}
diff --git a/apps/image/src/main.tsx b/apps/image/src/main.tsx
new file mode 100644
index 00000000..2339d59c
--- /dev/null
+++ b/apps/image/src/main.tsx
@@ -0,0 +1,10 @@
+import React from 'react';
+import ReactDOM from 'react-dom/client';
+import App from './App';
+import './index.css';
+
+ReactDOM.createRoot(document.getElementById('root')!).render(
+ <React.StrictMode>
+ <App />
+ </React.StrictMode>
+);
diff --git a/apps/image/src/services/export-service.ts b/apps/image/src/services/export-service.ts
new file mode 100644
index 00000000..629fc522
--- /dev/null
+++ b/apps/image/src/services/export-service.ts
@@ -0,0 +1,262 @@
+import type { Project, Artboard, Layer, ImageLayer, TextLayer, ShapeLayer } from '../types/project';
+
+export type ExportFormat = 'png' | 'jpg' | 'webp' | 'svg' | 'pdf';
+export type ExportQuality = 'low' | 'medium' | 'high' | 'max';
+
+export interface ExportOptions {
+ format: ExportFormat;
+ quality: ExportQuality;
+ scale: number;
+ background: 'include' | 'transparent';
+ artboardIds?: string[];
+}
+
+const QUALITY_MAP: Record<ExportQuality, number> = {
+ low: 0.6,
+ medium: 0.8,
+ high: 0.92,
+ max: 1.0,
+};
+
+export async function exportProject(
+ project: Project,
+ options: ExportOptions,
+ onProgress?: (progress: number, message: string) => void
+): Promise<Blob[]> {
+ const blobs: Blob[] = [];
+ const artboards = options.artboardIds
+ ? project.artboards.filter((a) => options.artboardIds!.includes(a.id))
+ : project.artboards;
+
+ for (let i = 0; i < artboards.length; i++) {
+ const artboard = artboards[i];
+ onProgress?.((i / artboards.length) * 100, `Exporting ${artboard.name}...`);
+
+ const blob = await exportArtboard(project, artboard, options);
+ blobs.push(blob);
+ }
+
+ onProgress?.(100, 'Export complete');
+ return blobs;
+}
+
+export async function exportArtboard(
+ project: Project,
+ artboard: Artboard,
+ options: ExportOptions
+): Promise<Blob> {
+ const { scale, format, quality, background } = options;
+ const width = artboard.size.width * scale;
+ const height = artboard.size.height * scale;
+
+ const canvas = document.createElement('canvas');
+ canvas.width = width;
+ canvas.height = height;
+
+ const ctx = canvas.getContext('2d')!;
+ ctx.scale(scale, scale);
+
+ if (background === 'include' || format === 'jpg') {
+ if (artboard.background.type === 'color') {
+ ctx.fillStyle = artboard.background.color ?? '#ffffff';
+ ctx.fillRect(0, 0, artboard.size.width, artboard.size.height);
+ } else if (artboard.background.type === 'transparent' && format === 'jpg') {
+ ctx.fillStyle = '#ffffff';
+ ctx.fillRect(0, 0, artboard.size.width, artboard.size.height);
+ } else if (artboard.background.type === 'gradient' && artboard.background.gradient) {
+ const { gradient } = artboard.background;
+ const rad = (gradient.angle * Math.PI) / 180;
+ const x1 = artboard.size.width / 2 - Math.cos(rad) * artboard.size.width / 2;
+ const y1 = artboard.size.height / 2 - Math.sin(rad) * artboard.size.height / 2;
+ const x2 = artboard.size.width / 2 + Math.cos(rad) * artboard.size.width / 2;
+ const y2 = artboard.size.height / 2 + Math.sin(rad) * artboard.size.height / 2;
+
+ const grad = ctx.createLinearGradient(x1, y1, x2, y2);
+ gradient.stops.forEach((stop) => {
+ grad.addColorStop(stop.offset, stop.color);
+ });
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, artboard.size.width, artboard.size.height);
+ }
+ }
+
+ const sortedLayerIds = [...artboard.layerIds].reverse();
+ for (const layerId of sortedLayerIds) {
+ const layer = project.layers[layerId];
+ if (!layer || !layer.visible) continue;
+ await renderLayerToContext(ctx, layer, project);
+ }
+
+ const mimeType = format === 'jpg' ? 'image/jpeg' : format === 'webp' ? 'image/webp' : 'image/png';
+ const qualityValue = format === 'png' ? undefined : QUALITY_MAP[quality];
+
+ return new Promise((resolve) => {
+ canvas.toBlob(
+ (blob) => resolve(blob!),
+ mimeType,
+ qualityValue
+ );
+ });
+}
+
+async function renderLayerToContext(
+ ctx: CanvasRenderingContext2D,
+ layer: Layer,
+ project: Project
+): Promise<void> {
+ const { transform } = layer;
+
+ ctx.save();
+ ctx.translate(transform.x, transform.y);
+ ctx.rotate((transform.rotation * Math.PI) / 180);
+ ctx.scale(transform.scaleX, transform.scaleY);
+ ctx.globalAlpha = transform.opacity;
+
+ switch (layer.type) {
+ case 'image':
+ await renderImageLayerToContext(ctx, layer as ImageLayer, project);
+ break;
+ case 'text':
+ renderTextLayerToContext(ctx, layer as TextLayer);
+ break;
+ case 'shape':
+ renderShapeLayerToContext(ctx, layer as ShapeLayer);
+ break;
+ }
+
+ ctx.restore();
+}
+
+async function renderImageLayerToContext(
+ ctx: CanvasRenderingContext2D,
+ layer: ImageLayer,
+ project: Project
+): Promise<void> {
+ const asset = project.assets[layer.sourceId];
+ if (!asset) return;
+
+ const img = new Image();
+ img.crossOrigin = 'anonymous';
+
+ await new Promise<void>((resolve) => {
+ img.onload = () => {
+ ctx.drawImage(img, 0, 0, layer.transform.width, layer.transform.height);
+ resolve();
+ };
+ img.onerror = () => resolve();
+ img.src = asset.dataUrl ?? asset.blobUrl ?? '';
+ });
+}
+
+function renderTextLayerToContext(ctx: CanvasRenderingContext2D, layer: TextLayer): void {
+ const { style, content, transform } = layer;
+
+ ctx.fillStyle = style.color;
+ ctx.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;
+ ctx.textAlign = style.textAlign as CanvasTextAlign;
+ ctx.textBaseline = 'top';
+
+ const lines = content.split('\n');
+ const lineHeight = style.fontSize * style.lineHeight;
+
+ let textX = 0;
+ if (style.textAlign === 'center') textX = transform.width / 2;
+ else if (style.textAlign === 'right') textX = transform.width;
+
+ lines.forEach((line, i) => {
+ ctx.fillText(line, textX, i * lineHeight);
+ });
+}
+
+function renderShapeLayerToContext(ctx: CanvasRenderingContext2D, layer: ShapeLayer): void {
+ const { shapeType, shapeStyle, transform } = layer;
+ const { width, height } = transform;
+
+ ctx.beginPath();
+
+ switch (shapeType) {
+ case 'rectangle':
+ if (shapeStyle.cornerRadius > 0) {
+ const r = Math.min(shapeStyle.cornerRadius, width / 2, height / 2);
+ ctx.moveTo(r, 0);
+ ctx.lineTo(width - r, 0);
+ ctx.quadraticCurveTo(width, 0, width, r);
+ ctx.lineTo(width, height - r);
+ ctx.quadraticCurveTo(width, height, width - r, height);
+ ctx.lineTo(r, height);
+ ctx.quadraticCurveTo(0, height, 0, height - r);
+ ctx.lineTo(0, r);
+ ctx.quadraticCurveTo(0, 0, r, 0);
+ } else {
+ ctx.rect(0, 0, width, height);
+ }
+ break;
+
+ case 'ellipse':
+ ctx.ellipse(width / 2, height / 2, width / 2, height / 2, 0, 0, Math.PI * 2);
+ break;
+
+ case 'triangle':
+ ctx.moveTo(width / 2, 0);
+ ctx.lineTo(width, height);
+ ctx.lineTo(0, height);
+ ctx.closePath();
+ break;
+
+ case 'star': {
+ const cx = width / 2;
+ const cy = height / 2;
+ const outerRadius = Math.min(width, height) / 2;
+ const innerRadius = outerRadius * 0.4;
+ const points = 5;
+ for (let i = 0; i < points * 2; i++) {
+ const radius = i % 2 === 0 ? outerRadius : innerRadius;
+ const angle = (i * Math.PI) / points - Math.PI / 2;
+ const px = cx + radius * Math.cos(angle);
+ const py = cy + radius * Math.sin(angle);
+ if (i === 0) ctx.moveTo(px, py);
+ else ctx.lineTo(px, py);
+ }
+ ctx.closePath();
+ break;
+ }
+
+ case 'line':
+ ctx.moveTo(0, height / 2);
+ ctx.lineTo(width, height / 2);
+ break;
+
+ default:
+ ctx.rect(0, 0, width, height);
+ }
+
+ if (shapeStyle.fill) {
+ ctx.fillStyle = shapeStyle.fill;
+ ctx.globalAlpha *= shapeStyle.fillOpacity;
+ ctx.fill();
+ ctx.globalAlpha /= shapeStyle.fillOpacity;
+ }
+
+ if (shapeStyle.stroke) {
+ ctx.strokeStyle = shapeStyle.stroke;
+ ctx.lineWidth = shapeStyle.strokeWidth;
+ ctx.globalAlpha *= shapeStyle.strokeOpacity;
+ ctx.stroke();
+ }
+}
+
+export function downloadBlob(blob: Blob, filename: string): void {
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = filename;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+}
+
+export function getExportFilename(projectName: string, artboardName: string, format: ExportFormat): string {
+ const safeName = `${projectName}-${artboardName}`.replace(/[^a-z0-9]/gi, '-').toLowerCase();
+ return `${safeName}.${format}`;
+}
diff --git a/apps/image/src/services/keyboard-service.ts b/apps/image/src/services/keyboard-service.ts
new file mode 100644
index 00000000..d5f392a3
--- /dev/null
+++ b/apps/image/src/services/keyboard-service.ts
@@ -0,0 +1,211 @@
+import { useEffect } from 'react';
+import { useUIStore } from '../stores/ui-store';
+import { useProjectStore } from '../stores/project-store';
+import { useHistoryStore } from '../stores/history-store';
+
+export function useKeyboardShortcuts() {
+ const { setActiveTool, zoomIn, zoomOut, zoomToFit, toggleGrid, toggleGuides } = useUIStore();
+ const {
+ selectedLayerIds,
+ removeLayer,
+ copyLayers,
+ cutLayers,
+ pasteLayers,
+ duplicateLayer,
+ selectAllLayers,
+ deselectAllLayers,
+ moveLayerUp,
+ moveLayerDown,
+ moveLayerToTop,
+ moveLayerToBottom,
+ groupLayers,
+ ungroupLayers,
+ project,
+ } = useProjectStore();
+ const { undo, redo, canUndo, canRedo } = useHistoryStore();
+
+ useEffect(() => {
+ const handleKeyDown = (e: KeyboardEvent) => {
+ const target = e.target as HTMLElement;
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
+ return;
+ }
+
+ const isMod = e.metaKey || e.ctrlKey;
+
+ if (!isMod && !e.shiftKey && !e.altKey) {
+ switch (e.key.toLowerCase()) {
+ case 'v':
+ setActiveTool('select');
+ break;
+ case 'h':
+ setActiveTool('hand');
+ break;
+ case 't':
+ setActiveTool('text');
+ break;
+ case 's':
+ setActiveTool('shape');
+ break;
+ case 'p':
+ setActiveTool('pen');
+ break;
+ case 'i':
+ setActiveTool('eyedropper');
+ break;
+ case 'z':
+ setActiveTool('zoom');
+ break;
+ case 'delete':
+ case 'backspace':
+ if (selectedLayerIds.length > 0) {
+ e.preventDefault();
+ selectedLayerIds.forEach((id) => removeLayer(id));
+ }
+ break;
+ }
+ }
+
+ if (isMod) {
+ switch (e.key.toLowerCase()) {
+ case 'z':
+ e.preventDefault();
+ if (e.shiftKey) {
+ if (canRedo()) {
+ const state = redo();
+ if (state) useProjectStore.getState().loadProject(state);
+ }
+ } else {
+ if (canUndo()) {
+ const state = undo();
+ if (state) useProjectStore.getState().loadProject(state);
+ }
+ }
+ break;
+
+ case 'c':
+ e.preventDefault();
+ copyLayers();
+ break;
+
+ case 'x':
+ e.preventDefault();
+ cutLayers();
+ break;
+
+ case 'v':
+ e.preventDefault();
+ pasteLayers();
+ break;
+
+ case 'd':
+ e.preventDefault();
+ if (selectedLayerIds.length > 0) {
+ selectedLayerIds.forEach((id) => duplicateLayer(id));
+ }
+ break;
+
+ case 'a':
+ e.preventDefault();
+ selectAllLayers();
+ break;
+
+ case 'g':
+ e.preventDefault();
+ if (e.shiftKey) {
+ if (selectedLayerIds.length === 1) {
+ const layer = project?.layers[selectedLayerIds[0]];
+ if (layer?.type === 'group') {
+ ungroupLayers(selectedLayerIds[0]);
+ }
+ }
+ } else if (selectedLayerIds.length > 1) {
+ groupLayers(selectedLayerIds);
+ }
+ break;
+
+ case ']':
+ e.preventDefault();
+ if (selectedLayerIds.length === 1) {
+ if (e.shiftKey) {
+ moveLayerToTop(selectedLayerIds[0]);
+ } else {
+ moveLayerUp(selectedLayerIds[0]);
+ }
+ }
+ break;
+
+ case '[':
+ e.preventDefault();
+ if (selectedLayerIds.length === 1) {
+ if (e.shiftKey) {
+ moveLayerToBottom(selectedLayerIds[0]);
+ } else {
+ moveLayerDown(selectedLayerIds[0]);
+ }
+ }
+ break;
+
+ case '=':
+ case '+':
+ e.preventDefault();
+ zoomIn();
+ break;
+
+ case '-':
+ e.preventDefault();
+ zoomOut();
+ break;
+
+ case '0':
+ e.preventDefault();
+ zoomToFit();
+ break;
+
+ case "'":
+ e.preventDefault();
+ toggleGrid();
+ break;
+
+ case ';':
+ e.preventDefault();
+ toggleGuides();
+ break;
+ }
+ }
+
+ if (e.key === 'Escape') {
+ deselectAllLayers();
+ }
+ };
+
+ window.addEventListener('keydown', handleKeyDown);
+ return () => window.removeEventListener('keydown', handleKeyDown);
+ }, [
+ selectedLayerIds,
+ setActiveTool,
+ removeLayer,
+ copyLayers,
+ cutLayers,
+ pasteLayers,
+ duplicateLayer,
+ selectAllLayers,
+ deselectAllLayers,
+ moveLayerUp,
+ moveLayerDown,
+ moveLayerToTop,
+ moveLayerToBottom,
+ groupLayers,
+ ungroupLayers,
+ zoomIn,
+ zoomOut,
+ zoomToFit,
+ toggleGrid,
+ toggleGuides,
+ undo,
+ redo,
+ canUndo,
+ canRedo,
+ project,
+ ]);
+}
diff --git a/apps/image/src/stores/canvas-store.ts b/apps/image/src/stores/canvas-store.ts
new file mode 100644
index 00000000..49cd3436
--- /dev/null
+++ b/apps/image/src/stores/canvas-store.ts
@@ -0,0 +1,216 @@
+import { create } from 'zustand';
+import { subscribeWithSelector } from 'zustand/middleware';
+
+export interface Guide {
+ id: string;
+ type: 'horizontal' | 'vertical';
+ position: number;
+}
+
+export interface SelectionRect {
+ x: number;
+ y: number;
+ width: number;
+ height: number;
+}
+
+export type DragMode = 'none' | 'move' | 'resize' | 'rotate' | 'marquee' | 'pan';
+export type ResizeHandle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
+
+interface CanvasState {
+ canvasRef: HTMLCanvasElement | null;
+ context: CanvasRenderingContext2D | null;
+ containerRef: HTMLDivElement | null;
+
+ isDragging: boolean;
+ dragMode: DragMode;
+ dragStartX: number;
+ dragStartY: number;
+ dragCurrentX: number;
+ dragCurrentY: number;
+
+ activeResizeHandle: ResizeHandle | null;
+
+ isMarqueeSelecting: boolean;
+ marqueeRect: SelectionRect | null;
+
+ guides: Guide[];
+ activeGuide: string | null;
+
+ hoveredLayerId: string | null;
+
+ transformOriginX: number;
+ transformOriginY: number;
+
+ renderCount: number;
+}
+
+interface CanvasActions {
+ setCanvasRef: (canvas: HTMLCanvasElement | null) => void;
+ setContainerRef: (container: HTMLDivElement | null) => void;
+
+ startDrag: (mode: DragMode, x: number, y: number) => void;
+ updateDrag: (x: number, y: number) => void;
+ endDrag: () => void;
+
+ setActiveResizeHandle: (handle: ResizeHandle | null) => void;
+
+ startMarqueeSelect: (x: number, y: number) => void;
+ updateMarqueeSelect: (x: number, y: number) => void;
+ endMarqueeSelect: () => SelectionRect | null;
+
+ addGuide: (type: 'horizontal' | 'vertical', position: number) => string;
+ removeGuide: (id: string) => void;
+ updateGuide: (id: string, position: number) => void;
+ setActiveGuide: (id: string | null) => void;
+ clearGuides: () => void;
+
+ setHoveredLayerId: (id: string | null) => void;
+
+ setTransformOrigin: (x: number, y: number) => void;
+
+ requestRender: () => void;
+}
+
+const generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
+
+export const useCanvasStore = create<CanvasState & CanvasActions>()(
+ subscribeWithSelector((set, get) => ({
+ canvasRef: null,
+ context: null,
+ containerRef: null,
+
+ isDragging: false,
+ dragMode: 'none',
+ dragStartX: 0,
+ dragStartY: 0,
+ dragCurrentX: 0,
+ dragCurrentY: 0,
+
+ activeResizeHandle: null,
+
+ isMarqueeSelecting: false,
+ marqueeRect: null,
+
+ guides: [],
+ activeGuide: null,
+
+ hoveredLayerId: null,
+
+ transformOriginX: 0.5,
+ transformOriginY: 0.5,
+
+ renderCount: 0,
+
+ setCanvasRef: (canvas) => {
+ set({
+ canvasRef: canvas,
+ context: canvas?.getContext('2d') ?? null,
+ });
+ },
+
+ setContainerRef: (container) => {
+ set({ containerRef: container });
+ },
+
+ startDrag: (mode, x, y) => {
+ set({
+ isDragging: true,
+ dragMode: mode,
+ dragStartX: x,
+ dragStartY: y,
+ dragCurrentX: x,
+ dragCurrentY: y,
+ });
+ },
+
+ updateDrag: (x, y) => {
+ set({
+ dragCurrentX: x,
+ dragCurrentY: y,
+ });
+ },
+
+ endDrag: () => {
+ set({
+ isDragging: false,
+ dragMode: 'none',
+ activeResizeHandle: null,
+ });
+ },
+
+ setActiveResizeHandle: (handle) => {
+ set({ activeResizeHandle: handle });
+ },
+
+ startMarqueeSelect: (x, y) => {
+ set({
+ isMarqueeSelecting: true,
+ marqueeRect: { x, y, width: 0, height: 0 },
+ });
+ },
+
+ updateMarqueeSelect: (x, y) => {
+ const { marqueeRect } = get();
+ if (marqueeRect) {
+ set({
+ marqueeRect: {
+ x: Math.min(marqueeRect.x, x),
+ y: Math.min(marqueeRect.y, y),
+ width: Math.abs(x - marqueeRect.x),
+ height: Math.abs(y - marqueeRect.y),
+ },
+ });
+ }
+ },
+
+ endMarqueeSelect: () => {
+ const { marqueeRect } = get();
+ set({
+ isMarqueeSelecting: false,
+ marqueeRect: null,
+ });
+ return marqueeRect;
+ },
+
+ addGuide: (type, position) => {
+ const id = generateId();
+ set((state) => ({
+ guides: [...state.guides, { id, type, position }],
+ }));
+ return id;
+ },
+
+ removeGuide: (id) => {
+ set((state) => ({
+ guides: state.guides.filter((g) => g.id !== id),
+ }));
+ },
+
+ updateGuide: (id, position) => {
+ set((state) => ({
+ guides: state.guides.map((g) => (g.id === id ? { ...g, position } : g)),
+ }));
+ },
+
+ setActiveGuide: (id) => {
+ set({ activeGuide: id });
+ },
+
+ clearGuides: () => {
+ set({ guides: [] });
+ },
+
+ setHoveredLayerId: (id) => {
+ set({ hoveredLayerId: id });
+ },
+
+ setTransformOrigin: (x, y) => {
+ set({ transformOriginX: x, transformOriginY: y });
+ },
+
+ requestRender: () => {
+ set((state) => ({ renderCount: state.renderCount + 1 }));
+ },
+ }))
+);
diff --git a/apps/image/src/stores/history-store.ts b/apps/image/src/stores/history-store.ts
new file mode 100644
index 00000000..eebbf992
--- /dev/null
+++ b/apps/image/src/stores/history-store.ts
@@ -0,0 +1,125 @@
+import { create } from 'zustand';
+import { subscribeWithSelector } from 'zustand/middleware';
+import type { Project } from '../types/project';
+
+interface HistoryEntry {
+ id: string;
+ timestamp: number;
+ description: string;
+ state: string;
+}
+
+interface HistoryState {
+ entries: HistoryEntry[];
+ currentIndex: number;
+ maxEntries: number;
+ isUndoing: boolean;
+ isRedoing: boolean;
+}
+
+interface HistoryActions {
+ pushState: (project: Project, description: string) => void;
+ undo: () => Project | null;
+ redo: () => Project | null;
+ canUndo: () => boolean;
+ canRedo: () => boolean;
+ clear: () => void;
+ setMaxEntries: (max: number) => void;
+ getUndoDescription: () => string | null;
+ getRedoDescription: () => string | null;
+}
+
+const generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
+
+export const useHistoryStore = create<HistoryState & HistoryActions>()(
+ subscribeWithSelector((set, get) => ({
+ entries: [],
+ currentIndex: -1,
+ maxEntries: 50,
+ isUndoing: false,
+ isRedoing: false,
+
+ pushState: (project, description) => {
+ const { entries, currentIndex, maxEntries, isUndoing, isRedoing } = get();
+
+ if (isUndoing || isRedoing) return;
+
+ const newEntry: HistoryEntry = {
+ id: generateId(),
+ timestamp: Date.now(),
+ description,
+ state: JSON.stringify(project),
+ };
+
+ let newEntries = entries.slice(0, currentIndex + 1);
+ newEntries.push(newEntry);
+
+ if (newEntries.length > maxEntries) {
+ newEntries = newEntries.slice(newEntries.length - maxEntries);
+ }
+
+ set({
+ entries: newEntries,
+ currentIndex: newEntries.length - 1,
+ });
+ },
+
+ undo: () => {
+ const { entries, currentIndex } = get();
+ if (currentIndex <= 0) return null;
+
+ set({ isUndoing: true });
+ const newIndex = currentIndex - 1;
+ const entry = entries[newIndex];
+
+ set({ currentIndex: newIndex, isUndoing: false });
+ return JSON.parse(entry.state) as Project;
+ },
+
+ redo: () => {
+ const { entries, currentIndex } = get();
+ if (currentIndex >= entries.length - 1) return null;
+
+ set({ isRedoing: true });
+ const newIndex = currentIndex + 1;
+ const entry = entries[newIndex];
+
+ set({ currentIndex: newIndex, isRedoing: false });
+ return JSON.parse(entry.state) as Project;
+ },
+
+ canUndo: () => {
+ const { currentIndex } = get();
+ return currentIndex > 0;
+ },
+
+ canRedo: () => {
+ const { entries, currentIndex } = get();
+ return currentIndex < entries.length - 1;
+ },
+
+ clear: () => {
+ set({ entries: [], currentIndex: -1 });
+ },
+
+ setMaxEntries: (max) => {
+ set({ maxEntries: max });
+ },
+
+ getUndoDescription: () => {
+ const { entries, currentIndex } = get();
+ if (currentIndex > 0) {
+ return entries[currentIndex].description;
+ }
+ return null;
+ },
+
+ getRedoDescription: () => {
+ const { entries, currentIndex } = get();
+ if (currentIndex < entries.length - 1) {
+ return entries[currentIndex + 1].description;
+ }
+ return null;
+ },
+ }))
+);
diff --git a/apps/image/src/stores/index.ts b/apps/image/src/stores/index.ts
new file mode 100644
index 00000000..9561eb4e
--- /dev/null
+++ b/apps/image/src/stores/index.ts
@@ -0,0 +1,9 @@
+export { useUIStore } from './ui-store';
+export type { AppView, Tool, Panel } from './ui-store';
+
+export { useProjectStore } from './project-store';
+
+export { useHistoryStore } from './history-store';
+
+export { useCanvasStore } from './canvas-store';
+export type { Guide, SelectionRect, DragMode, ResizeHandle } from './canvas-store';
diff --git a/apps/image/src/stores/project-store.ts b/apps/image/src/stores/project-store.ts
new file mode 100644
index 00000000..44ebc2dd
--- /dev/null
+++ b/apps/image/src/stores/project-store.ts
@@ -0,0 +1,645 @@
+import { create } from 'zustand';
+import { subscribeWithSelector } from 'zustand/middleware';
+import { immer } from 'zustand/middleware/immer';
+import {
+ Project,
+ Layer,
+ ImageLayer,
+ TextLayer,
+ ShapeLayer,
+ GroupLayer,
+ Artboard,
+ MediaAsset,
+ Transform,
+ DEFAULT_TRANSFORM,
+ DEFAULT_BLEND_MODE,
+ DEFAULT_SHADOW,
+ DEFAULT_STROKE,
+ DEFAULT_FILTER,
+ DEFAULT_TEXT_STYLE,
+ DEFAULT_SHAPE_STYLE,
+ CanvasSize,
+ CanvasBackground,
+} from '../types/project';
+
+interface ProjectState {
+ project: Project | null;
+ selectedLayerIds: string[];
+ selectedArtboardId: string | null;
+ copiedLayers: Layer[];
+ isDirty: boolean;
+}
+
+interface ProjectActions {
+ createProject: (name: string, size: CanvasSize, background?: CanvasBackground) => void;
+ loadProject: (project: Project) => void;
+ closeProject: () => void;
+ setProjectName: (name: string) => void;
+
+ addArtboard: (name: string, size: CanvasSize, position?: { x: number; y: number }) => string;
+ removeArtboard: (artboardId: string) => void;
+ updateArtboard: (artboardId: string, updates: Partial<Artboard>) => void;
+ selectArtboard: (artboardId: string | null) => void;
+
+ addImageLayer: (sourceId: string, transform?: Partial<Transform>) => string;
+ addTextLayer: (content: string, transform?: Partial<Transform>) => string;
+ addShapeLayer: (shapeType: ShapeLayer['shapeType'], transform?: Partial<Transform>) => string;
+ addGroupLayer: (childIds: string[]) => string;
+ removeLayer: (layerId: string) => void;
+ removeLayers: (layerIds: string[]) => void;
+ updateLayer: <T extends Layer>(layerId: string, updates: Partial<T>) => void;
+ updateLayerTransform: (layerId: string, transform: Partial<Transform>) => void;
+ duplicateLayer: (layerId: string) => string | null;
+ duplicateLayers: (layerIds: string[]) => string[];
+
+ selectLayer: (layerId: string, addToSelection?: boolean) => void;
+ selectLayers: (layerIds: string[]) => void;
+ deselectLayer: (layerId: string) => void;
+ deselectAllLayers: () => void;
+ selectAllLayers: () => void;
+
+ moveLayerUp: (layerId: string) => void;
+ moveLayerDown: (layerId: string) => void;
+ moveLayerToTop: (layerId: string) => void;
+ moveLayerToBottom: (layerId: string) => void;
+ reorderLayers: (layerIds: string[]) => void;
+
+ copyLayers: () => void;
+ cutLayers: () => void;
+ pasteLayers: () => void;
+
+ groupLayers: (layerIds: string[]) => string | null;
+ ungroupLayers: (groupId: string) => void;
+
+ addAsset: (asset: MediaAsset) => void;
+ removeAsset: (assetId: string) => void;
+
+ markDirty: () => void;
+ markClean: () => void;
+}
+
+const generateId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
+
+export const useProjectStore = create<ProjectState & ProjectActions>()(
+ subscribeWithSelector(
+ immer((set, get) => ({
+ project: null,
+ selectedLayerIds: [],
+ selectedArtboardId: null,
+ copiedLayers: [],
+ isDirty: false,
+
+ createProject: (name, size, background) => {
+ const artboardId = generateId();
+ const project: Project = {
+ id: generateId(),
+ name,
+ createdAt: Date.now(),
+ updatedAt: Date.now(),
+ version: 1,
+ artboards: [
+ {
+ id: artboardId,
+ name: 'Artboard 1',
+ size,
+ background: background ?? { type: 'color', color: '#ffffff' },
+ layerIds: [],
+ position: { x: 0, y: 0 },
+ },
+ ],
+ layers: {},
+ assets: {},
+ activeArtboardId: artboardId,
+ };
+ set({ project, selectedLayerIds: [], selectedArtboardId: artboardId, isDirty: false });
+ },
+
+ loadProject: (project) => {
+ set({
+ project,
+ selectedLayerIds: [],
+ selectedArtboardId: project.activeArtboardId,
+ isDirty: false,
+ });
+ },
+
+ closeProject: () => {
+ set({ project: null, selectedLayerIds: [], selectedArtboardId: null, isDirty: false });
+ },
+
+ setProjectName: (name) => {
+ set((state) => {
+ if (state.project) {
+ state.project.name = name;
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ });
+ },
+
+ addArtboard: (name, size, position) => {
+ const id = generateId();
+ set((state) => {
+ if (state.project) {
+ state.project.artboards.push({
+ id,
+ name,
+ size,
+ background: { type: 'color', color: '#ffffff' },
+ layerIds: [],
+ position: position ?? { x: (state.project.artboards.length % 3) * (size.width + 100), y: Math.floor(state.project.artboards.length / 3) * (size.height + 100) },
+ });
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ });
+ return id;
+ },
+
+ removeArtboard: (artboardId) => {
+ set((state) => {
+ if (state.project && state.project.artboards.length > 1) {
+ const artboard = state.project.artboards.find((a) => a.id === artboardId);
+ if (artboard) {
+ artboard.layerIds.forEach((layerId) => {
+ delete state.project!.layers[layerId];
+ });
+ state.project.artboards = state.project.artboards.filter((a) => a.id !== artboardId);
+ if (state.selectedArtboardId === artboardId) {
+ state.selectedArtboardId = state.project.artboards[0]?.id ?? null;
+ }
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ updateArtboard: (artboardId, updates) => {
+ set((state) => {
+ if (state.project) {
+ const artboard = state.project.artboards.find((a) => a.id === artboardId);
+ if (artboard) {
+ Object.assign(artboard, updates);
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ selectArtboard: (artboardId) => {
+ set({ selectedArtboardId: artboardId, selectedLayerIds: [] });
+ },
+
+ addImageLayer: (sourceId, transform) => {
+ const id = generateId();
+ const asset = get().project?.assets[sourceId];
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ const layer: ImageLayer = {
+ id,
+ name: asset?.name ?? 'Image',
+ type: 'image',
+ visible: true,
+ locked: false,
+ transform: {
+ ...DEFAULT_TRANSFORM,
+ width: asset?.width ?? 200,
+ height: asset?.height ?? 200,
+ x: (artboard.size.width - (asset?.width ?? 200)) / 2,
+ y: (artboard.size.height - (asset?.height ?? 200)) / 2,
+ ...transform,
+ },
+ blendMode: DEFAULT_BLEND_MODE,
+ shadow: DEFAULT_SHADOW,
+ stroke: DEFAULT_STROKE,
+ filters: DEFAULT_FILTER,
+ parentId: null,
+ sourceId,
+ cropRect: null,
+ flipHorizontal: false,
+ flipVertical: false,
+ };
+ state.project.layers[id] = layer;
+ artboard.layerIds.unshift(id);
+ state.selectedLayerIds = [id];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ return id;
+ },
+
+ addTextLayer: (content, transform) => {
+ const id = generateId();
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ const layer: TextLayer = {
+ id,
+ name: content.slice(0, 20) || 'Text',
+ type: 'text',
+ visible: true,
+ locked: false,
+ transform: {
+ ...DEFAULT_TRANSFORM,
+ width: 200,
+ height: 50,
+ x: (artboard.size.width - 200) / 2,
+ y: (artboard.size.height - 50) / 2,
+ ...transform,
+ },
+ blendMode: DEFAULT_BLEND_MODE,
+ shadow: DEFAULT_SHADOW,
+ stroke: DEFAULT_STROKE,
+ filters: DEFAULT_FILTER,
+ parentId: null,
+ content,
+ style: DEFAULT_TEXT_STYLE,
+ autoSize: true,
+ };
+ state.project.layers[id] = layer;
+ artboard.layerIds.unshift(id);
+ state.selectedLayerIds = [id];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ return id;
+ },
+
+ addShapeLayer: (shapeType, transform) => {
+ const id = generateId();
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ const layer: ShapeLayer = {
+ id,
+ name: shapeType.charAt(0).toUpperCase() + shapeType.slice(1),
+ type: 'shape',
+ visible: true,
+ locked: false,
+ transform: {
+ ...DEFAULT_TRANSFORM,
+ width: 100,
+ height: 100,
+ x: (artboard.size.width - 100) / 2,
+ y: (artboard.size.height - 100) / 2,
+ ...transform,
+ },
+ blendMode: DEFAULT_BLEND_MODE,
+ shadow: DEFAULT_SHADOW,
+ stroke: DEFAULT_STROKE,
+ filters: DEFAULT_FILTER,
+ parentId: null,
+ shapeType,
+ shapeStyle: DEFAULT_SHAPE_STYLE,
+ };
+ state.project.layers[id] = layer;
+ artboard.layerIds.unshift(id);
+ state.selectedLayerIds = [id];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ return id;
+ },
+
+ addGroupLayer: (childIds) => {
+ const id = generateId();
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard && childIds.length > 0) {
+ const layer: GroupLayer = {
+ id,
+ name: 'Group',
+ type: 'group',
+ visible: true,
+ locked: false,
+ transform: DEFAULT_TRANSFORM,
+ blendMode: DEFAULT_BLEND_MODE,
+ shadow: DEFAULT_SHADOW,
+ stroke: DEFAULT_STROKE,
+ filters: DEFAULT_FILTER,
+ parentId: null,
+ childIds,
+ expanded: true,
+ };
+ childIds.forEach((childId) => {
+ const child = state.project!.layers[childId];
+ if (child) {
+ child.parentId = id;
+ }
+ });
+ state.project.layers[id] = layer;
+ const firstChildIndex = artboard.layerIds.findIndex((lid) => childIds.includes(lid));
+ artboard.layerIds = artboard.layerIds.filter((lid) => !childIds.includes(lid));
+ artboard.layerIds.splice(firstChildIndex, 0, id);
+ state.selectedLayerIds = [id];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ return id;
+ },
+
+ removeLayer: (layerId) => {
+ set((state) => {
+ if (state.project) {
+ const layer = state.project.layers[layerId];
+ if (layer) {
+ if (layer.type === 'group') {
+ (layer as GroupLayer).childIds.forEach((childId) => {
+ delete state.project!.layers[childId];
+ });
+ }
+ delete state.project.layers[layerId];
+ state.project.artboards.forEach((artboard) => {
+ artboard.layerIds = artboard.layerIds.filter((id) => id !== layerId);
+ });
+ state.selectedLayerIds = state.selectedLayerIds.filter((id) => id !== layerId);
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ removeLayers: (layerIds) => {
+ layerIds.forEach((id) => get().removeLayer(id));
+ },
+
+ updateLayer: (layerId, updates) => {
+ set((state) => {
+ if (state.project) {
+ const layer = state.project.layers[layerId];
+ if (layer) {
+ Object.assign(layer, updates);
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ updateLayerTransform: (layerId, transform) => {
+ set((state) => {
+ if (state.project) {
+ const layer = state.project.layers[layerId];
+ if (layer) {
+ Object.assign(layer.transform, transform);
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ duplicateLayer: (layerId) => {
+ const { project, selectedArtboardId } = get();
+ if (!project || !selectedArtboardId) return null;
+
+ const layer = project.layers[layerId];
+ if (!layer) return null;
+
+ const newId = generateId();
+ set((state) => {
+ if (state.project) {
+ const artboard = state.project.artboards.find((a) => a.id === selectedArtboardId);
+ if (artboard) {
+ const newLayer = JSON.parse(JSON.stringify(layer));
+ newLayer.id = newId;
+ newLayer.name = `${layer.name} copy`;
+ newLayer.transform.x += 20;
+ newLayer.transform.y += 20;
+ state.project.layers[newId] = newLayer;
+ const originalIndex = artboard.layerIds.indexOf(layerId);
+ artboard.layerIds.splice(originalIndex, 0, newId);
+ state.selectedLayerIds = [newId];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ return newId;
+ },
+
+ duplicateLayers: (layerIds) => {
+ return layerIds.map((id) => get().duplicateLayer(id)).filter((id): id is string => id !== null);
+ },
+
+ selectLayer: (layerId, addToSelection = false) => {
+ set((state) => {
+ if (addToSelection) {
+ if (!state.selectedLayerIds.includes(layerId)) {
+ state.selectedLayerIds.push(layerId);
+ }
+ } else {
+ state.selectedLayerIds = [layerId];
+ }
+ });
+ },
+
+ selectLayers: (layerIds) => {
+ set({ selectedLayerIds: layerIds });
+ },
+
+ deselectLayer: (layerId) => {
+ set((state) => {
+ state.selectedLayerIds = state.selectedLayerIds.filter((id) => id !== layerId);
+ });
+ },
+
+ deselectAllLayers: () => {
+ set({ selectedLayerIds: [] });
+ },
+
+ selectAllLayers: () => {
+ const { project, selectedArtboardId } = get();
+ if (project && selectedArtboardId) {
+ const artboard = project.artboards.find((a) => a.id === selectedArtboardId);
+ if (artboard) {
+ set({ selectedLayerIds: [...artboard.layerIds] });
+ }
+ }
+ },
+
+ moveLayerUp: (layerId) => {
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ const index = artboard.layerIds.indexOf(layerId);
+ if (index > 0) {
+ [artboard.layerIds[index - 1], artboard.layerIds[index]] = [artboard.layerIds[index], artboard.layerIds[index - 1]];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ }
+ });
+ },
+
+ moveLayerDown: (layerId) => {
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ const index = artboard.layerIds.indexOf(layerId);
+ if (index < artboard.layerIds.length - 1) {
+ [artboard.layerIds[index], artboard.layerIds[index + 1]] = [artboard.layerIds[index + 1], artboard.layerIds[index]];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ }
+ });
+ },
+
+ moveLayerToTop: (layerId) => {
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ artboard.layerIds = artboard.layerIds.filter((id) => id !== layerId);
+ artboard.layerIds.unshift(layerId);
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ moveLayerToBottom: (layerId) => {
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ artboard.layerIds = artboard.layerIds.filter((id) => id !== layerId);
+ artboard.layerIds.push(layerId);
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ reorderLayers: (layerIds) => {
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ artboard.layerIds = layerIds;
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ },
+
+ copyLayers: () => {
+ const { project, selectedLayerIds } = get();
+ if (project && selectedLayerIds.length > 0) {
+ const layers = selectedLayerIds.map((id) => project.layers[id]).filter(Boolean);
+ set({ copiedLayers: JSON.parse(JSON.stringify(layers)) });
+ }
+ },
+
+ cutLayers: () => {
+ get().copyLayers();
+ get().removeLayers(get().selectedLayerIds);
+ },
+
+ pasteLayers: () => {
+ const { copiedLayers, selectedArtboardId, project } = get();
+ if (copiedLayers.length > 0 && selectedArtboardId && project) {
+ const newIds: string[] = [];
+ set((state) => {
+ if (state.project) {
+ const artboard = state.project.artboards.find((a) => a.id === selectedArtboardId);
+ if (artboard) {
+ copiedLayers.forEach((layer) => {
+ const newId = generateId();
+ const newLayer = JSON.parse(JSON.stringify(layer));
+ newLayer.id = newId;
+ newLayer.name = `${layer.name} copy`;
+ newLayer.transform.x += 20;
+ newLayer.transform.y += 20;
+ state.project!.layers[newId] = newLayer;
+ artboard.layerIds.unshift(newId);
+ newIds.push(newId);
+ });
+ state.selectedLayerIds = newIds;
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ });
+ }
+ },
+
+ groupLayers: (layerIds) => {
+ if (layerIds.length < 2) return null;
+ return get().addGroupLayer(layerIds);
+ },
+
+ ungroupLayers: (groupId) => {
+ set((state) => {
+ if (state.project && state.selectedArtboardId) {
+ const group = state.project.layers[groupId] as GroupLayer;
+ if (group && group.type === 'group') {
+ const artboard = state.project.artboards.find((a) => a.id === state.selectedArtboardId);
+ if (artboard) {
+ const groupIndex = artboard.layerIds.indexOf(groupId);
+ group.childIds.forEach((childId) => {
+ const child = state.project!.layers[childId];
+ if (child) {
+ child.parentId = null;
+ }
+ });
+ artboard.layerIds.splice(groupIndex, 1, ...group.childIds);
+ delete state.project.layers[groupId];
+ state.selectedLayerIds = group.childIds;
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ }
+ }
+ });
+ },
+
+ addAsset: (asset) => {
+ set((state) => {
+ if (state.project) {
+ state.project.assets[asset.id] = asset;
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ });
+ },
+
+ removeAsset: (assetId) => {
+ set((state) => {
+ if (state.project) {
+ delete state.project.assets[assetId];
+ state.project.updatedAt = Date.now();
+ state.isDirty = true;
+ }
+ });
+ },
+
+ markDirty: () => set({ isDirty: true }),
+ markClean: () => set({ isDirty: false }),
+ }))
+ )
+);
diff --git a/apps/image/src/stores/ui-store.ts b/apps/image/src/stores/ui-store.ts
new file mode 100644
index 00000000..18af7ae5
--- /dev/null
+++ b/apps/image/src/stores/ui-store.ts
@@ -0,0 +1,123 @@
+import { create } from 'zustand';
+import { subscribeWithSelector } from 'zustand/middleware';
+
+export type AppView = 'welcome' | 'editor';
+export type Tool = 'select' | 'hand' | 'text' | 'shape' | 'pen' | 'eyedropper' | 'zoom';
+export type Panel = 'layers' | 'assets' | 'templates' | 'text' | 'shapes' | 'uploads';
+
+interface UIState {
+ currentView: AppView;
+ activeTool: Tool;
+ activePanel: Panel;
+ isPanelCollapsed: boolean;
+ isInspectorCollapsed: boolean;
+ zoom: number;
+ panX: number;
+ panY: number;
+ showGrid: boolean;
+ showGuides: boolean;
+ showRulers: boolean;
+ snapToGrid: boolean;
+ snapToGuides: boolean;
+ snapToObjects: boolean;
+ gridSize: number;
+ isExporting: boolean;
+ exportProgress: number;
+ notification: { type: 'success' | 'error' | 'info'; message: string } | null;
+}
+
+interface UIActions {
+ setCurrentView: (view: AppView) => void;
+ setActiveTool: (tool: Tool) => void;
+ setActivePanel: (panel: Panel) => void;
+ togglePanelCollapsed: () => void;
+ toggleInspectorCollapsed: () => void;
+ setZoom: (zoom: number) => void;
+ setPan: (x: number, y: number) => void;
+ resetView: () => void;
+ zoomIn: () => void;
+ zoomOut: () => void;
+ zoomToFit: () => void;
+ toggleGrid: () => void;
+ toggleGuides: () => void;
+ toggleRulers: () => void;
+ toggleSnapToGrid: () => void;
+ toggleSnapToGuides: () => void;
+ toggleSnapToObjects: () => void;
+ setGridSize: (size: number) => void;
+ setExporting: (exporting: boolean) => void;
+ setExportProgress: (progress: number) => void;
+ showNotification: (type: 'success' | 'error' | 'info', message: string) => void;
+ clearNotification: () => void;
+}
+
+const ZOOM_LEVELS = [0.1, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4, 5, 8];
+
+export const useUIStore = create<UIState & UIActions>()(
+ subscribeWithSelector((set, get) => ({
+ currentView: 'welcome',
+ activeTool: 'select',
+ activePanel: 'layers',
+ isPanelCollapsed: false,
+ isInspectorCollapsed: false,
+ zoom: 1,
+ panX: 0,
+ panY: 0,
+ showGrid: false,
+ showGuides: true,
+ showRulers: true,
+ snapToGrid: false,
+ snapToGuides: true,
+ snapToObjects: true,
+ gridSize: 10,
+ isExporting: false,
+ exportProgress: 0,
+ notification: null,
+
+ setCurrentView: (view) => set({ currentView: view }),
+ setActiveTool: (tool) => set({ activeTool: tool }),
+ setActivePanel: (panel) => set({ activePanel: panel }),
+ togglePanelCollapsed: () => set((s) => ({ isPanelCollapsed: !s.isPanelCollapsed })),
+ toggleInspectorCollapsed: () => set((s) => ({ isInspectorCollapsed: !s.isInspectorCollapsed })),
+
+ setZoom: (zoom) => set({ zoom: Math.max(0.1, Math.min(8, zoom)) }),
+ setPan: (x, y) => set({ panX: x, panY: y }),
+ resetView: () => set({ zoom: 1, panX: 0, panY: 0 }),
+
+ zoomIn: () => {
+ const { zoom } = get();
+ const nextLevel = ZOOM_LEVELS.find((l) => l > zoom) ?? ZOOM_LEVELS[ZOOM_LEVELS.length - 1];
+ set({ zoom: nextLevel });
+ },
+
+ zoomOut: () => {
+ const { zoom } = get();
+ const prevLevel = [...ZOOM_LEVELS].reverse().find((l) => l < zoom) ?? ZOOM_LEVELS[0];
+ set({ zoom: prevLevel });
+ },
+
+ zoomToFit: () => {
+ set({ zoom: 1, panX: 0, panY: 0 });
+ },
+
+ toggleGrid: () => set((s) => ({ showGrid: !s.showGrid })),
+ toggleGuides: () => set((s) => ({ showGuides: !s.showGuides })),
+ toggleRulers: () => set((s) => ({ showRulers: !s.showRulers })),
+ toggleSnapToGrid: () => set((s) => ({ snapToGrid: !s.snapToGrid })),
+ toggleSnapToGuides: () => set((s) => ({ snapToGuides: !s.snapToGuides })),
+ toggleSnapToObjects: () => set((s) => ({ snapToObjects: !s.snapToObjects })),
+ setGridSize: (size) => set({ gridSize: size }),
+
+ setExporting: (exporting) => set({ isExporting: exporting }),
+ setExportProgress: (progress) => set({ exportProgress: progress }),
+
+ showNotification: (type, message) => {
+ set({ notification: { type, message } });
+ setTimeout(() => {
+ set({ notification: null });
+ }, 4000);
+ },
+
+ clearNotification: () => set({ notification: null }),
+ }))
+);
diff --git a/apps/image/src/types/index.ts b/apps/image/src/types/index.ts
new file mode 100644
index 00000000..e984fc51
--- /dev/null
+++ b/apps/image/src/types/index.ts
@@ -0,0 +1 @@
+export * from './project';
diff --git a/apps/image/src/types/project.ts b/apps/image/src/types/project.ts
new file mode 100644
index 00000000..77468538
--- /dev/null
+++ b/apps/image/src/types/project.ts
@@ -0,0 +1,254 @@
+export type LayerType = 'image' | 'text' | 'shape' | 'group';
+
+export interface Transform {
+ x: number;
+ y: number;
+ width: number;
+ height: number;
+ rotation: number;
+ scaleX: number;
+ scaleY: number;
+ opacity: number;
+}
+
+export interface BlendMode {
+ mode: 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion';
+}
+
+export interface Shadow {
+ enabled: boolean;
+ color: string;
+ blur: number;
+ offsetX: number;
+ offsetY: number;
+}
+
+export interface Stroke {
+ enabled: boolean;
+ color: string;
+ width: number;
+ style: 'solid' | 'dashed' | 'dotted';
+}
+
+export interface Filter {
+ brightness: number;
+ contrast: number;
+ saturation: number;
+ hue: number;
+ blur: number;
+ sharpen: number;
+}
+
+export interface BaseLayer {
+ id: string;
+ name: string;
+ type: LayerType;
+ visible: boolean;
+ locked: boolean;
+ transform: Transform;
+ blendMode: BlendMode;
+ shadow: Shadow;
+ stroke: Stroke;
+ filters: Filter;
+ parentId: string | null;
+}
+
+export interface ImageLayer extends BaseLayer {
+ type: 'image';
+ sourceId: string;
+ cropRect: { x: number; y: number; width: number; height: number } | null;
+ flipHorizontal: boolean;
+ flipVertical: boolean;
+}
+
+export interface TextStyle {
+ fontFamily: string;
+ fontSize: number;
+ fontWeight: number;
+ fontStyle: 'normal' | 'italic';
+ textDecoration: 'none' | 'underline' | 'line-through';
+ textAlign: 'left' | 'center' | 'right' | 'justify';
+ verticalAlign: 'top' | 'middle' | 'bottom';
+ lineHeight: number;
+ letterSpacing: number;
+ color: string;
+ backgroundColor: string | null;
+}
+
+export interface TextLayer extends BaseLayer {
+ type: 'text';
+ content: string;
+ style: TextStyle;
+ autoSize: boolean;
+}
+
+export type ShapeType = 'rectangle' | 'ellipse' | 'triangle' | 'polygon' | 'star' | 'line' | 'arrow' | 'path';
+
+export interface ShapeStyle {
+ fill: string | null;
+ fillOpacity: number;
+ stroke: string | null;
+ strokeWidth: number;
+ strokeOpacity: number;
+ cornerRadius: number;
+}
+
+export interface ShapeLayer extends BaseLayer {
+ type: 'shape';
+ shapeType: ShapeType;
+ shapeStyle: ShapeStyle;
+ points?: { x: number; y: number }[];
+ sides?: number;
+ innerRadius?: number;
+}
+
+export interface GroupLayer extends BaseLayer {
+ type: 'group';
+ childIds: string[];
+ expanded: boolean;
+}
+
+export type Layer = ImageLayer | TextLayer | ShapeLayer | GroupLayer;
+
+export interface CanvasSize {
+ width: number;
+ height: number;
+}
+
+export interface CanvasBackground {
+ type: 'color' | 'gradient' | 'image' | 'transparent';
+ color?: string;
+ gradient?: {
+ type: 'linear' | 'radial';
+ angle: number;
+ stops: { offset: number; color: string }[];
+ };
+ imageId?: string;
+}
+
+export interface Artboard {
+ id: string;
+ name: string;
+ size: CanvasSize;
+ background: CanvasBackground;
+ layerIds: string[];
+ position: { x: number; y: number };
+}
+
+export interface MediaAsset {
+ id: string;
+ name: string;
+ type: 'image' | 'svg';
+ mimeType: string;
+ size: number;
+ width: number;
+ height: number;
+ thumbnailUrl: string;
+ dataUrl?: string;
+ blobUrl?: string;
+}
+
+export interface Project {
+ id: string;
+ name: string;
+ createdAt: number;
+ updatedAt: number;
+ version: number;
+ artboards: Artboard[];
+ layers: Record<string, Layer>;
+ assets: Record<string, MediaAsset>;
+ activeArtboardId: string | null;
+}
+
+export interface ProjectMetadata {
+ id: string;
+ name: string;
+ createdAt: number;
+ updatedAt: number;
+ thumbnailUrl: string | null;
+}
+
+export const DEFAULT_TRANSFORM: Transform = {
+ x: 0,
+ y: 0,
+ width: 100,
+ height: 100,
+ rotation: 0,
+ scaleX: 1,
+ scaleY: 1,
+ opacity: 1,
+};
+
+export const DEFAULT_BLEND_MODE: BlendMode = {
+ mode: 'normal',
+};
+
+export const DEFAULT_SHADOW: Shadow = {
+ enabled: false,
+ color: 'rgba(0, 0, 0, 0.5)',
+ blur: 10,
+ offsetX: 0,
+ offsetY: 4,
+};
+
+export const DEFAULT_STROKE: Stroke = {
+ enabled: false,
+ color: '#000000',
+ width: 1,
+ style: 'solid',
+};
+
+export const DEFAULT_FILTER: Filter = {
+ brightness: 100,
+ contrast: 100,
+ saturation: 100,
+ hue: 0,
+ blur: 0,
+ sharpen: 0,
+};
+
+export const DEFAULT_TEXT_STYLE: TextStyle = {
+ fontFamily: 'Inter',
+ fontSize: 24,
+ fontWeight: 400,
+ fontStyle: 'normal',
+ textDecoration: 'none',
+ textAlign: 'left',
+ verticalAlign: 'top',
+ lineHeight: 1.4,
+ letterSpacing: 0,
+ color: '#ffffff',
+ backgroundColor: null,
+};
+
+export const DEFAULT_SHAPE_STYLE: ShapeStyle = {
+ fill: '#3b82f6',
+ fillOpacity: 1,
+ stroke: null,
+ strokeWidth: 2,
+ strokeOpacity: 1,
+ cornerRadius: 0,
+};
+
+export const CANVAS_PRESETS: { name: string; width: number; height: number; category: string }[] = [
+ { name: 'Instagram Post', width: 1080, height: 1080, category: 'Social Media' },
+ { name: 'Instagram Story', width: 1080, height: 1920, category: 'Social Media' },
+ { name: 'Facebook Post', width: 1200, height: 630, category: 'Social Media' },
+ { name: 'Twitter Post', width: 1200, height: 675, category: 'Social Media' },
+ { name: 'LinkedIn Post', width: 1200, height: 627, category: 'Social Media' },
+ { name: 'YouTube Thumbnail', width: 1280, height: 720, category: 'Social Media' },
+ { name: 'TikTok Video', width: 1080, height: 1920, category: 'Social Media' },
+ { name: 'Pinterest Pin', width: 1000, height: 1500, category: 'Social Media' },
+ { name: 'Presentation 16:9', width: 1920, height: 1080, category: 'Presentation' },
+ { name: 'Presentation 4:3', width: 1024, height: 768, category: 'Presentation' },
+ { name: 'A4 Portrait', width: 2480, height: 3508, category: 'Print' },
+ { name: 'A4 Landscape', width: 3508, height: 2480, category: 'Print' },
+ { name: 'Letter Portrait', width: 2550, height: 3300, category: 'Print' },
+ { name: 'Business Card', width: 1050, height: 600, category: 'Print' },
+ { name: 'Poster 18x24', width: 5400, height: 7200, category: 'Print' },
+ { name: 'Desktop Wallpaper', width: 1920, height: 1080, category: 'Desktop' },
+ { name: '4K Wallpaper', width: 3840, height: 2160, category: 'Desktop' },
+ { name: 'Mobile Wallpaper', width: 1080, height: 1920, category: 'Mobile' },
+ { name: 'Logo Square', width: 500, height: 500, category: 'Logo' },
+ { name: 'Favicon', width: 512, height: 512, category: 'Logo' },
+];
diff --git a/apps/image/src/vite-env.d.ts b/apps/image/src/vite-env.d.ts
new file mode 100644
index 00000000..11f02fe2
--- /dev/null
+++ b/apps/image/src/vite-env.d.ts
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/apps/image/tailwind.config.js b/apps/image/tailwind.config.js
new file mode 100644
index 00000000..4fcb2a5c
--- /dev/null
+++ b/apps/image/tailwind.config.js
@@ -0,0 +1,102 @@
+/** @type {import('tailwindcss').Config} */
+export default {
+ content: [
+ "./index.html",
+ "./src/**/*.{js,ts,jsx,tsx}",
+ "../../packages/ui/src/**/*.{js,ts,jsx,tsx}",
+ ],
+ darkMode: 'class',
+ theme: {
+ extend: {
+ colors: {
+ background: {
+ DEFAULT: "hsl(var(--background))",
+ secondary: "rgb(var(--color-background-secondary) / <alpha-value>)",
+ tertiary: "rgb(var(--color-background-tertiary) / <alpha-value>)",
+ elevated: "rgb(var(--color-background-elevated) / <alpha-value>)",
+ },
+ foreground: "hsl(var(--foreground))",
+ card: {
+ DEFAULT: "hsl(var(--card))",
+ foreground: "hsl(var(--card-foreground))",
+ },
+ popover: {
+ DEFAULT: "hsl(var(--popover))",
+ foreground: "hsl(var(--popover-foreground))",
+ },
+ primary: {
+ DEFAULT: "hsl(var(--primary))",
+ foreground: "hsl(var(--primary-foreground))",
+ hover: "#16a34a",
+ active: "#15803d",
+ glow: "rgba(34, 197, 94, 0.5)",
+ },
+ secondary: {
+ DEFAULT: "hsl(var(--secondary))",
+ foreground: "hsl(var(--secondary-foreground))",
+ },
+ muted: {
+ DEFAULT: "hsl(var(--muted))",
+ foreground: "hsl(var(--muted-foreground))",
+ },
+ accent: {
+ DEFAULT: "hsl(var(--accent))",
+ foreground: "hsl(var(--accent-foreground))",
+ },
+ destructive: {
+ DEFAULT: "hsl(var(--destructive))",
+ foreground: "hsl(var(--destructive-foreground))",
+ },
+ border: {
+ DEFAULT: "hsl(var(--border))",
+ hover: "rgb(var(--color-border-hover) / <alpha-value>)",
+ active: "rgb(var(--color-border-active) / <alpha-value>)",
+ },
+ input: "hsl(var(--input))",
+ ring: "hsl(var(--ring))",
+ text: {
+ primary: "rgb(var(--color-text-primary) / <alpha-value>)",
+ secondary: "rgb(var(--color-text-secondary) / <alpha-value>)",
+ muted: "rgb(var(--color-text-muted) / <alpha-value>)",
+ },
+ status: {
+ success: "#22c55e",
+ warning: "#eab308",
+ error: "#ef4444",
+ info: "#3b82f6",
+ }
+ },
+ fontFamily: {
+ sans: ['Geist', '-apple-system', 'BlinkMacSystemFont', 'system-ui', 'sans-serif'],
+ mono: ['Geist Mono', 'monospace'],
+ },
+ boxShadow: {
+ 'glow': '0 0 10px rgba(34, 197, 94, 0.3)',
+ 'glow-lg': '0 0 20px rgba(34, 197, 94, 0.4)',
+ 'panel': '0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.15)',
+ },
+ borderRadius: {
+ lg: "var(--radius)",
+ md: "calc(var(--radius) - 2px)",
+ sm: "calc(var(--radius) - 4px)",
+ 'xl': '0.75rem',
+ '2xl': '1rem',
+ },
+ keyframes: {
+ "accordion-down": {
+ from: { height: "0" },
+ to: { height: "var(--radix-accordion-content-height)" },
+ },
+ "accordion-up": {
+ from: { height: "var(--radix-accordion-content-height)" },
+ to: { height: "0" },
+ },
+ },
+ animation: {
+ "accordion-down": "accordion-down 0.2s ease-out",
+ "accordion-up": "accordion-up 0.2s ease-out",
+ },
+ },
+ },
+ plugins: [require("tailwindcss-animate")],
+};
diff --git a/apps/image/tsconfig.json b/apps/image/tsconfig.json
new file mode 100644
index 00000000..541ffab2
--- /dev/null
+++ b/apps/image/tsconfig.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
+ "jsx": "react-jsx",
+ "noEmit": true,
+ "declaration": false,
+ "declarationMap": false,
+ "baseUrl": ".",
+ "paths": {
+ "@/*": ["./src/*"],
+ "@openreel/ui": ["../../packages/ui/src/index.ts"],
+ "@openreel/ui/*": ["../../packages/ui/src/*"]
+ }
+ },
+ "include": ["src"]
+}
diff --git a/apps/image/vite.config.ts b/apps/image/vite.config.ts
new file mode 100644
index 00000000..1037c9ce
--- /dev/null
+++ b/apps/image/vite.config.ts
@@ -0,0 +1,44 @@
+import { defineConfig } from "vite";
+import react from "@vitejs/plugin-react";
+import path from "path";
+
+export default defineConfig({
+ plugins: [react()],
+ assetsInclude: ["**/*.wasm"],
+ resolve: {
+ alias: {
+ "@": path.resolve(__dirname, "./src"),
+ },
+ },
+ build: {
+ target: "esnext",
+ rollupOptions: {
+ output: {
+ manualChunks: (id) => {
+ if (id.includes("node_modules/react") || id.includes("node_modules/react-dom")) {
+ return "react";
+ }
+ if (id.includes("node_modules/zustand")) {
+ return "zustand";
+ }
+ if (id.includes("node_modules/@radix-ui")) {
+ return "radix";
+ }
+ },
+ },
+ },
+ },
+ server: {
+ port: 5174,
+ headers: {
+ "Cross-Origin-Opener-Policy": "same-origin",
+ "Cross-Origin-Embedder-Policy": "require-corp",
+ },
+ },
+ preview: {
+ headers: {
+ "Cross-Origin-Opener-Policy": "same-origin",
+ "Cross-Origin-Embedder-Policy": "require-corp",
+ },
+ },
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fb1b42fc..190b9dd1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -34,6 +34,127 @@ importers:
specifier: ^3.101.0
version: 3.114.17(@cloudflare/[email protected])
+ apps/image:
+ dependencies:
+ '@openreel/ui':
+ specifier: workspace:*
+ version: link:../../packages/ui
+ '@radix-ui/react-context-menu':
+ specifier: ^2.2.16
+ '@radix-ui/react-dialog':
+ specifier: ^1.1.15
+ '@radix-ui/react-dropdown-menu':
+ specifier: ^2.1.16
+ '@radix-ui/react-popover':
+ specifier: ^1.1.15
+ '@radix-ui/react-select':
+ specifier: ^2.2.6
+ '@radix-ui/react-slider':
+ specifier: ^1.3.6
+ '@radix-ui/react-tabs':
+ specifier: ^1.1.13
+ '@radix-ui/react-tooltip':
+ specifier: ^1.2.8
+ class-variance-authority:
+ specifier: ^0.7.1
+ version: 0.7.1
+ clsx:
+ specifier: ^2.1.1
+ version: 2.1.1
+ framer-motion:
+ specifier: ^12.23.24
+ lucide-react:
+ specifier: ^0.555.0
+ version: 0.555.0([email protected])
+ react:
+ specifier: ^18.3.1
+ version: 18.3.1
+ react-dom:
+ specifier: ^18.3.1
+ version: 18.3.1([email protected])
+ tailwind-merge:
+ specifier: ^3.4.0
+ version: 3.4.0
+ uuid:
+ specifier: ^13.0.0
+ version: 13.0.0
+ zustand:
+ specifier: ^4.5.2
+ devDependencies:
+ '@eslint/js':
+ specifier: ^9.39.2
+ version: 9.39.2
+ '@testing-library/jest-dom':
+ specifier: ^6.4.6
+ version: 6.9.1
+ '@testing-library/react':
+ specifier: ^16.0.0
+ '@types/react':
+ specifier: ^18.3.3
+ version: 18.3.27
+ '@types/react-dom':
+ specifier: ^18.3.0
+ version: 18.3.7(@types/[email protected])
+ '@types/uuid':
+ specifier: ^11.0.0
+ version: 11.0.0
+ '@typescript-eslint/eslint-plugin':
+ specifier: ^8.53.0
+ '@typescript-eslint/parser':
+ specifier: ^8.53.0
+ '@vitejs/plugin-react':
+ specifier: ^4.3.1
+ version: 4.7.0([email protected](@types/[email protected]))
+ autoprefixer:
+ specifier: ^10.4.19
+ version: 10.4.22([email protected])
+ eslint:
+ specifier: ^9.39.2
+ version: 9.39.2([email protected])
+ eslint-plugin-react-hooks:
+ specifier: ^7.0.1
+ globals:
+ specifier: ^17.0.0
+ version: 17.0.0
+ jsdom:
+ specifier: ^24.1.0
+ version: 24.1.3
+ postcss:
+ specifier: ^8.4.38
+ version: 8.5.6
+ tailwindcss:
+ specifier: ^3.4.4
+ version: 3.4.18
+ tailwindcss-animate:
+ specifier: ^1.0.7
+ version: 1.0.7([email protected])
+ typescript:
+ specifier: ^5.4.5
+ version: 5.9.3
+ vite:
+ specifier: ^5.3.1
+ version: 5.4.21(@types/[email protected])
+ vitest:
+ specifier: ^1.6.0
+ version: 1.6.1(@types/[email protected])([email protected])
+ wrangler:
+ specifier: ^3.114.17
+ version: 3.114.17(@cloudflare/[email protected])
+
apps/web:
dependencies:
'@openreel/core':