diff --git a/components/common/TemplatePreviewModal.tsx b/components/common/TemplatePreviewModal.tsx index 5b3ed8b..97ec233 100644 --- a/components/common/TemplatePreviewModal.tsx +++ b/components/common/TemplatePreviewModal.tsx @@ -1,7 +1,8 @@ "use client"; -import { useEffect, useState } from 'react'; -import { X } from 'lucide-react'; +import { useEffect, useState, useRef } from 'react'; +import { X, ChevronDown, ChevronUp } from 'lucide-react'; +import { useDeviceType } from '@/hooks/useDeviceType'; interface TemplatePreviewModalProps { /** Control visibility */ @@ -23,6 +24,7 @@ interface TemplatePreviewModalProps { /** * Fullscreen, Tailwind-based template preview modal with video content. * Overlays title/description if provided and supports an optional primary action. + * Supports expand/collapse for long descriptions and H5 responsive design. */ export function TemplatePreviewModal({ open, @@ -31,27 +33,62 @@ export function TemplatePreviewModal({ title, description, onPrimaryAction, - primaryLabel = 'Try it', + primaryLabel = 'Try it Free', }: TemplatePreviewModalProps) { const [isReady, setIsReady] = useState(false); + const [isExpanded, setIsExpanded] = useState(false); + const [showExpandButton, setShowExpandButton] = useState(false); + const descriptionRef = useRef(null); + const { isMobile } = useDeviceType(); useEffect(() => { if (!open) { setIsReady(false); + setIsExpanded(false); } }, [open]); + useEffect(() => { + if (isReady && description && descriptionRef.current) { + const element = descriptionRef.current; + const isOverflowing = element.scrollHeight > element.clientHeight; + setShowExpandButton(isOverflowing); + } + }, [isReady, description]); + if (!open || !videoUrl) return null; return ( -
+ <> + +
e.stopPropagation()} >
+
+ ); } diff --git a/components/pages/create-video/CreateInput/VideoCreationForm.tsx b/components/pages/create-video/CreateInput/VideoCreationForm.tsx index 54df7bf..6f130a2 100644 --- a/components/pages/create-video/CreateInput/VideoCreationForm.tsx +++ b/components/pages/create-video/CreateInput/VideoCreationForm.tsx @@ -63,6 +63,21 @@ export default function VideoCreationForm() { void getTemplateStoryList(); }, [getTemplateStoryList]); + /** Clear inputText when currentTemplate changes */ + useEffect(() => { + if (currentTemplate) { + setInputText(''); + } + }, [currentTemplate]); + + /** Determine if input textarea should be shown based on selected template's freeInput */ + const shouldShowInput = useMemo(() => { + if (!isTemplateSelected) { + return true; + } + return isTemplateSelected.freeInput && isTemplateSelected.freeInput.length > 0; + }, [isTemplateSelected]); + const characterInputRef = useRef(null); const sceneInputRef = useRef(null); const propInputRef = useRef(null); @@ -350,15 +365,17 @@ export default function VideoCreationForm() { )} {/* Text Input Area - Middle */} -
-