Skip to content

Commit 73fffe3

Browse files
wass08claude
andcommitted
feat(editor): standard-capture aspect preselect via CaptureMode
Hosts (the studio capbar) can now pass standardAspect alongside crop when entering capture mode; the overlay initializes its aspect picker from it. SnapshotStandardAspect exported. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c00945b commit 73fffe3

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

packages/editor/src/components/editor/snapshot-capture-overlay.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { Check, Crop, Loader2, Maximize2, Monitor, X } from 'lucide-react'
55
import { useCallback, useEffect, useRef, useState } from 'react'
66
import { useIsMobile } from '../../hooks/use-mobile'
77
import { triggerSFX } from '../../lib/sfx-bus'
8-
import useEditor, { type SnapshotCropMode } from '../../store/use-editor'
8+
import useEditor, {
9+
type SnapshotCropMode,
10+
type SnapshotStandardAspect,
11+
} from '../../store/use-editor'
912

1013
// Local alias — distinct from `useEditor.captureMode` (which describes *why*
1114
// a capture is happening, e.g. `preset`). This one says HOW the captured
@@ -25,14 +28,14 @@ interface Drag {
2528
}
2629

2730
// Output presets for `standard` captures — long edge stays near 1920.
28-
const STANDARD_SIZES = {
31+
const STANDARD_SIZES: Record<SnapshotStandardAspect, { w: number; h: number }> = {
2932
'16:9': { w: 1920, h: 1080 },
3033
'9:16': { w: 1080, h: 1920 },
3134
'4:3': { w: 1920, h: 1440 },
3235
'3:4': { w: 1440, h: 1920 },
3336
'1:1': { w: 1440, h: 1440 },
34-
} as const
35-
type StandardAspect = keyof typeof STANDARD_SIZES
37+
}
38+
type StandardAspect = SnapshotStandardAspect
3639

3740
function getResolution(
3841
mode: CropMode,
@@ -105,6 +108,7 @@ export function SnapshotCaptureOverlay({ projectId }: { projectId: string }) {
105108
// crop shape. Matches the unified preset-thumbnail capture flow.
106109
const isPreset = captureMode.mode === 'preset'
107110
const requestedCrop = captureMode.mode === 'standard' ? captureMode.crop : undefined
111+
const requestedAspect = captureMode.mode === 'standard' ? captureMode.standardAspect : undefined
108112

109113
const [mode, setMode] = useState<CropMode>('standard')
110114
const [standardAspect, setStandardAspect] = useState<StandardAspect>('16:9')
@@ -145,6 +149,7 @@ export function SnapshotCaptureOverlay({ projectId }: { projectId: string }) {
145149
useEffect(() => {
146150
if (!isCaptureMode) return
147151
setMode(isPreset ? 'area' : (requestedCrop ?? 'standard'))
152+
setStandardAspect(requestedAspect ?? '16:9')
148153
setAspectMenuOpen(false)
149154
setIsDragging(false)
150155
setCaptureState('idle')
@@ -160,7 +165,7 @@ export function SnapshotCaptureOverlay({ projectId }: { projectId: string }) {
160165
} else {
161166
setDrag(null)
162167
}
163-
}, [isCaptureMode, isPreset, requestedCrop])
168+
}, [isCaptureMode, isPreset, requestedCrop, requestedAspect])
164169

165170
// Listen for snapshot saved to show feedback then exit
166171
useEffect(() => {

packages/editor/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ export type {
368368
CaptureMode,
369369
FloorplanSelectionTool,
370370
SnapshotCropMode,
371+
SnapshotStandardAspect,
371372
SplitOrientation,
372373
Tool,
373374
ToolDefaults,

packages/editor/src/store/use-editor.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ export type WorkspaceMode = 'edit' | 'studio'
8686
// or user-dragged area. Hosts (e.g. the studio capture bar) can preselect it
8787
// when entering capture mode.
8888
export type SnapshotCropMode = 'standard' | 'viewport' | 'area'
89+
/** Aspect presets available to `standard` crops. */
90+
export type SnapshotStandardAspect = '16:9' | '9:16' | '4:3' | '3:4' | '1:1'
8991

9092
export type CaptureMode =
9193
| { mode: 'idle' }
92-
| { mode: 'standard'; crop?: SnapshotCropMode }
94+
| { mode: 'standard'; crop?: SnapshotCropMode; standardAspect?: SnapshotStandardAspect }
9395
| {
9496
mode: 'preset'
9597
isolated: AnyNodeId[]

0 commit comments

Comments
 (0)