Create professional demos and 3D mockups in seconds, directly in your browser
feat: enhance loading component styling, improve header and mobile menu functionality, and optimize context management
CristianOlivera103f86c4f4800
diff --git a/app/[locale]/(editor)/editor/loading.tsx b/app/[locale]/(editor)/editor/loading.tsxindex 96fa16b..7bfea02 100644--- a/app/[locale]/(editor)/editor/loading.tsx+++ b/app/[locale]/(editor)/editor/loading.tsx@@ -1,24 +1,18 @@export default function Loading() {return (- <div className="fixed inset-0 z-50 flex items-center justify-center bg-[#020202]/50 backdrop-blur-3xl saturate-200 animate-fade-in">-- <div className="absolute inset-0 overflow-hidden pointer-events-none z-0 opacity-30 mix-blend-screen select-none">- <div className="absolute -top-1/4 -left-1/4 size-[600px] rounded-full bg-gradient-to-br from-cyan-600/30 to-emerald-700/0 blur-[140px] animate-[spin_50s_linear_infinite]" />- <div className="absolute -bottom-1/4 -right-1/4 size-[700px] rounded-full bg-gradient-to-tl from-indigo-700/25 to-purple-700/0 blur-[160px] animate-[spin_80s_linear_infinite_reverse]" />- </div>+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-[#020202]/50 backdrop-blur-2xl animate-fade-in">- <div className="absolute inset-0 flex items-center justify-center pointer-events-none z-0 overflow-hidden select-none">- <div className="absolute size-[1200px] rounded-full bg-radial from-cyan-700/10 via-indigo-700/3 to-transparent blur-[200px] mix-blend-plus-lighter transform-gpu" />-- <div className="absolute size-[800px] rounded-full bg-radial from-cyan-800/10 via-purple-800/4 to-transparent blur-[140px] mix-blend-plus-lighter transform-gpu" />+ <div className="absolute inset-0 overflow-hidden pointer-events-none z-0 opacity-30 select-none">+ <div className="absolute -top-1/4 -left-1/4 size-[600px] rounded-full bg-gradient-to-br from-cyan-600/30 to-emerald-700/0 blur-[120px]" />+ <div className="absolute -bottom-1/4 -right-1/4 size-[700px] rounded-full bg-gradient-to-tl from-indigo-700/25 to-purple-700/0 blur-[120px]" /></div><div className="relative flex items-center justify-center z-10 scale-95 animate-[pulse_6s_ease-in-out_infinite]">-- <div className="absolute size-36 rounded-full bg-cyan-700/10 blur-2xl pointer-events-none" />- <img- src="/svg/logo-openvid.svg"+ <div className="absolute size-36 rounded-full bg-cyan-700/10 blur-xl pointer-events-none" />++ <img+ src="/svg/logo-openvid.svg"alt="Cargando Openvid..."className="relative size-30 object-contain select-none filter drop-shadow-[0_0_35px_rgba(6,182,212,0.4)]"draggable={false}diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsxindex dbf9ea2..f67cb04 100644--- a/app/[locale]/(editor)/editor/page.tsx+++ b/app/[locale]/(editor)/editor/page.tsx@@ -35,7 +35,6 @@ import { MobileToolsMenu } from "@/app/components/ui/editor/MobileToolsMenu";import { MobileControlPanel } from "@/app/components/ui/editor/MobileControlPanel";import { EditorTopBar } from "@/app/components/ui/editor/EditorTopBar";import { VideoCanvas } from "@/app/components/ui/editor/VideoCanvas";-import { PlayerControls } from "@/app/components/ui/editor/PlayerControls";import { LoadingSpinner } from "@/components/ui/LoadingSpinner";import { TimelineSkeleton } from "@/app/components/ui/Skeleton";import { AudioTrimModal } from "@/app/components/ui/editor/AudioTrimModal";@@ -62,6 +61,7 @@ const ExportOverlay = lazy(() => import("@/app/components/ui/ExportOverlay").theconst VideoCropperModal = lazy(() => import("@/app/components/ui/editor/VideoCropperModal").then(mod => ({ default: mod.VideoCropperModal })));const ImageCropperModal = lazy(() => import("@/app/components/ui/editor/ImageCropperModal").then(mod => ({ default: mod.ImageCropperModal })));const PhotoEditorPlaceholder = lazy(() => import("@/app/components/ui/editor/PhotoEditorPlaceholder").then(mod => ({ default: mod.PhotoEditorPlaceholder })));+const PlayerControls = lazy(() => import("@/app/components/ui/editor/PlayerControls").then(mod => ({ default: mod.PlayerControls })));export default function Editor() {// Editor mode (video/photo) from URL params@@ -2948,6 +2948,7 @@ export default function Editor() {{/* Video mode: Show player controls and timeline */}{isVideoMode && (<>+ <Suspense fallback={<div className="h-13 border-b border-border" />}><PlayerControlsisPlaying={isPlaying}currentTime={currentTime}@@ -2971,6 +2972,8 @@ export default function Editor() {canSplitClip={canSplitClip}/>+ </Suspense>+<Suspense fallback={<TimelineSkeleton />}><TimelinevideoDuration={videoDuration}diff --git a/app/components/common/Header.tsx b/app/components/common/Header.tsxindex ca04cb5..e5fcab5 100644--- a/app/components/common/Header.tsx+++ b/app/components/common/Header.tsx@@ -13,7 +13,6 @@ import { Button } from "@/components/ui/button";import { useRecording } from "@/app/contexts/RecordingContext";import RecordingSetupDialog from "../ui/RecordingSetupDialog";import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";-import { driver } from "driver.js";export default function Header() {const t = useTranslations("header");@@ -49,48 +48,50 @@ export default function Header() {const driverTimer = setTimeout(() => {if (getIsMobileSnapshot()) return;if (document.getElementById("tour-video-upload")) {- const driverObj = driver({- showProgress: true,- animate: true,- nextBtnText: tTour("nextBtn"),- prevBtnText: tTour("prevBtn"),- doneBtnText: tTour("doneBtn"),- popoverClass: "minimal-dark-theme",- onDestroyed: () => {- localStorage.setItem("openvid-tour-completed", "true");- },- steps: [- {- element: "#tour-record-btn",- popover: {- title: tTour("step1.title"),- description: `${tTour("step1.description")} <a href="/guide" target="_blank" style="color: #60a5fa; text-decoration: underline;">${tTour("step1.guideLinkText")}</a>`,- side: "bottom",- align: "center",- },+ import("driver.js").then(({ driver }) => {+ const driverObj = driver({+ showProgress: true,+ animate: true,+ nextBtnText: tTour("nextBtn"),+ prevBtnText: tTour("prevBtn"),+ doneBtnText: tTour("doneBtn"),+ popoverClass: "minimal-dark-theme",+ onDestroyed: () => {+ localStorage.setItem("openvid-tour-completed", "true");},- {- element: "#tour-video-upload",- popover: {- title: tTour("step2.title"),- description: tTour("step2.description"),- side: "bottom",- align: "center",+ steps: [+ {+ element: "#tour-record-btn",+ popover: {+ title: tTour("step1.title"),+ description: `${tTour("step1.description")} <a href="/guide" target="_blank" style="color: #60a5fa; text-decoration: underline;">${tTour("step1.guideLinkText")}</a>`,+ side: "bottom",+ align: "center",+ },},- },- {- element: "#tour-photo-upload",- popover: {- title: tTour("step3.title"),- description: tTour("step3.description"),- side: "bottom",- align: "center",+ {+ element: "#tour-video-upload",+ popover: {+ title: tTour("step2.title"),+ description: tTour("step2.description"),+ side: "bottom",+ align: "center",+ },},- },- ],- });+ {+ element: "#tour-photo-upload",+ popover: {+ title: tTour("step3.title"),+ description: tTour("step3.description"),+ side: "bottom",+ align: "center",+ },+ },+ ],+ });- driverObj.drive();+ driverObj.drive();+ });}}, 800);@@ -211,4 +212,4 @@ export default function Header() {/></>);-}\ No newline at end of file+}diff --git a/app/components/common/MobileMenu.tsx b/app/components/common/MobileMenu.tsxindex f212261..831f9fc 100644--- a/app/components/common/MobileMenu.tsx+++ b/app/components/common/MobileMenu.tsx@@ -1,7 +1,7 @@"use client";import { useState, useEffect } from "react";-import { Link } from "@/navigation";+import { Link, useRouter } from "@/navigation";import { Icon } from "@iconify/react";import { useAuth } from "@/app/contexts/useAuth";import { hasAnyVideo } from "@/lib/video-cache-utils";@@ -12,6 +12,7 @@ import { useTranslations } from "next-intl";export function MobileMenu() {const t = useTranslations('header');+ const router = useRouter();const [isOpen, setIsOpen] = useState(false);const [hasCachedVideo, setHasCachedVideo] = useState(false);const { user, signOut } = useAuth();@@ -49,7 +50,7 @@ export function MobileMenu() {try {await signOut();setIsOpen(false);- window.location.href = "/";+ router.push("/");} catch (error) {console.error("Error signing out:", error);setIsLoggingOut(false);@@ -128,17 +129,16 @@ export function MobileMenu() {<Icon icon="solar:external-link-linear" className="w-4 h-4 ml-auto opacity-50" aria-hidden="true" /></a>- <a+ <Linkhref="/donate"target="_blank"- rel="noopener noreferrer"onClick={closeMenu}className="flex items-center gap-3 px-4 py-3 text-neutral-300 hover:text-white hover:bg-white/5 rounded-lg transition-colors"><Icon icon="mdi:donate" className="w-5 h-5" aria-hidden="true" /><span>{t('donate')}</span><Icon icon="solar:external-link-linear" className="w-4 h-4 ml-auto opacity-50" aria-hidden="true" />- </a>+ </Link></div></nav>@@ -179,4 +179,4 @@ export function MobileMenu() {</Dialog.Portal></Dialog.Root>);-}\ No newline at end of file+}diff --git a/app/components/common/UserMenuDropdown.tsx b/app/components/common/UserMenuDropdown.tsxindex 08fef9f..1a0933d 100644--- a/app/components/common/UserMenuDropdown.tsx+++ b/app/components/common/UserMenuDropdown.tsx@@ -6,7 +6,7 @@ import { useAuth } from "@/app/contexts/useAuth";import * as DropdownMenu from "@radix-ui/react-dropdown-menu";import { useTranslations } from "next-intl";import { createClient } from "@/utils/supabase/client";-import { usePathname } from "@/navigation";+import { usePathname, useRouter } from "@/navigation";type Theme = "light" | "dark" | "system";@@ -65,6 +65,7 @@ export function UserMenuDropdown({const t = useTranslations('userMenu');const { user, profile } = useAuth();const pathname = usePathname();+ const router = useRouter();const isEditorPage = pathname.startsWith("/editor");const [theme, setTheme] = useState<Theme>("system");const [isSavingTheme, setIsSavingTheme] = useState(false);@@ -124,7 +125,7 @@ export function UserMenuDropdown({user?.email?.split("@")[0] ||t('defaultUser');const provider = profile?.provider || meta.provider || "email";- const editorHref = editorMode === "video" ? "/editor?mode=photo" : "/editor";+ const editorHref = editorMode === "video" ? "/editor?mode=photo" : "/editor?mode=video";const editorLabel = editorMode === "video" ? t("photoEditor") : editorMode === "photo" ? t("videoEditor") : t("editor");const editorIcon = editorMode === "video" ? "solar:gallery-wide-linear" : "solar:video-frame-cut-2-linear";@@ -154,10 +155,10 @@ export function UserMenuDropdown({</DropdownMenu.Item><DropdownMenu.Item asChild>- <a href={editorHref} className={itemClasses}>+ <Link href={editorHref} className={itemClasses}><Icon icon={editorIcon} className="size-4" aria-hidden="true" /><span>{editorLabel}</span>- </a>+ </Link></DropdownMenu.Item>{showTheme && (@@ -202,14 +203,14 @@ export function UserMenuDropdown({<DropdownMenu.Separator className="h-px bg-border my-1" />- <SignOutItem />+ <SignOutItem router={router} /></DropdownMenu.Content></DropdownMenu.Portal></DropdownMenu.Root>);}-function SignOutItem() {+function SignOutItem({ router }: { router: ReturnType<typeof useRouter> }) {const t = useTranslations('userMenu');const { signOut } = useAuth();const [isLoggingOut, setIsLoggingOut] = useState(false);@@ -218,7 +219,7 @@ function SignOutItem() {setIsLoggingOut(true);try {await signOut();- window.location.href = "/";+ router.push("/");} catch (error) {console.error("Error signing out:", error);setIsLoggingOut(false);diff --git a/app/components/ui/Skeleton.tsx b/app/components/ui/Skeleton.tsxindex 36ea810..fdff1ba 100644--- a/app/components/ui/Skeleton.tsx+++ b/app/components/ui/Skeleton.tsx@@ -442,54 +442,54 @@ export function AudioMenuSkeleton() {}export function VideosMenuSkeleton() {- return (- <div className="p-4 flex flex-col gap-5 h-full relative">-- <div className="flex items-center gap-2">- <Skeleton width={20} height={20} variant="circle" />- <Skeleton height={16} width={50} />- </div>-- <div className="flex-1 overflow-y-hidden flex flex-col gap-2 -mx-1 px-1">-- <div className="mb-4">- <Skeleton height={32} variant="square" className="w-full rounded-md" />- </div>+ return (+ <div className="p-4 flex flex-col gap-5 h-full relative">- <div className="flex flex-col gap-2">- {Array.from({ length: 3 }).map((_, i) => (- <div- key={i}- className="bg-muted/30 border border-border squircle-element overflow-hidden p-2.5 flex items-center gap-3"- >- <div className="shrink-0">- <Skeleton width={80} height={48} variant="square" className="rounded-md" />- </div>-- <div className="flex-1 min-w-0 flex flex-col justify-center gap-2">- <Skeleton height={12} width="85%" />- <div className="flex items-center gap-2">- <Skeleton height={10} width="35%" />- <Skeleton height={10} width={8} />- <Skeleton height={10} width="30%" />+ <div className="flex items-center gap-2">+ <Skeleton width={20} height={20} variant="circle" />+ <Skeleton height={16} width={50} />+ </div>++ <div className="flex-1 overflow-y-hidden flex flex-col gap-2 -mx-1 px-1">++ <div className="mb-4">+ <Skeleton height={32} variant="square" className="w-full rounded-md" />+ </div>++ <div className="flex flex-col gap-2">+ {Array.from({ length: 3 }).map((_, i) => (+ <div+ key={i}+ className="bg-muted/30 border border-border squircle-element overflow-hidden p-2.5 flex items-center gap-3"+ >+ <div className="shrink-0">+ <Skeleton width={80} height={48} variant="square" className="rounded-md" />+ </div>++ <div className="flex-1 min-w-0 flex flex-col justify-center gap-2">+ <Skeleton height={12} width="85%" />+ <div className="flex items-center gap-2">+ <Skeleton height={10} width="35%" />+ <Skeleton height={10} width={8} />+ <Skeleton height={10} width="30%" />+ </div>+ </div>++ <div className="flex items-center gap-1 shrink-0">+ <Skeleton width={28} height={28} variant="square" className="rounded-md" />+ <Skeleton width={28} height={28} variant="square" className="rounded-md" />+ </div>+ </div>+ ))}</div>- </div>+ </div>- <div className="flex items-center gap-1 shrink-0">- <Skeleton width={28} height={28} variant="square" className="rounded-md" />- <Skeleton width={28} height={28} variant="square" className="rounded-md" />- </div>+ <div className="pt-2 border-t border-border shrink-0 flex justify-center">+ <Skeleton height={10} width="70%" /></div>- ))}+</div>- </div>-- <div className="pt-2 border-t border-border shrink-0 flex justify-center">- <Skeleton height={10} width="70%" />- </div>-- </div>- );+ );}export function HistoryMenuSkeleton() {@@ -503,10 +503,10 @@ export function HistoryMenuSkeleton() {<div className="grid grid-cols-2 gap-3">{Array.from({ length: 6 }).map((_, i) => (<div key={i} className="flex flex-col gap-2 p-2 rounded-lg bg-muted/40 border border-border">- <Skeleton- variant="square"- className="w-full rounded-md"- style={{ aspectRatio: "16/9" } as React.CSSProperties}+ <Skeleton+ variant="square"+ className="w-full rounded-md"+ style={{ aspectRatio: "16/9" } as React.CSSProperties}/><div className="space-y-1.5 mt-1"><Skeleton height={10} width="80%" />@@ -521,89 +521,89 @@ export function HistoryMenuSkeleton() {}export function MotionGlobalConfigSkeleton() {- return (- <div className="p-4 flex flex-col gap-4 h-full relative">- <div className="flex items-center gap-2 shrink-0">- <Skeleton width={20} height={20} variant="circle" />- <Skeleton height={14} width={50} />- </div>-- <div className="flex-1 overflow-y-hidden -mx-1 px-1">- <div className="flex flex-col gap-6">- {[6, 6, 2].map((count, sectionIndex) => (- <div key={sectionIndex}>- <div className="flex items-center gap-2 mb-3">- <Skeleton height={9} width={60} />- <div className="h-px flex-1 bg-muted" />- </div>-- <div className="grid grid-cols-2 gap-2.5">- {Array.from({ length: count }).map((_, i) => (- <div- key={i}- className="squircle-element-camera border border-border bg-card p-2 flex flex-col gap-2"- >- <Skeleton- variant="square"- className="w-full aspect-[16/10] rounded-lg"- />- <Skeleton height={9} width="75%" />- </div>+ return (+ <div className="p-4 flex flex-col gap-4 h-full relative">+ <div className="flex items-center gap-2 shrink-0">+ <Skeleton width={20} height={20} variant="circle" />+ <Skeleton height={14} width={50} />+ </div>++ <div className="flex-1 overflow-y-hidden -mx-1 px-1">+ <div className="flex flex-col gap-6">+ {[2, 2].map((count, sectionIndex) => (+ <div key={sectionIndex}>+ <div className="flex items-center gap-2 mb-3">+ <Skeleton height={9} width={60} />+ <div className="h-px flex-1 bg-muted" />+ </div>++ <div className="grid grid-cols-2 gap-2.5">+ {Array.from({ length: count }).map((_, i) => (+ <div+ key={i}+ className="squircle-element-camera border border-border bg-card p-2 flex flex-col gap-2"+ >+ <Skeleton+ variant="square"+ className="w-full aspect-[16/10] rounded-lg"+ />+ <Skeleton height={9} width="75%" />+ </div>+ ))}+ </div>+ </div>+ ))}+ </div>+ </div>++ <div className="shrink-0 flex flex-col gap-4 pt-4 border-t border-border">+ {Array.from({ length: 2 }).map((_, i) => (+ <div key={i} className="flex items-center gap-3">+ <Skeleton width={14} height={14} variant="circle" />+ <Skeleton height={10} width={70} />+ <Skeleton height={6} className="flex-1" variant="default" />+ <Skeleton height={10} width={24} />+ </div>))}- </div></div>- ))}</div>- </div>-- <div className="shrink-0 flex flex-col gap-4 pt-4 border-t border-border">- {Array.from({ length: 2 }).map((_, i) => (- <div key={i} className="flex items-center gap-3">- <Skeleton width={14} height={14} variant="circle" />- <Skeleton height={10} width={70} />- <Skeleton height={6} className="flex-1" variant="default" />- <Skeleton height={10} width={24} />- </div>- ))}- </div>- </div>- );+ );}export function MotionFragmentEditorSkeleton() {- return (- <div className="flex flex-col h-full">- <div className="flex items-center gap-2 p-3 border-b border-border shrink-0">- <Skeleton width={28} height={28} variant="square" />- <Skeleton height={14} width={120} />- </div>-- <div className="flex-1 overflow-y-auto px-4 py-4 space-y-6">-- <div className="flex flex-col gap-4">- <Skeleton height={44} variant="square" className="rounded-lg w-full" />- <Skeleton height={44} variant="square" className="rounded-lg w-full" />- </div>+ return (+ <div className="flex flex-col h-full">+ <div className="flex items-center gap-2 p-3 border-b border-border shrink-0">+ <Skeleton width={28} height={28} variant="square" />+ <Skeleton height={14} width={120} />+ </div>- <div className="space-y-6 p-4 bg-muted/40 border border-border squircle-element">-- <div className="flex items-center gap-3">- <Skeleton width={20} height={20} variant="circle" />- <Skeleton height={14} width="50%" />- </div>+ <div className="flex-1 overflow-y-auto px-4 py-4 space-y-6">- <div className="flex flex-col gap-5 items-center w-full">- <Skeleton height={160} variant="square" className="w-full rounded-xl" />- <Skeleton variant="circle" className="aspect-square w-full max-w-[180px]" />- </div>+ <div className="flex flex-col gap-4">+ <Skeleton height={44} variant="square" className="rounded-lg w-full" />+ <Skeleton height={44} variant="square" className="rounded-lg w-full" />+ </div>- <div className="space-y-3 pt-2">- <Skeleton height={40} variant="square" className="rounded-lg w-full" />- <Skeleton height={40} variant="square" className="rounded-lg w-full" />- </div>+ <div className="space-y-6 p-4 bg-muted/40 border border-border squircle-element">+ <div className="flex items-center gap-3">+ <Skeleton width={20} height={20} variant="circle" />+ <Skeleton height={14} width="50%" />+ </div>++ <div className="flex flex-col gap-5 items-center w-full">+ <Skeleton height={160} variant="square" className="w-full rounded-xl" />+ <Skeleton variant="circle" className="aspect-square w-full max-w-[180px]" />+ </div>++ <div className="space-y-3 pt-2">+ <Skeleton height={40} variant="square" className="rounded-lg w-full" />+ <Skeleton height={40} variant="square" className="rounded-lg w-full" />+ </div>++ </div>+ </div></div>- </div>- </div>- );+ );}\ No newline at end of filediff --git a/app/components/ui/editor/ToolsSidebar.tsx b/app/components/ui/editor/ToolsSidebar.tsxindex 244bbd2..7d92f90 100644--- a/app/components/ui/editor/ToolsSidebar.tsx+++ b/app/components/ui/editor/ToolsSidebar.tsx@@ -61,41 +61,28 @@ export function ToolsSidebar({const isPhotoMode = editorMode === "photo";+ // Consolidated scroll-into-view: a single effect avoids multiple forced+ // synchronous layouts. Using 'auto' (instant) instead of 'smooth' prevents+ // a long-running scroll animation from blocking the main thread on selection.useEffect(() => {- if (newVideosCount > 0 && videosToolRef.current && activeTool !== "video") {- videosToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });+ let targetRef: React.RefObject<HTMLButtonElement | null> | null = null;++ if (newVideosCount > 0 && activeTool !== "video") {+ targetRef = videosToolRef;+ } else if (selectedZoomFragmentId) {+ targetRef = zoomToolRef;+ } else if (selectedAudioTrackId) {+ targetRef = audioToolRef;+ } else if (selectedVideoClipId) {+ targetRef = videosToolRef;+ } else if (activeTool === "camera") {+ targetRef = cameraToolRef;+ } else if (selectedElementId) {+ targetRef = elementsToolRef;}- }, [newVideosCount, activeTool]);- useEffect(() => {- if (selectedZoomFragmentId && zoomToolRef.current) {- zoomToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });- }- }, [selectedZoomFragmentId]);-- useEffect(() => {- if (selectedAudioTrackId && audioToolRef.current) {- audioToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });- }- }, [selectedAudioTrackId]);-- useEffect(() => {- if (selectedVideoClipId && videosToolRef.current) {- videosToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });- }- }, [selectedVideoClipId]);-- useEffect(() => {- if (activeTool === "camera" && cameraToolRef.current) {- cameraToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });- }- }, [activeTool]);-- useEffect(() => {- if (selectedElementId && elementsToolRef.current) {- elementsToolRef.current.scrollIntoView({ behavior: 'smooth', block: 'center' });- }- }, [selectedElementId]);+ targetRef?.current?.scrollIntoView({ block: 'center' });+ }, [newVideosCount, activeTool, selectedZoomFragmentId, selectedAudioTrackId, selectedVideoClipId, selectedElementId]);const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {const file = e.target.files?.[0];@@ -509,4 +496,4 @@ export function ToolsSidebar({)}</div>);-}\ No newline at end of file+}diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsxindex b0ff44d..59d5393 100644--- a/app/components/ui/editor/VideoCanvas.tsx+++ b/app/components/ui/editor/VideoCanvas.tsx@@ -435,7 +435,7 @@ function VideoCanvasInner({lastSetVideoUrlRef.current = null;lastLogicalUrlRef.current = null;}- }, [videoUrl, activeClipUrl, videoRef, mockupId]);+ }, [videoUrl, activeClipUrl, videoRef, mockupId, mediaType]);// Track the real intrinsic aspect ratio of the video so the "none"useEffect(() => {diff --git a/app/components/ui/editor/mockups-3d/Mockup3DFrame.tsx b/app/components/ui/editor/mockups-3d/Mockup3DFrame.tsxindex a43d5ba..9b9f010 100644--- a/app/components/ui/editor/mockups-3d/Mockup3DFrame.tsx+++ b/app/components/ui/editor/mockups-3d/Mockup3DFrame.tsx@@ -120,6 +120,13 @@ export function Mockup3DFrame({ device, ...stageProps }: FrameProps) {return () => window.removeEventListener("pointerup", onWinPointerUp);}, []);+ const hoverRafRef = useRef<number | null>(null);+ useEffect(() => {+ return () => {+ if (hoverRafRef.current !== null) cancelAnimationFrame(hoverRafRef.current);+ };+ }, []);+const overlayStyle: React.CSSProperties =layout.overlay.kind === "inset"? { position: "absolute", inset: `-${layout.overlay.inset}px`, zIndex: 2, overflow: "visible" }@@ -181,13 +188,17 @@ export function Mockup3DFrame({ device, ...stageProps }: FrameProps) {setGrabbing(true);}}onPointerMove={(e) => {- if (!grabbing) {- const isCurrentlyHovering = hitsModel(e.clientX, e.clientY);- if (isCurrentlyHovering !== modelHovered) {- setModelHovered(isCurrentlyHovering);- stageProps.onHoverChange?.(isCurrentlyHovering);+ if (grabbing || hoverRafRef.current !== null) return;+ const clientX = e.clientX;+ const clientY = e.clientY;+ hoverRafRef.current = requestAnimationFrame(() => {+ hoverRafRef.current = null;+ const hit = hitsModel(clientX, clientY);+ if (hit !== modelHovered) {+ setModelHovered(hit);+ stageProps.onHoverChange?.(hit);}- }+ });}}onPointerUp={() => setGrabbing(false)}onPointerLeave={() => {diff --git a/app/components/ui/home/Hero.tsx b/app/components/ui/home/Hero.tsxindex de61008..c7b4d0b 100644--- a/app/components/ui/home/Hero.tsx+++ b/app/components/ui/home/Hero.tsx@@ -4,9 +4,10 @@ import { useRef, useState, useCallback } from "react";import { saveUploadedVideo, clearVideoTrack } from "@/lib/video-upload-cache";import { saveUploadedImage } from "@/lib/image-upload-cache";import { clearVideoProjectAndAudios } from "@/lib/video-project-cache";-import { useLocale, useTranslations } from "next-intl";+import { useTranslations } from "next-intl";import Link from "next/link";import GitHubBadge from "@/components/ui/GitHubStars";+import { useRouter } from "@/navigation";interface HeroProps {onVideoUpload?: (file: File) => void;@@ -15,7 +16,7 @@ interface HeroProps {export default function Hero({ onVideoUpload, onPhotoUpload }: HeroProps) {const t = useTranslations("hero");- const locale = useLocale();+ const router = useRouter();const videoInputRef = useRef<HTMLInputElement>(null);const [isDraggingVideo, setIsDraggingVideo] = useState(false);@@ -32,13 +33,13 @@ export default function Hero({ onVideoUpload, onPhotoUpload }: HeroProps) {if (onVideoUpload) {onVideoUpload(file);}- window.location.href = `/${locale}/editor?mode=video`;+ router.push("/editor?mode=video");} catch (error) {console.error("Error uploading video:", error);setIsUploadingVideo(false);}},- [onVideoUpload, locale]+ [onVideoUpload, router]);const handleVideoFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {@@ -78,13 +79,13 @@ export default function Hero({ onVideoUpload, onPhotoUpload }: HeroProps) {if (onPhotoUpload) {onPhotoUpload(file);}- window.location.href = `/${locale}/editor?mode=photo`;+ router.push("/editor?mode=photo");} catch (error) {console.error("Error uploading photo:", error);setIsUploadingPhoto(false);}},- [onPhotoUpload, locale]+ [onPhotoUpload, router]);const handlePhotoFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {diff --git a/app/contexts/Mockup3dContext.tsx b/app/contexts/Mockup3dContext.tsxindex 7753fb5..f80bd65 100644--- a/app/contexts/Mockup3dContext.tsx+++ b/app/contexts/Mockup3dContext.tsx@@ -1,6 +1,6 @@"use client";-import { createContext, useContext, useState, useEffect, useRef, type ReactNode } from "react";+import { createContext, useContext, useState, useEffect, useRef, useMemo, type ReactNode } from "react";import { DEVICE_VIEWER_DEFAULTS } from "@/lib/phone3d.utils";import type { EnvironmentPreset } from "@/lib/viewer-controls3d";@@ -100,30 +100,39 @@ export function Mockup3dProvider({ children }: { children: ReactNode }) {setViewer3DEnvironment(defaults.environment);}, [imagePhoneDevice]);+ const value = useMemo(() => ({+ selectedTemplateId, setSelectedTemplateId,+ motionImageUrl, setMotionImageUrl,+ motionIntensity, setMotionIntensity,+ imagePhoneActive, setImagePhoneActive,+ imagePhoneX, setImagePhoneX,+ imagePhoneY, setImagePhoneY,+ imagePhoneScale, setImagePhoneScale,+ imagePhoneRotX, setImagePhoneRotX,+ imagePhoneRotY, setImagePhoneRotY,+ imagePhoneRotZ, setImagePhoneRotZ,+ imagePhonePerspective, setImagePhonePerspective,+ imagePhoneDevice, setImagePhoneDevice,+ imagePhonePresetId, setImagePhonePresetId,+ imagePhoneOpening, setImagePhoneOpening,+ imagePhoneShadow, setImagePhoneShadow,+ imagePhoneShadowColor, setImagePhoneShadowColor,+ imagePhoneRefWidth, setImagePhoneRefWidth,+ viewer3DAutoRotate, setViewer3DAutoRotate,+ viewer3DRotationSpeed, setViewer3DRotationSpeed,+ viewer3DGlow, setViewer3DGlow,+ viewer3DEnvironment, setViewer3DEnvironment,+ }), [+ selectedTemplateId, motionImageUrl, motionIntensity,+ imagePhoneActive, imagePhoneX, imagePhoneY, imagePhoneScale,+ imagePhoneRotX, imagePhoneRotY, imagePhoneRotZ, imagePhonePerspective,+ imagePhoneDevice, imagePhonePresetId, imagePhoneOpening,+ imagePhoneShadow, imagePhoneShadowColor, imagePhoneRefWidth,+ viewer3DAutoRotate, viewer3DRotationSpeed, viewer3DGlow, viewer3DEnvironment,+ ]);+return (- <Mockup3dContext.Provider value={{- selectedTemplateId, setSelectedTemplateId,- motionImageUrl, setMotionImageUrl,- motionIntensity, setMotionIntensity,- imagePhoneActive, setImagePhoneActive,- imagePhoneX, setImagePhoneX,- imagePhoneY, setImagePhoneY,- imagePhoneScale, setImagePhoneScale,- imagePhoneRotX, setImagePhoneRotX,- imagePhoneRotY, setImagePhoneRotY,- imagePhoneRotZ, setImagePhoneRotZ,- imagePhonePerspective, setImagePhonePerspective,- imagePhoneDevice, setImagePhoneDevice,- imagePhonePresetId, setImagePhonePresetId,- imagePhoneOpening, setImagePhoneOpening,- imagePhoneShadow, setImagePhoneShadow,- imagePhoneShadowColor, setImagePhoneShadowColor,- imagePhoneRefWidth, setImagePhoneRefWidth,- viewer3DAutoRotate, setViewer3DAutoRotate,- viewer3DRotationSpeed, setViewer3DRotationSpeed,- viewer3DGlow, setViewer3DGlow,- viewer3DEnvironment, setViewer3DEnvironment,- }}>+ <Mockup3dContext.Provider value={value}>{children}</Mockup3dContext.Provider>);@@ -133,4 +142,4 @@ export function useMockup3dContext() {const ctx = useContext(Mockup3dContext);if (!ctx) throw new Error("useMockup3dContext must be used inside Mockup3dProvider");return ctx;-}\ No newline at end of file+}diff --git a/hooks/useActiveTool.ts b/hooks/useActiveTool.tsindex e15810a..0ae62f4 100644--- a/hooks/useActiveTool.ts+++ b/hooks/useActiveTool.ts@@ -1,7 +1,7 @@"use client";-import { useCallback } from "react";-import { usePathname, useRouter, useSearchParams } from "next/navigation";+import { useCallback, useState } from "react";+import { usePathname, useSearchParams } from "next/navigation";import type { Tool } from "@/types/editor.types";const VALID_TOOLS: ReadonlySet<Tool> = new Set<Tool>([@@ -25,17 +25,22 @@ function parseTool(value: string | null): Tool {}export function useActiveTool(): [Tool, (next: Tool) => void] {- const router = useRouter();const pathname = usePathname();const searchParams = useSearchParams();- const tool = parseTool(searchParams.get("menu"));+ const urlTool = parseTool(searchParams.get("menu"));+ const [override, setOverride] = useState<Tool | null>(null);+ const [overrideFor, setOverrideFor] = useState<Tool>(urlTool);+ const effectiveOverride = overrideFor === urlTool ? override : null;+ const tool = effectiveOverride ?? urlTool;const setTool = useCallback((next: Tool) => {- const params = new URLSearchParams(searchParams.toString());+ setOverrideFor(urlTool);+ setOverride(next);+ const params = new URLSearchParams(window.location.search);params.set("menu", next);- router.replace(`${pathname}?${params.toString()}`);- }, [router, pathname, searchParams]);+ window.history.replaceState(null, "", `${pathname}?${params.toString()}`);+ }, [pathname, urlTool]);return [tool, setTool];}