브랜드 에셋 사운드 스튜디오UI 수정
This commit is contained in:
1 parent
cd4114f74d
commit
b05c7bd080
6 files changed
+489
-397
No files matched your search
@@ -129,6 +129,11 @@
|
||||
"imageUpload": "Image Upload",
|
||||
"dragAndDrop": "Drag and drop\nimages to upload",
|
||||
"videoRatio": "Video Ratio",
|
||||
"minImages": "Min. 5 images",
|
||||
"youtubeShorts": "YouTube Shorts",
|
||||
"youtubeVideo": "YouTube Video",
|
||||
"back": "Go Back",
|
||||
"loadMore": "Load more",
|
||||
"uploadFailed": "Image upload failed.",
|
||||
"uploading": "Uploading...",
|
||||
"nextStep": "Next Step"
|
||||
|
||||
@@ -129,6 +129,11 @@
|
||||
"imageUpload": "이미지 업로드",
|
||||
"dragAndDrop": "이미지를 드래그하여\n업로드",
|
||||
"videoRatio": "영상 비율",
|
||||
"minImages": "최소 5장",
|
||||
"youtubeShorts": "유튜브 쇼츠",
|
||||
"youtubeVideo": "유튜브 일반",
|
||||
"back": "뒤로가기",
|
||||
"loadMore": "더보기",
|
||||
"uploadFailed": "이미지 업로드에 실패했습니다.",
|
||||
"uploading": "업로드 중...",
|
||||
"nextStep": "다음 단계"
|
||||
|
||||
@@ -6,6 +6,7 @@ import { uploadImages } from '../../utils/api';
|
||||
|
||||
interface AssetManagementContentProps {
|
||||
onNext: (imageTaskId: string) => void;
|
||||
onBack?: () => void;
|
||||
imageList: ImageItem[];
|
||||
onRemoveImage: (index: number) => void;
|
||||
onAddImages: (files: File[]) => void;
|
||||
@@ -13,20 +14,22 @@ interface AssetManagementContentProps {
|
||||
|
||||
type VideoRatio = 'vertical' | 'horizontal';
|
||||
|
||||
const IMAGES_PER_PAGE = 12;
|
||||
|
||||
const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
onNext,
|
||||
onBack,
|
||||
imageList,
|
||||
onRemoveImage,
|
||||
onAddImages,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const imageListRef = useRef<HTMLDivElement>(null);
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const [uploadError, setUploadError] = useState<string | null>(null);
|
||||
const [videoRatio, setVideoRatio] = useState<VideoRatio>('vertical');
|
||||
const [displayCount, setDisplayCount] = useState(IMAGES_PER_PAGE);
|
||||
|
||||
// Load video ratio from localStorage on mount
|
||||
useEffect(() => {
|
||||
const savedRatio = localStorage.getItem('castad_video_ratio') as VideoRatio;
|
||||
if (savedRatio === 'vertical' || savedRatio === 'horizontal') {
|
||||
@@ -34,7 +37,6 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Save video ratio to localStorage when it changes
|
||||
const handleVideoRatioChange = (ratio: VideoRatio) => {
|
||||
setVideoRatio(ratio);
|
||||
localStorage.setItem('castad_video_ratio', ratio);
|
||||
@@ -51,7 +53,6 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
setUploadError(null);
|
||||
|
||||
try {
|
||||
// URL 이미지와 파일 이미지 분리
|
||||
const urlImages: ImageUrlItem[] = imageList
|
||||
.filter((item: ImageItem): item is ImageItem & { type: 'url' } => item.type === 'url')
|
||||
.map((item) => ({ url: item.url }));
|
||||
@@ -60,7 +61,6 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
.filter((item: ImageItem): item is ImageItem & { type: 'file' } => item.type === 'file')
|
||||
.map((item) => item.file);
|
||||
|
||||
// 이미지가 하나라도 있으면 업로드
|
||||
if (urlImages.length > 0 || fileImages.length > 0) {
|
||||
const response = await uploadImages(urlImages, fileImages);
|
||||
onNext(response.task_id);
|
||||
@@ -73,11 +73,6 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const handleImageListWheel = (e: React.WheelEvent) => {
|
||||
// 이 영역 안에서는 항상 스크롤 이벤트 전파 차단
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const handleDragOver = (e: React.DragEvent) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@@ -86,14 +81,10 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
const handleDrop = (e: React.DragEvent) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const files = Array.from(e.dataTransfer.files).filter(file =>
|
||||
const files = Array.from(e.dataTransfer.files).filter((file: File) =>
|
||||
file.type.startsWith('image/')
|
||||
);
|
||||
|
||||
if (files.length > 0) {
|
||||
onAddImages(files);
|
||||
}
|
||||
if (files.length > 0) onAddImages(files);
|
||||
};
|
||||
|
||||
const handleFileSelect = () => {
|
||||
@@ -108,104 +99,132 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const visibleImages = imageList.slice(0, displayCount);
|
||||
const hasMore = imageList.length > displayCount;
|
||||
|
||||
return (
|
||||
<main className="page-container">
|
||||
{/* Title */}
|
||||
<h1 className="asset-title">{t('assetManagement.title')}</h1>
|
||||
<main className="asset-page">
|
||||
{/* Fixed Header - 뒤로가기 버튼 */}
|
||||
<div className="asset-sticky-header">
|
||||
{onBack && (
|
||||
<button onClick={onBack} className="asset-back-btn">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
|
||||
<polyline points="15 18 9 12 15 6"/>
|
||||
</svg>
|
||||
{t('assetManagement.back')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Main Content Container */}
|
||||
<div className="asset-container">
|
||||
{/* Left Column - Selected Images */}
|
||||
<div className="asset-column asset-column-left">
|
||||
<h3 className="asset-section-title">{t('assetManagement.selectedImages')}</h3>
|
||||
<div
|
||||
ref={imageListRef}
|
||||
onWheel={handleImageListWheel}
|
||||
className="asset-image-list"
|
||||
>
|
||||
{imageList.length > 0 ? (
|
||||
<div className="asset-image-grid">
|
||||
{imageList.map((item, i) => (
|
||||
<div key={i} className="asset-image-item">
|
||||
<img
|
||||
src={getImageSrc(item)}
|
||||
alt={`${t('assetManagement.imageAlt')} ${i + 1}`}
|
||||
/>
|
||||
{item.type === 'file' && (
|
||||
<div className="asset-image-badge">{t('assetManagement.uploadBadge')}</div>
|
||||
)}
|
||||
<button
|
||||
onClick={() => onRemoveImage(i)}
|
||||
className="asset-image-remove"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/>
|
||||
<line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
{/* Single Scrollable Content Area */}
|
||||
<div className="asset-scroll-area">
|
||||
<h1 className="asset-title">{t('assetManagement.title')}</h1>
|
||||
|
||||
<div className="asset-container">
|
||||
{/* Left Column - Selected Images */}
|
||||
<div className="asset-column asset-column-left">
|
||||
<div className="asset-section-header">
|
||||
<div className="asset-section-header-left">
|
||||
<h3 className="asset-section-title">{t('assetManagement.selectedImages')}</h3>
|
||||
<span className="asset-section-subtitle">{t('assetManagement.minImages')}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Column - Upload and Video Ratio */}
|
||||
<div className="asset-column asset-column-right">
|
||||
{/* Image Upload Section */}
|
||||
<div className="asset-upload-section">
|
||||
<h3 className="asset-section-title">{t('assetManagement.imageUpload')}</h3>
|
||||
<div
|
||||
onClick={handleFileSelect}
|
||||
onDragOver={handleDragOver}
|
||||
onDrop={handleDrop}
|
||||
className="asset-upload-zone"
|
||||
>
|
||||
<p className="asset-upload-text">
|
||||
{t('assetManagement.dragAndDrop').split('\n').map((line, i) => (
|
||||
<React.Fragment key={i}>{i > 0 && <br/>}{line}</React.Fragment>
|
||||
))}
|
||||
</p>
|
||||
<button onClick={handleFileSelect} className="asset-mobile-upload-btn">
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none">
|
||||
<line x1="8" y1="2" x2="8" y2="14" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
|
||||
<line x1="2" y1="8" x2="14" y2="8" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
|
||||
</svg>
|
||||
{t('assetManagement.imageUpload')}
|
||||
</button>
|
||||
</div>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
onChange={handleFileChange}
|
||||
className="hidden"
|
||||
/>
|
||||
|
||||
<div className="asset-image-list">
|
||||
{visibleImages.length > 0 && (
|
||||
<div className="asset-image-grid">
|
||||
{visibleImages.map((item, i) => (
|
||||
<div key={i} className="asset-image-item">
|
||||
<img
|
||||
src={getImageSrc(item)}
|
||||
alt={`${t('assetManagement.imageAlt')} ${i + 1}`}
|
||||
/>
|
||||
{item.type === 'file' && (
|
||||
<div className="asset-image-badge">{t('assetManagement.uploadBadge')}</div>
|
||||
)}
|
||||
<button
|
||||
onClick={() => onRemoveImage(i)}
|
||||
className="asset-image-remove"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/>
|
||||
<line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{hasMore && (
|
||||
<button
|
||||
className="asset-load-more"
|
||||
onClick={() => setDisplayCount(prev => prev + IMAGES_PER_PAGE)}
|
||||
>
|
||||
{t('assetManagement.loadMore')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Video Ratio Section */}
|
||||
<div className="asset-ratio-section">
|
||||
<h3 className="asset-section-title">{t('assetManagement.videoRatio')}</h3>
|
||||
<div className="asset-ratio-buttons">
|
||||
<button
|
||||
onClick={() => handleVideoRatioChange('vertical')}
|
||||
className={`asset-ratio-button ${videoRatio === 'vertical' ? 'active' : ''}`}
|
||||
{/* Right Column - Upload and Video Ratio */}
|
||||
<div className="asset-column asset-column-right">
|
||||
{/* Image Upload Section (desktop only) */}
|
||||
<div className="asset-upload-section">
|
||||
<h3 className="asset-section-title">{t('assetManagement.imageUpload')}</h3>
|
||||
<div
|
||||
onClick={handleFileSelect}
|
||||
onDragOver={handleDragOver}
|
||||
onDrop={handleDrop}
|
||||
className="asset-upload-zone"
|
||||
>
|
||||
<div className="asset-ratio-icon asset-ratio-icon-vertical">
|
||||
<div className="asset-ratio-box"></div>
|
||||
</div>
|
||||
<span>9:16</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleVideoRatioChange('horizontal')}
|
||||
className={`asset-ratio-button ${videoRatio === 'horizontal' ? 'active' : ''}`}
|
||||
>
|
||||
<div className="asset-ratio-icon asset-ratio-icon-horizontal">
|
||||
<div className="asset-ratio-box"></div>
|
||||
</div>
|
||||
<span>16:9</span>
|
||||
</button>
|
||||
<p className="asset-upload-text">
|
||||
{t('assetManagement.dragAndDrop').split('\n').map((line, i) => (
|
||||
<React.Fragment key={i}>{i > 0 && <br/>}{line}</React.Fragment>
|
||||
))}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Video Ratio Section */}
|
||||
<div className="asset-ratio-section">
|
||||
<h3 className="asset-section-title">{t('assetManagement.videoRatio')}</h3>
|
||||
<div className="asset-ratio-buttons">
|
||||
<button
|
||||
onClick={() => handleVideoRatioChange('vertical')}
|
||||
className={`asset-ratio-button ${videoRatio === 'vertical' ? 'active' : ''}`}
|
||||
>
|
||||
<div className="asset-ratio-icon asset-ratio-icon-vertical">
|
||||
<div className="asset-ratio-box"></div>
|
||||
</div>
|
||||
<span className="asset-ratio-label">9:16</span>
|
||||
<span className="asset-ratio-subtitle">{t('assetManagement.youtubeShorts')}</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleVideoRatioChange('horizontal')}
|
||||
className={`asset-ratio-button ${videoRatio === 'horizontal' ? 'active' : ''}`}
|
||||
>
|
||||
<div className="asset-ratio-icon asset-ratio-icon-horizontal">
|
||||
<div className="asset-ratio-box"></div>
|
||||
</div>
|
||||
<span className="asset-ratio-label">16:9</span>
|
||||
<span className="asset-ratio-subtitle">{t('assetManagement.youtubeVideo')}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bottom Button */}
|
||||
<div className="asset-bottom">
|
||||
{/* Fixed Footer - 다음 단계 버튼 */}
|
||||
<div className="asset-sticky-footer">
|
||||
{uploadError && (
|
||||
<p className="text-red-500 text-sm mb-2">{uploadError}</p>
|
||||
)}
|
||||
@@ -217,6 +236,15 @@ const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
|
||||
{isUploading ? t('assetManagement.uploading') : t('assetManagement.nextStep')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
onChange={handleFileChange}
|
||||
className="hidden"
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -363,6 +363,7 @@ const GenerationFlow: React.FC<GenerationFlowProps> = ({
|
||||
case 1:
|
||||
return (
|
||||
<AssetManagementContent
|
||||
onBack={() => goToWizardStep(0)}
|
||||
onNext={(taskId: string) => {
|
||||
// Clear video generation state to start fresh
|
||||
localStorage.removeItem(VIDEO_GENERATION_KEY);
|
||||
|
||||
@@ -386,7 +386,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
const isGenerating = status === 'generating_lyric' || status === 'generating_song' || status === 'polling';
|
||||
|
||||
return (
|
||||
<main className="page-container">
|
||||
<main className="sound-studio-page">
|
||||
{audioUrl && (
|
||||
<audio ref={audioRef} src={audioUrl} preload="metadata" />
|
||||
)}
|
||||
@@ -517,6 +517,41 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Generate Button */}
|
||||
<button
|
||||
onClick={handleGenerateMusic}
|
||||
disabled={isGenerating}
|
||||
className={`btn-generate-sound ${isGenerating ? 'disabled' : ''}`}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<>
|
||||
<svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none"/>
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
|
||||
</svg>
|
||||
{t('soundStudio.generating')}
|
||||
</>
|
||||
) : (
|
||||
t('soundStudio.generateButton')
|
||||
)}
|
||||
</button>
|
||||
|
||||
{errorMessage && (
|
||||
<div className="error-message-new">
|
||||
{errorMessage}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isGenerating && statusMessage && (
|
||||
<div className="status-message-new">
|
||||
<svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none"/>
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
|
||||
</svg>
|
||||
{statusMessage}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right Column - Lyrics */}
|
||||
@@ -578,41 +613,6 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Generate Button */}
|
||||
<button
|
||||
onClick={handleGenerateMusic}
|
||||
disabled={isGenerating}
|
||||
className={`btn-generate-sound ${isGenerating ? 'disabled' : ''}`}
|
||||
>
|
||||
{isGenerating ? (
|
||||
<>
|
||||
<svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none"/>
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
|
||||
</svg>
|
||||
{t('soundStudio.generating')}
|
||||
</>
|
||||
) : (
|
||||
t('soundStudio.generateButton')
|
||||
)}
|
||||
</button>
|
||||
|
||||
{errorMessage && (
|
||||
<div className="error-message-new">
|
||||
{errorMessage}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isGenerating && statusMessage && (
|
||||
<div className="status-message-new">
|
||||
<svg className="animate-spin h-4 w-4" viewBox="0 0 24 24">
|
||||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none"/>
|
||||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/>
|
||||
</svg>
|
||||
{statusMessage}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Bottom Button */}
|
||||
@@ -653,3 +653,4 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
};
|
||||
|
||||
export default SoundStudioContent;
|
||||
|
||||
Reference in new issue
Block a user