Create professional demos and 3D mockups in seconds, directly in your browser
feat: refactor motion menu components and introduce new motion fragment editor
CristianOlivera1f575347788d8
diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsxindex f6aecc8..e992997 100644--- a/app/[locale]/(editor)/editor/page.tsx+++ b/app/[locale]/(editor)/editor/page.tsx@@ -1150,7 +1150,7 @@ export default function Editor() {}} catch (error) {console.error('Error uploading audio:', error);- alert('Error al subir el audio. Por favor intenta de nuevo.');+ alert('Error uploading the audio. Please try again.');}}, [audioTracks, videoDuration]);diff --git a/app/components/ui/Skeleton.tsx b/app/components/ui/Skeleton.tsxindex 96e237a..11e8cb3 100644--- a/app/components/ui/Skeleton.tsx+++ b/app/components/ui/Skeleton.tsx@@ -520,7 +520,7 @@ export function HistoryMenuSkeleton() {);}-export function MotionMenuSkeleton() {+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">@@ -568,4 +568,42 @@ export function MotionMenuSkeleton() {</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-white/6 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>++ <div className="space-y-6 p-4 bg-white/3 border border-white/8 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>+ );}\ No newline at end of filediff --git a/app/components/ui/editor/ControlPanel.tsx b/app/components/ui/editor/ControlPanel.tsxindex 2be049c..1e652c6 100644--- a/app/components/ui/editor/ControlPanel.tsx+++ b/app/components/ui/editor/ControlPanel.tsx@@ -10,13 +10,12 @@ import Image from "next/image";import { lazy, Suspense, useState } from "react";import { useTranslations } from "next-intl";-import { ElementsMenuSkeleton, ZoomGlobalConfigSkeleton, MockupMenuSkeleton, WallpaperSkeleton, BackgroundColorSkeleton, ZoomFragmentEditorSkeleton, AudioMenuSkeleton, VideosMenuSkeleton, HistoryMenuSkeleton, MotionMenuSkeleton } from "../Skeleton";+import { ElementsMenuSkeleton, ZoomGlobalConfigSkeleton, MockupMenuSkeleton, WallpaperSkeleton, BackgroundColorSkeleton, ZoomFragmentEditorSkeleton, AudioMenuSkeleton, VideosMenuSkeleton, HistoryMenuSkeleton, MotionGlobalConfigSkeleton, MotionFragmentEditorSkeleton } from "../Skeleton";import { ElementsMenu } from "./ElementsMenu";import { TooltipAction } from "@/components/ui/tooltip-action";import { CameraMenu } from "./CameraMenu";import { useMockup3dContext } from "@/app/contexts/Mockup3dContext";-import { MotionMenu } from "./MotionMenu";const BackgroundColorEditor = lazy(() => import("../BackgroundColorEditor").then(mod => ({ default: mod.BackgroundColorEditor })));const ZoomFragmentEditor = lazy(() => import("./ZoomFragmentEditor").then(mod => ({ default: mod.ZoomFragmentEditor })));@@ -27,6 +26,8 @@ const MockupMenu = lazy(() => import("./MockupMenu").then(mod => ({ default: modconst AudioMenu = lazy(() => import("./AudioMenu").then(mod => ({ default: mod.AudioMenu })));const VideosMenu = lazy(() => import("./VideosMenu").then(mod => ({ default: mod.VideosMenu })));const HistoryMenu = lazy(() => import("./HistoryMenu").then(mod => ({ default: mod.HistoryMenu })));+const MotionGlobalConfig = lazy(() => import("./MotionGlobalConfig").then(mod => ({ default: mod.MotionGlobalConfig })));+const MotionFragmentEditor = lazy(() => import("./MotionFragmentEditor").then(mod => ({ default: mod.MotionFragmentEditor })));interface ExtendedControlPanelProps extends ControlPanelProps {onTogglePanel?: () => void;@@ -130,6 +131,8 @@ export function ControlPanel({const t = useTranslations("controlPanel");const { imagePhoneActive } = useMockup3dContext();const [isGlobalMotionEnabled, setIsGlobalMotionEnabled] = useState(true);+ const hasMockup2D = mediaType === "video" && !imagePhoneActive;+return (<div className="relative w-full sm:w-[320px] h-screen bg-[#141417] border-r border-white/10 flex flex-col shrink-0" role="complementary" aria-label="Control panel"><header className="flex items-center justify-between h-13 p-2 border-b border-white/10 shrink-0" role="banner">@@ -270,23 +273,37 @@ export function ControlPanel({</Suspense>)}{activeTool === "motion" && (- <Suspense fallback={<MotionMenuSkeleton />}>- <MotionMenu- fragments={mockupMotionFragments}- selectedFragment={selectedMockupMotionFragment}- onAddOrReplacePreset={(presetId) => onAddOrReplaceMotionPreset?.(presetId)}- onUpdateSelectedFragment={(updates) =>- selectedMockupMotionFragmentId &&- onUpdateMockupMotionFragment?.(selectedMockupMotionFragmentId, updates)- }- onSelectFragment={(id) => onSelectMockupMotionFragment?.(id)}- onDeleteFragment={(id) => onDeleteMockupMotionFragment?.(id)}- mediaType={mediaType}- mockupId={mockupId}- isGlobalMotionEnabled={isGlobalMotionEnabled}- onToggleGlobalMotion={setIsGlobalMotionEnabled}- />- </Suspense>+ <>+ {selectedMockupMotionFragment && hasMockup2D ? (+ <Suspense fallback={<MotionFragmentEditorSkeleton />}>+ <MotionFragmentEditor+ fragment={selectedMockupMotionFragment}+ isGlobalMotionEnabled={isGlobalMotionEnabled}+ onUpdate={(updates) =>+ selectedMockupMotionFragmentId &&+ onUpdateMockupMotionFragment?.(selectedMockupMotionFragmentId, updates)+ }+ onDelete={() => {+ if (selectedMockupMotionFragmentId) {+ onDeleteMockupMotionFragment?.(selectedMockupMotionFragmentId);+ }+ onSelectMockupMotionFragment?.(null);+ }}+ onClose={() => onSelectMockupMotionFragment?.(null)}+ />+ </Suspense>+ ) : (+ <Suspense fallback={<MotionGlobalConfigSkeleton />}>+ <MotionGlobalConfig+ fragments={mockupMotionFragments}+ onAddOrReplacePreset={(presetId) => onAddOrReplaceMotionPreset?.(presetId)}+ hasMockup2D={hasMockup2D}+ isGlobalMotionEnabled={isGlobalMotionEnabled}+ onToggleGlobalMotion={setIsGlobalMotionEnabled}+ />+ </Suspense>+ )}+ </>)}{activeTool === "video" && (diff --git a/app/components/ui/editor/MockupMotionTrackItem.tsx b/app/components/ui/editor/MockupMotionTrackItem.tsxindex b4134d1..6f7df9e 100644--- a/app/components/ui/editor/MockupMotionTrackItem.tsx+++ b/app/components/ui/editor/MockupMotionTrackItem.tsx@@ -3,7 +3,6 @@import { useState, useCallback, useEffect, useMemo } from "react";import { motion, useMotionValue } from "framer-motion";import type { MockupMotionFragment } from "@/lib/mockup-motion";-import { MOCKUP_MOTION_PRESETS } from "@/lib/mockup-motion";import { useTranslations } from "next-intl";const MIN_FRAGMENT_DURATION = 0.3;diff --git a/app/components/ui/editor/MotionFragmentEditor.tsx b/app/components/ui/editor/MotionFragmentEditor.tsxnew file mode 100644index 0000000..30ea5f7--- /dev/null+++ b/app/components/ui/editor/MotionFragmentEditor.tsx@@ -0,0 +1,154 @@+"use client";++import { Icon } from "@iconify/react";+import { useTranslations } from "next-intl";+import { SliderControl } from "../../../../components/ui/SliderControl";+import { Toggle } from "@/components/ui/toggle";+import {+ MockupMotionFragment,+ DEFAULT_MOTION_CUSTOM_OFFSETS,+ type MotionCustomOffsets,+} from "@/lib/mockup-motion";+import {+ MotionPresetIconStyles,+} from "../../../../components/ui/MotionPresetIcon";+import { DirectionPad } from "@/components/ui/DirectionPad";+import { PositionPad } from "@/components/ui/PositionPad";+import { TooltipAction } from "@/components/ui/tooltip-action";+import { DetailPageHeader } from "@/components/ui/DetailHeaderMenu";++interface MotionFragmentEditorProps {+ fragment: MockupMotionFragment;+ isGlobalMotionEnabled: boolean;+ onUpdate: (updates: Partial<MockupMotionFragment>) => void;+ onDelete: () => void;+ onClose: () => void;+}++export function MotionFragmentEditor({+ fragment,+ onUpdate,+ onDelete,+ onClose,+}: MotionFragmentEditorProps) {+ const t = useTranslations("motionMenu");+ const custom = fragment.custom ?? DEFAULT_MOTION_CUSTOM_OFFSETS;++ const updateCustom = (partial: Partial<MotionCustomOffsets>) => {+ onUpdate({ custom: { ...custom, ...partial } });+ };++ const hasCustomChanges =+ custom.positionX !== 0 ||+ custom.positionY !== 0 ||+ custom.zoomMultiplier !== 1 ||+ custom.rotateX !== 0 ||+ custom.rotateY !== 0 ||+ custom.rotateZ !== 0 ||+ custom.blur !== 0 ||+ custom.reverse;++ return (+ <div className="flex flex-col h-full text-white">+ <MotionPresetIconStyles />++ <div className="flex items-center gap-2 p-3 border-b border-white/6 shrink-0">+ <DetailPageHeader label={t("title")} icon="ph:arrow-left-bold" onBack={onClose} />+ <TooltipAction label={t("deleteTooltip")}>+ <button+ onClick={onDelete}+ className="ml-auto flex items-center gap-1.5 text-[11px] text-red-400/70 hover:text-red-400 px-2 py-1 rounded-md transition-colors shrink-0"+ >+ <Icon icon="ph:trash-bold" width="12" />+ {t("actions.delete")}+ </button>+ </TooltipAction>+ </div>++ <div className="flex-1 overflow-y-auto custom-scrollbar px-4 py-4 space-y-5">+ <div className="flex flex-col gap-4">+ <SliderControl+ icon="mdi:tune-variant"+ label={t("controls.intensity")}+ value={fragment.intensity}+ min={0}+ max={100}+ onChange={(v: number) => onUpdate({ intensity: v })}+ />+ <SliderControl+ icon="mdi:speedometer"+ label={t("controls.speed")}+ value={fragment.speed}+ min={0}+ max={100}+ onChange={(v: number) => onUpdate({ speed: v })}+ />+ </div>++ <div className="space-y-3 p-3 bg-white/3 border border-white/8 squircle-element">+ <div className="flex items-center gap-2">+ <Icon icon="mdi:tune" width="16" className="text-white/60" />+ <div>+ <p className="text-xs font-medium text-white/80">{t("customize.title")}</p>+ <p className="text-[11px] text-white/40">{t("customize.subtitle")}</p>+ </div>+ </div>++ <PositionPad+ x={custom.positionX}+ y={custom.positionY}+ onChange={(x, y) => updateCustom({ positionX: x, positionY: y })}+ scale={custom.zoomMultiplier}+ rotateZ={custom.rotateZ}+ blur={custom.blur}+ accentRgb="249,115,22"+ label={t("customize.positionLabel")}+ hint={t("customize.positionHint")}+ />+ <DirectionPad+ angleX={custom.rotateX}+ angleY={custom.rotateY}+ onChange={(rx, ry) => updateCustom({ rotateX: rx, rotateY: ry })}+ accentRgb="249,115,22"+ label={t("customize.tiltLabel")}+ hint={t("customize.tiltHint")}+ className="aspect-square max-w-[220px]"+ />+ <SliderControl+ icon="mdi:magnify"+ label={t("customize.zoomLabel")}+ value={Math.round(custom.zoomMultiplier * 100)}+ min={50}+ max={200}+ onChange={(v: number) => updateCustom({ zoomMultiplier: v / 100 })}+ suffix="%"+ />+ <SliderControl+ icon="mdi:axis-z-rotate-clockwise"+ label={t("customize.rotateZLabel")}+ value={custom.rotateZ}+ min={-45}+ max={45}+ onChange={(v: number) => updateCustom({ rotateZ: v })}+ />+ <label className="flex items-center justify-between px-3 py-2.5 rounded-lg bg-white/[0.03] border border-white/5">+ <span className="text-xs text-white/60">{t("customize.reverseLabel")}</span>+ <Toggle+ checked={custom.reverse}+ onChange={(v: boolean) => updateCustom({ reverse: v })}+ activeColor="bg-orange-600"+ />+ </label>+ {hasCustomChanges && (+ <button+ onClick={() => onUpdate({ custom: { ...DEFAULT_MOTION_CUSTOM_OFFSETS } })}+ className="self-start text-xs text-white/40 hover:text-white transition-colors underline underline-offset-2"+ >+ {t("customize.resetButton")}+ </button>+ )}+ </div>+ </div>+ </div>+ );+}\ No newline at end of filediff --git a/app/components/ui/editor/MotionGlobalConfig.tsx b/app/components/ui/editor/MotionGlobalConfig.tsxnew file mode 100644index 0000000..fd78efc--- /dev/null+++ b/app/components/ui/editor/MotionGlobalConfig.tsx@@ -0,0 +1,98 @@+"use client";+import { Icon } from "@iconify/react";+import { useTranslations } from "next-intl";+import { MOCKUP_MOTION_PRESETS, type MockupMotionPresetId, MockupMotionFragment } from "@/lib/mockup-motion";+import { MotionPresetIcon, MotionPresetIconStyles } from "../../../../components/ui/MotionPresetIcon";+import { Toggle } from "@/components/ui/toggle";++interface MotionGlobalConfigProps {+ fragments: MockupMotionFragment[];+ onAddOrReplacePreset: (presetId: MockupMotionPresetId) => void;+ hasMockup2D: boolean;+ isGlobalMotionEnabled: boolean;+ onToggleGlobalMotion: (enabled: boolean) => void;+}++const CATEGORY_ORDER = ["Entrance", "Continue", "Exit"] as const;++export function MotionGlobalConfig({+ onAddOrReplacePreset,+ hasMockup2D,+ isGlobalMotionEnabled,+ onToggleGlobalMotion,+}: MotionGlobalConfigProps) {+ const t = useTranslations("motionMenu");++ if (!hasMockup2D) {+ return (+ <div className="p-4 flex flex-col gap-5 h-full relative">+ <div className="flex items-center justify-between shrink-0">+ <div className="flex items-center gap-2 text-white font-medium">+ <Icon icon="ph:film-strip-bold" width="20" aria-hidden="true" />+ <span>{t("title")}</span>+ </div>+ <label className="flex items-center gap-2 text-xs text-white/40">+ <span>{t("globalMotionLabel")}</span>+ <Toggle checked={isGlobalMotionEnabled} onChange={onToggleGlobalMotion} disabled={true} />+ </label>+ </div>+ <div className="group bg-[#09090B] border border-dashed border-white/10 squircle-element p-8 text-center transition-colors">+ <div className="w-12 h-12 rounded-full bg-white/5 border border-white/10 flex items-center justify-center mx-auto mb-4 group-hover:scale-105 transition-transform">+ <Icon icon="ph:frame-corners-bold" width="24" className="text-white/40 group-hover:text-white/70 transition-colors" aria-hidden="true" />+ </div>+ <p className="text-sm font-medium text-white/70 mb-1">{t("empty2D.title")}</p>+ <p className="text-xs text-white/40">{t("empty2D.description")}</p>+ </div>+ </div>+ );+ }++ return (+ <div className="p-4 flex flex-col gap-4 h-full relative min-h-0">+ <MotionPresetIconStyles />+ <div className="flex items-center justify-between shrink-0">+ <div className="flex items-center gap-2 text-white font-medium">+ <Icon icon="ph:film-strip-bold" width="20" aria-hidden="true" />+ <span>{t("title")}</span>+ </div>+ <label className="flex items-center gap-2 text-xs text-white/40">+ <span>{t("globalMotionLabel")}</span>+ <Toggle checked={isGlobalMotionEnabled} onChange={onToggleGlobalMotion} activeColor="bg-orange-600" />+ </label>+ </div>+ <div className="flex-1 min-h-0 overflow-y-auto custom-scrollbar -mx-1 px-1">+ <div className="flex flex-col gap-6">+ {CATEGORY_ORDER.map((category) => {+ const presets = MOCKUP_MOTION_PRESETS.filter((p) => p.category === category);+ if (presets.length === 0) return null;+ return (+ <div key={category}>+ <div className="flex items-center gap-2 mb-3">+ <span className="text-[11px] font-bold uppercase tracking-widest text-white/70">+ {t(`categories.${category}`)}+ </span>+ </div>+ <div className="grid grid-cols-2 gap-2.5">+ {presets.map((preset) => (+ <button+ key={preset.id}+ onClick={() => onAddOrReplacePreset(preset.id)}+ className="group flex flex-col gap-2 squircle-element-camera border border-neutral-800 bg-black p-2 text-left transition-all duration-200 hover:scale-[1.015] hover:border-neutral-700 hover:bg-neutral-900 active:scale-[0.98]"+ >+ <div className="relative w-full aspect-[16/10] rounded-lg overflow-hidden">+ <MotionPresetIcon presetId={preset.id} category={preset.category} active={false} fill forceAnimate={isGlobalMotionEnabled} />+ </div>+ <span className="text-[11px] leading-tight truncate text-neutral-400 transition-colors group-hover:text-white">+ {t(`presets.${preset.id}`)}+ </span>+ </button>+ ))}+ </div>+ </div>+ );+ })}+ </div>+ </div>+ </div>+ );+}\ No newline at end of filediff --git a/app/components/ui/editor/MotionMenu.tsx b/app/components/ui/editor/MotionMenu.tsxdeleted file mode 100644index cb04f68..0000000--- a/app/components/ui/editor/MotionMenu.tsx+++ /dev/null@@ -1,150 +0,0 @@-"use client";-import { Icon } from "@iconify/react";-import { useTranslations } from "next-intl";-import { SliderControl } from "../../../../components/ui/SliderControl";-import { useMockup3dContext } from "@/app/contexts/Mockup3dContext";-import { MOCKUP_MOTION_PRESETS, type MockupMotionPresetId, MockupMotionFragment, } from "@/lib/mockup-motion";-import { MotionPresetIcon, MotionPresetIconStyles, } from "../../../../components/ui/MotionPresetIcon";-import { Toggle } from "@/components/ui/toggle";--interface MotionMenuProps {- fragments: MockupMotionFragment[];- selectedFragment: MockupMotionFragment | null;- onAddOrReplacePreset: (presetId: MockupMotionPresetId) => void;- onUpdateSelectedFragment: (updates: Partial<MockupMotionFragment>) => void;- onSelectFragment: (id: string | null) => void;- onDeleteFragment: (id: string) => void;- mediaType?: "video" | "image";- mockupId?: string;- isGlobalMotionEnabled?: boolean;- onToggleGlobalMotion?: (enabled: boolean) => void;-}--const CATEGORY_ORDER = ["Entrance", "Continue", "Exit"] as const;--export function MotionMenu({- selectedFragment,- onAddOrReplacePreset,- onUpdateSelectedFragment,- mediaType = "video",- isGlobalMotionEnabled = true,- onToggleGlobalMotion,-}: MotionMenuProps) {- const t = useTranslations("motionMenu");- const { imagePhoneActive } = useMockup3dContext();- const hasMockup2D = mediaType === "video" && !imagePhoneActive;-- if (!hasMockup2D) {- return (- <div className="p-4 flex flex-col gap-5 h-full relative">- <div className="flex items-center justify-between shrink-0">- <div className="flex items-center gap-2 text-white font-medium">- <Icon icon="ph:film-strip-bold" width="20" aria-hidden="true" />- <span>{t("title")}</span>- </div>- {onToggleGlobalMotion && (- <label className="flex items-center gap-2 text-xs text-white/40">- <span>{t("globalMotionLabel")}</span>- <Toggle checked={isGlobalMotionEnabled} onChange={onToggleGlobalMotion} disabled={true} />- </label>- )}- </div>- <div className="group bg-[#09090B] border border-dashed border-white/10 squircle-element p-8 text-center transition-colors">- <div className="w-12 h-12 rounded-full bg-white/5 border border-white/10 flex items-center justify-center mx-auto mb-4 group-hover:scale-105 transition-transform">- <Icon icon="ph:frame-corners-bold" width="24" className="text-white/40 group-hover:text-white/70 transition-colors" aria-hidden="true" />- </div>- <p className="text-sm font-medium text-white/70 mb-1">- {t("empty2D.title")}- </p>- <p className="text-xs text-white/40">{t("empty2D.description")}</p>- </div>- </div>- );- }-- return (- <div className="p-4 flex flex-col gap-4 h-full relative min-h-0">- <MotionPresetIconStyles />- <div className="flex items-center justify-between shrink-0">- <div className="flex items-center gap-2 text-white font-medium">- <Icon icon="ph:film-strip-bold" width="20" aria-hidden="true" />- <span>{t("title")}</span>- </div>- {onToggleGlobalMotion && (- <label className="flex items-center gap-2 text-xs text-white/40">- <span>{t("globalMotionLabel")}</span>- <Toggle checked={isGlobalMotionEnabled} onChange={onToggleGlobalMotion} activeColor="bg-orange-600" />- </label>- )}- </div>-- <div className="flex-1 min-h-0 overflow-y-auto custom-scrollbar -mx-1 px-1">- <div className="flex flex-col gap-6">- {CATEGORY_ORDER.map((category) => {- const presets = MOCKUP_MOTION_PRESETS.filter((p) => p.category === category);- if (presets.length === 0) return null;-- return (- <div key={category}>- <div className="flex items-center gap-2 mb-3">- <span className="text-[11px] font-bold uppercase tracking-widest text-white/70">- {t(`categories.${category}`)}- </span>- </div>- <div className="grid grid-cols-2 gap-2.5">- {presets.map((preset) => {- const isActive = selectedFragment?.presetId === preset.id;- return (- <button- key={preset.id}- onClick={() => onAddOrReplacePreset(preset.id)}- className={`group flex flex-col gap-2 squircle-element-camera border p-2 text-left transition-all duration-200 hover:scale-[1.015] active:scale-[0.98] ${isActive ? "border-orange-600/50 bg-orange-[0.05]" : "border-neutral-800 bg-black hover:border-neutral-700 hover:bg-neutral-900"}`}- >- <div className="relative w-full aspect-[16/10] rounded-lg overflow-hidden">- <MotionPresetIcon- presetId={preset.id}- category={preset.category}- active={isActive}- fill- forceAnimate={isGlobalMotionEnabled}- />- {isActive && (- <div className="absolute top-1.5 right-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-orange-600/50 backdrop-blur-sm">- <Icon icon="ph:check-bold" className="text-white" width="9" aria-hidden="true" />- </div>- )}- </div>- <span className={`text-[11px] leading-tight truncate transition-colors ${isActive ? "text-white" : "text-neutral-400 group-hover:text-white"}`} >- {t(`presets.${preset.id}`)}- </span>- </button>- );- })}- </div>- </div>- );- })}- </div>- </div>-- {selectedFragment && (- <div className="flex flex-col gap-4">- <SliderControl- icon="mdi:tune-variant"- label={t("controls.intensity")}- value={selectedFragment?.intensity ?? 50}- min={0} max={100}- onChange={(v: number) => selectedFragment && onUpdateSelectedFragment({ intensity: v })}- />- <SliderControl- icon="mdi:speedometer"- label={t("controls.speed")}- value={selectedFragment?.speed ?? 50}- min={0} max={100}- onChange={(v: number) => selectedFragment && onUpdateSelectedFragment({ speed: v })}- />- </div>- )}- </div>- );-}\ No newline at end of filediff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsxindex c6502d6..10248aa 100644--- a/app/components/ui/editor/VideoCanvas.tsx+++ b/app/components/ui/editor/VideoCanvas.tsx@@ -1464,12 +1464,10 @@ function VideoCanvasInner({drawMockupAndMedia(fgCtx, containerX, containerY, containerWidth, containerHeight, video!, false, true, mockupDrawCtx);}fgCtx.restore();- applyPerspective3D(- fgCanvas,- zoomState.rotateX + (mockupMotionForFrame?.rotateX ?? 0),- zoomState.rotateY + (mockupMotionForFrame?.rotateY ?? 0),- (zoomState.perspective || mockupMotionForFrame?.perspectivePx || 900) / BLEED_FACTOR,- );++ applyPerspective3D(fgCanvas, mockupMotionForFrame?.rotateX ?? 0, mockupMotionForFrame?.rotateY ?? 0, (mockupMotionForFrame?.perspectivePx || 900) / BLEED_FACTOR);+ applyPerspective3D(fgCanvas, zoomState.rotateX, zoomState.rotateY, zoomState.perspective / BLEED_FACTOR);+ctx.save();applyVideoZoom(ctx);ctx.drawImage(fgCanvas, -fgOffsetX, -fgOffsetY, fgWidth, fgHeight);diff --git a/app/components/ui/editor/VideosMenu.tsx b/app/components/ui/editor/VideosMenu.tsxindex 368c050..4cbbd62 100644--- a/app/components/ui/editor/VideosMenu.tsx+++ b/app/components/ui/editor/VideosMenu.tsx@@ -267,7 +267,7 @@ export function VideosMenu({initial={{ opacity: 0, scale: 0.95 }}animate={{ opacity: 1, scale: 1 }}exit={{ opacity: 0, scale: 0.95 }}- className={`group flex flex-col rounded-lg border overflow-hidden transition-all duration-200 bg-neutral-950 w-full ${videosInTrackIds.includes(video.id)+ className={`group flex flex-col squircle-element border overflow-hidden transition-all duration-200 bg-neutral-950 w-full ${videosInTrackIds.includes(video.id)? "border-blue-500 shadow-[0_0_15px_rgba(59,130,246,0.15)]": "border-neutral-800 hover:border-neutral-700"}`}@@ -332,7 +332,7 @@ export function VideosMenu({handleToggleAudio(video.id, video.hasAudio);}}disabled={video.originalHasAudio === false}- className={`p-1.5 rounded-md transition-colors ${video.originalHasAudio === false+ className={`p-1.5 squircle-element transition-colors ${video.originalHasAudio === false? "text-neutral-500 cursor-not-allowed": video.hasAudio === false? "text-red-400 hover:bg-red-500/10"@@ -353,7 +353,7 @@ export function VideosMenu({handleDelete(video.id);}}disabled={deletingId === video.id}- className="p-1.5 rounded-md text-neutral-400 hover:text-red-400 hover:bg-red-500/10 transition-colors disabled:opacity-50"+ className="p-1.5 squircle-element text-neutral-400 hover:text-red-400 hover:bg-red-500/10 transition-colors disabled:opacity-50">{deletingId === video.id ? (<Icon icon="svg-spinners:ring-resize" width="14" />diff --git a/app/components/ui/editor/ZoomFragmentEditor.tsx b/app/components/ui/editor/ZoomFragmentEditor.tsxindex 8103523..5f0a7a5 100644--- a/app/components/ui/editor/ZoomFragmentEditor.tsx+++ b/app/components/ui/editor/ZoomFragmentEditor.tsx@@ -9,6 +9,7 @@ import { formatZoomTime, zoomLevelToFactor, speedToTransitionMs, calculateHoldDuimport { TooltipAction } from "@/components/ui/tooltip-action";import { DetailPageHeader } from "@/components/ui/DetailHeaderMenu";import { Toggle } from "@/components/ui/toggle";+import { DirectionPad } from "@/components/ui/DirectionPad";export function ZoomFragmentEditor({fragment, videoUrl, videoThumbnail, currentTime = 0,@@ -331,43 +332,23 @@ export function ZoomFragmentEditor({{fragment.enable3D && (<div className="space-y-3 pt-3 border-t border-gray-500/20"><SliderControl icon="mdi:brightness-6" label={tCommon("effect3d.intensity")} value={fragment.perspective3DIntensity ?? 50} min={0} max={100} step={5} onChange={(value) => onUpdate({ perspective3DIntensity: value })} suffix="%" />- <div className="space-y-2">- <div className="flex items-center gap-2 text-xs text-white/60">- <span>{tCommon("effect3d.direction")}</span>- </div>- <div- className="relative w-full aspect-square mx-auto bg-[#0A0A0A] squircle-element border border-[#262626] hover:border-[#404040] transition-colors cursor-crosshair overflow-hidden group"- onClick={(e) => {- const rect = e.currentTarget.getBoundingClientRect();- const x = ((e.clientX - rect.left) / rect.width) * 2 - 1;- const y = ((e.clientY - rect.top) / rect.height) * 2 - 1;- onUpdate({ perspective3DAngleX: Math.round(y * 45), perspective3DAngleY: Math.round(-x * 45) });- }}- >- <div className="absolute inset-0 flex items-center justify-center pointer-events-none">- <div className="w-full h-px bg-[#1F1F1F]" />- <div className="h-full w-px bg-[#1F1F1F] absolute" />- </div>-- <div className="absolute inset-0 flex items-center justify-center pointer-events-none">- <div- className="w-40 h-28 border border-gray-500/40 bg-gray-500/10 rounded-md transition-transform duration-300 ease-out shadow-[0_4px_20px_rgba(0,0,0,0.4)]"- style={{ transform: `perspective(120px) rotateX(${fragment.perspective3DAngleX ?? 0}deg) rotateY(${fragment.perspective3DAngleY ?? 0}deg)` }}- />- </div>-- <div- className="absolute w-2.5 h-2.5 bg-gray-300 rounded-full shadow-[0_0_8px_rgba(255,255,255,0.4)] transition-all duration-300 ease-out z-10"- style={{- left: `${50 + (-(fragment.perspective3DAngleY ?? (-(fragment.focusX - 50) / 50 * 15)) / 45) * 50}%`,- top: `${50 + ((fragment.perspective3DAngleX ?? ((fragment.focusY - 50) / 50 * 15)) / 45) * 50}%`,- transform: 'translate(-50%, -50%)'- }}+ {(() => {+ const defaultAngleX = ((fragment.focusY - 50) / 50) * 15;+ const defaultAngleY = -((fragment.focusX - 50) / 50) * 15;+ const angleX = fragment.perspective3DAngleX ?? defaultAngleX;+ const angleY = fragment.perspective3DAngleY ?? defaultAngleY;+ return (+ <DirectionPad+ angleX={angleX}+ angleY={angleY}+ onChange={(x, y) => onUpdate({ perspective3DAngleX: x, perspective3DAngleY: y })}+ accentRgb="156,163,175"+ label={tCommon("effect3d.direction")}+ hint={tCommon("effect3d.directionHint")}+ className="aspect-square max-w-[220px]"/>- </div>-- <p className="text-[11px] text-white/30 text-center">{tCommon("effect3d.directionHint")}</p>- </div>+ );+ })()}</div>)}</div>diff --git a/components/ui/DirectionPad.tsx b/components/ui/DirectionPad.tsxnew file mode 100644index 0000000..91db87e--- /dev/null+++ b/components/ui/DirectionPad.tsx@@ -0,0 +1,94 @@+"use client";++import { useRef } from "react";+import { Icon } from "@iconify/react";++interface DirectionPadProps {+ angleX: number;+ angleY: number;+ onChange: (angleX: number, angleY: number) => void;+ maxAngle?: number;+ accentRgb?: string;+ labelIcon?: string;+ label?: string;+ hint?: string;+ className?: string;+}++export function DirectionPad({+ angleX,+ angleY,+ onChange,+ maxAngle = 45,+ accentRgb = "156,163,175",+ labelIcon,+ label,+ hint,+ className,+}: DirectionPadProps) {+ const padRef = useRef<HTMLDivElement>(null);++ const setFromClient = (clientX: number, clientY: number) => {+ const rect = padRef.current?.getBoundingClientRect();+ if (!rect) return;+ const x = Math.max(-1, Math.min(1, ((clientX - rect.left) / rect.width) * 2 - 1));+ const y = Math.max(-1, Math.min(1, ((clientY - rect.top) / rect.height) * 2 - 1));+ onChange(Math.round(y * maxAngle), Math.round(-x * maxAngle));+ };++ const handlePointerDown = (e: React.PointerEvent<HTMLDivElement>) => {+ e.currentTarget.setPointerCapture(e.pointerId);+ setFromClient(e.clientX, e.clientY);+ const move = (ev: PointerEvent) => setFromClient(ev.clientX, ev.clientY);+ const up = () => {+ window.removeEventListener("pointermove", move);+ window.removeEventListener("pointerup", up);+ };+ window.addEventListener("pointermove", move);+ window.addEventListener("pointerup", up);+ };++ return (+ <div className="space-y-2">+ {label && (+ <div className="flex items-center gap-2 text-xs text-white/60">+ {labelIcon && <Icon icon={labelIcon} width="14" aria-hidden="true" />}+ <span>{label}</span>+ </div>+ )}+ <div+ ref={padRef}+ onPointerDown={handlePointerDown}+ className={`relative w-full mx-auto bg-[#0A0A0A] squircle-element border border-[#262626] hover:border-[#404040] transition-colors cursor-crosshair overflow-hidden touch-none group ${className ?? "aspect-square max-w-[220px]"}`}+ >+ <div className="absolute inset-0 flex items-center justify-center pointer-events-none">+ <div className="w-full h-px bg-[#1F1F1F]" />+ <div className="h-full w-px bg-[#1F1F1F] absolute" />+ </div>++ <div className="absolute inset-0 flex items-center justify-center pointer-events-none">+ <div+ className="w-3/5 aspect-[10/7] rounded-md transition-transform duration-300 ease-out shadow-[0_4px_20px_rgba(0,0,0,0.4)]"+ style={{+ border: `1px solid rgba(${accentRgb}, 0.4)`,+ background: `rgba(${accentRgb}, 0.1)`,+ transform: `perspective(120px) rotateX(${angleX}deg) rotateY(${angleY}deg)`,+ }}+ />+ </div>++ <div+ className="absolute w-2.5 h-2.5 rounded-full transition-all duration-300 ease-out z-10 pointer-events-none"+ style={{+ background: `rgb(${accentRgb})`,+ boxShadow: `0 0 8px rgba(${accentRgb}, 0.5)`,+ left: `${50 + (-angleY / maxAngle) * 50}%`,+ top: `${50 + (angleX / maxAngle) * 50}%`,+ transform: "translate(-50%, -50%)",+ }}+ />+ </div>+ {hint && <p className="text-[11px] text-white/30 text-center">{hint}</p>}+ </div>+ );+}\ No newline at end of filediff --git a/components/ui/MotionPresetIcon.tsx b/components/ui/MotionPresetIcon.tsxindex e67b40c..87553eb 100644--- a/components/ui/MotionPresetIcon.tsx+++ b/components/ui/MotionPresetIcon.tsx@@ -90,15 +90,6 @@ export function MotionPresetIconStyles() {.force-animate .mp-card {will-change: transform, filter, opacity;}-- .group:hover .mp-card--rise-settle,- .force-animate .mp-card--rise-settle {- animation: mp-rise-settle 1.1s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;- }- .group:hover .mp-card--flip-reveal,- .force-animate .mp-card--flip-reveal {- animation: mp-flip-reveal 1.3s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;- }.group:hover .mp-card--focus-in,.force-animate .mp-card--focus-in {animation: mp-focus-in 1.1s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;@@ -127,18 +118,10 @@ export function MotionPresetIconStyles() {.force-animate .mp-card--macro-track {animation: mp-macro-track 2.4s ease-in-out infinite alternate;}- .group:hover .mp-card--rim-light-reveal,- .force-animate .mp-card--rim-light-reveal {- animation: mp-rim-light-reveal 2.2s ease-in-out infinite alternate;- }.group:hover .mp-card--surface-orbit,.force-animate .mp-card--surface-orbit {animation: mp-surface-orbit 2.6s ease-in-out infinite alternate;}- .group:hover .mp-card--low-dolly-reveal,- .force-animate .mp-card--low-dolly-reveal {- animation: mp-low-dolly-reveal 2.2s ease-in-out infinite alternate;- }.group:hover .mp-card--exit-fade-down,.force-animate .mp-card--exit-fade-down {animation: mp-exit-fade-down 1s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;@@ -148,15 +131,6 @@ export function MotionPresetIconStyles() {animation: mp-exit-scale-blur 1s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;}}-- @keyframes mp-rise-settle {- 0% { transform: translateY(45%); opacity: 0.25; }- 100% { transform: translateY(0); opacity: 1; }- }- @keyframes mp-flip-reveal {- 0% { transform: rotateY(-62deg) scale(0.92); opacity: 0.35; }- 100% { transform: rotateY(0deg) scale(1); opacity: 1; }- }@keyframes mp-focus-in {0% { transform: scale(1.22); filter: blur(3.5px); opacity: 0.45; }100% { transform: scale(1); filter: blur(0); opacity: 1; }@@ -185,18 +159,10 @@ export function MotionPresetIconStyles() {0% { transform: scale(1.7) translate(10%, 10%) rotateX(32deg); }100% { transform: scale(1) translate(-6%, -6%) rotateX(0deg); }}- @keyframes mp-rim-light-reveal {- 0% { transform: scale(1.55) rotateX(55deg) rotateY(38deg); filter: brightness(0.35) blur(2.5px); opacity: 0.4; }- 100% { transform: scale(1) rotateX(0) rotateY(0); filter: brightness(1.2) blur(0); opacity: 1; }- }@keyframes mp-surface-orbit {0% { transform: scale(1.22) rotateX(48deg); }100% { transform: scale(1.05) rotateX(14deg) rotateY(12deg); }}- @keyframes mp-low-dolly-reveal {- 0% { transform: scale(1.45) rotateX(32deg) translateY(8%); }- 100% { transform: scale(1) rotateX(8deg) translateY(-4%); }- }@keyframes mp-exit-fade-down {0% { transform: translateY(0); opacity: 1; }100% { transform: translateY(30%); opacity: 0; }diff --git a/components/ui/PositionPad.tsx b/components/ui/PositionPad.tsxnew file mode 100644index 0000000..cd9d22c--- /dev/null+++ b/components/ui/PositionPad.tsx@@ -0,0 +1,102 @@+"use client";++import { useRef } from "react";+import { Icon } from "@iconify/react";++interface PositionPadProps {+ x: number;+ y: number;+ onChange: (x: number, y: number) => void;+ range?: number;+ scale?: number;+ rotateZ?: number;+ blur?: number;+ accentRgb?: string;+ icon?: string;+ labelIcon?: string;+ label?: string;+ hint?: string;+ className?: string;+}++export function PositionPad({+ x,+ y,+ onChange,+ range = 50,+ scale = 1,+ rotateZ = 0,+ blur = 0,+ accentRgb = "249,115,22",+ icon = "ph:device-mobile-bold",+ labelIcon,+ label,+ hint,+ className,+}: PositionPadProps) {+ const padRef = useRef<HTMLDivElement>(null);++ const setFromClient = (clientX: number, clientY: number) => {+ const rect = padRef.current?.getBoundingClientRect();+ if (!rect) return;+ const nx = Math.max(-range, Math.min(range, ((clientX - rect.left) / rect.width) * range * 2 - range));+ const ny = Math.max(-range, Math.min(range, ((clientY - rect.top) / rect.height) * range * 2 - range));+ onChange(Math.round(nx), Math.round(ny));+ };++ const handlePointerDown = (e: React.PointerEvent<HTMLDivElement>) => {+ e.preventDefault();+ e.stopPropagation();+ e.currentTarget.setPointerCapture(e.pointerId);+ setFromClient(e.clientX, e.clientY);+ const move = (ev: PointerEvent) => setFromClient(ev.clientX, ev.clientY);+ const up = () => {+ window.removeEventListener("pointermove", move);+ window.removeEventListener("pointerup", up);+ };+ window.addEventListener("pointermove", move);+ window.addEventListener("pointerup", up);+ };++ const handlePadClick = (e: React.MouseEvent<HTMLDivElement>) => {+ if ((e.target as HTMLElement).closest("[data-drag-handle]")) return;+ setFromClient(e.clientX, e.clientY);+ };++ return (+ <div className="space-y-2">+ {label && (+ <div className="flex items-center gap-2 text-xs text-white/60">+ {labelIcon && <Icon icon={labelIcon} width="14" aria-hidden="true" />}+ <span>{label}</span>+ </div>+ )}+ <div+ ref={padRef}+ onClick={handlePadClick}+ className={`relative w-full mx-auto bg-[#0A0A0A] squircle-element border border-[#262626] hover:border-[#404040] transition-colors cursor-crosshair overflow-hidden ${className ?? "aspect-video"}`}+ >+ <div className="absolute inset-0 flex items-center justify-center pointer-events-none">+ <div className="w-full h-px bg-[#1F1F1F]" />+ <div className="h-full w-px bg-[#1F1F1F] absolute" />+ </div>+ <div+ data-drag-handle+ onPointerDown={handlePointerDown}+ className="absolute size-12 rounded-lg cursor-grab active:cursor-grabbing touch-none flex items-center justify-center"+ style={{+ left: `${50 + (x / range) * 50}%`,+ top: `${50 + (y / range) * 50}%`,+ background: `rgba(${accentRgb}, 0.18)`,+ border: `2px solid rgb(${accentRgb})`,+ transform: `translate(-50%, -50%) scale(${scale}) rotate(${rotateZ}deg)`,+ filter: blur > 0 ? `blur(${blur * 0.4}px)` : undefined,+ }}+ >+ <Icon icon={icon} width="16" style={{ color: `rgb(${accentRgb})` }} aria-hidden="true" />+ </div>+ </div>+ {hint && <p className="text-[11px] text-white/30 text-center">{hint}</p>}+ </div>+ );+}\ No newline at end of file