Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

refactor: update selection handling and improve layout in Home and Editor components

CristianOlivera19629e84702c5
diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsx
index 5637875..cb2927e 100644
--- a/app/[locale]/(editor)/editor/page.tsx
+++ b/app/[locale]/(editor)/editor/page.tsx
@@ -670,11 +670,13 @@ export default function Editor() {
const hasTransparentBackground = selectedWallpaper === -1;
- // Temporarily deselect to exclude selection borders from the captured image
- const prevSelection = selectedElementId;
- if (prevSelection) selectCanvasElement(null);
+ // Temporarily clear ALL selection indicators (single, multi, and mockup border)
+ // so they don't appear in the html-to-image capture
+ const prevSingleSelection = selectedElementId;
+ selectCanvasElement(null);
+ const prevSelectionState = canvasRef.current?.clearAllSelection?.();
- await new Promise(resolve => setTimeout(resolve, 50));
+ await new Promise(resolve => setTimeout(resolve, 80));
const blob = await toBlob(previewContainer, {
quality,
@@ -686,8 +688,9 @@ export default function Editor() {
pixelRatio: 1,
});
- // Restore selection after capture
- if (prevSelection) selectCanvasElement(prevSelection);
+ // Restore all selection state after capture
+ if (prevSingleSelection) selectCanvasElement(prevSingleSelection);
+ if (prevSelectionState) canvasRef.current?.restoreSelectionState?.(prevSelectionState);
originalSrcs.forEach((originalSrc, img) => {
img.src = originalSrc;
@@ -987,9 +990,11 @@ export default function Editor() {
));
}, []);
- const deleteCanvasElement = useCallback((id: string) => {
- setCanvasElements(prev => prev.filter(el => el.id !== id));
- setSelectedElementId(prev => prev === id ? null : prev);
+ const deleteCanvasElement = useCallback((idOrIds: string | string[]) => {
+ const idsToDelete = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
+ const idsSet = new Set(idsToDelete);
+ setCanvasElements(prev => prev.filter(el => !idsSet.has(el.id)));
+ setSelectedElementId(prev => prev && idsSet.has(prev) ? null : prev);
}, []);
const [copiedElement, setCopiedElement] = useState<CanvasElement | null>(null);
@@ -2791,22 +2796,23 @@ export default function Editor() {
)}
</AnimatePresence>
- <EditorTopBar
- onExport={handleExport}
- exportProgress={exportProgress}
- hasTransparentBackground={selectedWallpaper === -1}
- onUndo={undo}
- onRedo={redo}
- canUndo={canUndo}
- canRedo={canRedo}
- editorMode={editorMode}
- onImageExport={handleImageExport}
- imageExportProgress={imageExportProgress}
- canvasWidth={customAspectRatio?.width || 1920}
- canvasHeight={customAspectRatio?.height || 1080}
- />
-
<VideoCanvas
+ layersPanelToolbar={
+ <EditorTopBar
+ onExport={handleExport}
+ exportProgress={exportProgress}
+ hasTransparentBackground={selectedWallpaper === -1}
+ onUndo={undo}
+ onRedo={redo}
+ canUndo={canUndo}
+ canRedo={canRedo}
+ editorMode={editorMode}
+ onImageExport={handleImageExport}
+ imageExportProgress={imageExportProgress}
+ canvasWidth={customAspectRatio?.width || 1920}
+ canvasHeight={customAspectRatio?.height || 1080}
+ />
+ }
ref={canvasRef}
videoUrl={videoUrl}
videoRef={videoRef}
@@ -2849,6 +2855,7 @@ export default function Editor() {
selectedElementId={selectedElementId}
onElementUpdate={updateCanvasElement}
onElementSelect={selectCanvasElement}
+ onElementDelete={deleteCanvasElement}
cameraUrl={effectiveCameraUrl}
cameraConfig={cameraConfig}
onCameraConfigChange={handleCameraConfigChange}
diff --git a/app/[locale]/(home)/page.tsx b/app/[locale]/(home)/page.tsx
index 19e4f10..7f01f9e 100644
--- a/app/[locale]/(home)/page.tsx
+++ b/app/[locale]/(home)/page.tsx
@@ -10,7 +10,7 @@ export default function Home() {
<div className="flex flex-col">
<div className="relative overflow-hidden bg-gradient-radial-primary w-full">
- <div className="absolute top-0 left-1/2 -translate-x-1/2 w-250 h-[150%] rounded-[100%] blur-3xl pointer-events-none -z-10"></div>
+ <div className="absolute top-0 left-1/2 -translate-x-1/2 w-75 h-75 rounded-full bg-cyan-500/15 blur-[80px] pointer-events-none z-0" />
<section className="pt-32 pb-6 sm:pb-14 bg-gradient-radial-primary">
<div className="max-w-6xl mx-auto px-6 text-center relative z-10">
@@ -19,29 +19,35 @@ export default function Home() {
</section>
<section className="w-full">
- <div className="absolute top-0 left-1/2 -translate-x-1/2 w-250 h-[150%] rounded-[100%] blur-3xl pointer-events-none -z-10"></div>
<HeroScrollMask />
</section>
</div>
- <section className="w-full py-16">
+ <section className="w-full py-10 sm:py-16">
<div className="max-w-6xl mx-auto px-6">
<InteractiveRecordingSteps />
</div>
</section>
- <section className="pt-8 pb-0 sm:py-2 w-full mb-0 sm:mb-42">
- <div className="max-w-xl mx-auto px-6">
- <DonationCard />
- </div>
- </section>
-
- <div className="relative overflow-hidden bg-gradient-radial-primary w-full py-20 pb-40">
+ <div className="relative overflow-hidden bg-gradient-radial-primary w-full pt-0 pb-30 sm:py-20">
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-250 h-[150%] rounded-[100%] blur-xl pointer-events-none "></div>
<section className="w-full">
- <div className="w-full sm:max-w-6xl mx-auto">
+ <div className="w-full mx-auto bg-[url('/images/pages/dots.svg')] bg-no-repeat bg-contain bg-center">
<EditorPreview />
</div>
- {/* <CarouselDemos /> */}
+ <CarouselDemos />
+ <section className="pt-4 pb-10 sm:py-2 w-full mb-0 sm:mb-42">
+ <div
+ className="absolute left-1/2 -translate-x-1/2 w-150 h-500 pointer-events-none z-0 pro-glow"
+ style={{
+ mixBlendMode: 'plus-lighter',
+ willChange: 'filter, background',
+ background: 'radial-gradient(circle at var(--glow-x) 20%, rgba(6, 182, 212, 0.25) 0%, transparent 70%)'
+ }}
+ />
+ <div className="max-w-xl mx-auto px-6">
+ <DonationCard />
+ </div>
+ </section>
</section>
</div>
</div>