castad front 작업

This commit is contained in:
HyeongBaeYang committed 2025-12-23 11:01:31 +09:00
1 parent aa39cde4c6
commit a42562279e
30 files changed
+4332

No files matched your search

+200
View File
@@ -0,0 +1,200 @@
import React, { useRef } from 'react';
import { ImageItem } from '../../types/api';
interface AssetManagementContentProps {
onBack: () => void;
onNext: () => void;
imageList: ImageItem[];
onRemoveImage: (index: number) => void;
onAddImages: (files: File[]) => void;
}
const AssetManagementContent: React.FC<AssetManagementContentProps> = ({
onBack,
onNext,
imageList,
onRemoveImage,
onAddImages,
}) => {
const fileInputRef = useRef<HTMLInputElement>(null);
const imageListRef = useRef<HTMLDivElement>(null);
// 이미지 아이템의 표시용 URL 가져오기
const getImageSrc = (item: ImageItem): string => {
return item.type === 'url' ? item.url : item.preview;
};
const handleImageListWheel = (e: React.WheelEvent) => {
const el = imageListRef.current;
if (!el) return;
const { scrollTop, scrollHeight, clientHeight } = el;
const hasScrollableContent = scrollHeight > clientHeight;
if (!hasScrollableContent) return;
const atTop = scrollTop <= 0;
const atBottom = scrollTop + clientHeight >= scrollHeight - 1;
// 스크롤 가능한 영역 내에서 스크롤 중이면 이벤트 전파 중지
if ((e.deltaY < 0 && !atTop) || (e.deltaY > 0 && !atBottom)) {
e.stopPropagation();
}
};
const handleDragOver = (e: React.DragEvent) => {
e.preventDefault();
e.stopPropagation();
};
const handleDrop = (e: React.DragEvent) => {
e.preventDefault();
e.stopPropagation();
const files = Array.from(e.dataTransfer.files).filter(file =>
file.type.startsWith('image/')
);
if (files.length > 0) {
onAddImages(files);
}
};
const handleFileSelect = () => {
fileInputRef.current?.click();
};
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const files = e.target.files;
if (files && files.length > 0) {
onAddImages(Array.from(files));
// input 초기화 (같은 파일 다시 선택 가능하도록)
e.target.value = '';
}
};
return (
<main className="flex flex-col h-full p-3 sm:p-4 md:p-6 overflow-hidden">
<div className="flex justify-start mb-2 sm:mb-3 ml-10 md:ml-0 shrink-0">
<button
onClick={onBack}
className="flex items-center gap-1.5 py-1 px-3 sm:py-1.5 sm:px-4 rounded-full border border-gray-700 hover:bg-gray-800 transition-colors text-[9px] sm:text-[10px] md:text-xs text-gray-300"
>
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M15 18l-6-6 6-6" />
</svg>
뒤로가기
</button>
</div>
<div className="hidden sm:block text-center mb-2 md:mb-4 shrink-0">
<h1 className="text-lg md:text-xl lg:text-2xl font-bold mb-0.5 tracking-tight">브랜드 에셋</h1>
<p className="text-gray-400 text-[9px] md:text-[10px] lg:text-xs font-light">
쉽고 빠르게, 브랜드 소셜 미디어 캠페인을 만드세요.
</p>
</div>
<div className="flex-1 flex flex-col md:flex-row gap-2 sm:gap-3 md:gap-4 max-w-6xl mx-auto w-full min-h-0 overflow-hidden">
{/* 선택된 이미지 */}
<div className="flex-[2] bg-[#1c2a2e] rounded-xl sm:rounded-2xl md:rounded-3xl p-3 sm:p-4 md:p-5 border border-white/5 shadow-2xl overflow-hidden flex flex-col">
<div className="flex justify-between items-center mb-2 sm:mb-3 shrink-0">
<h3 className="text-[#a6ffea] text-[9px] sm:text-[10px] md:text-xs font-bold tracking-wide">선택된 이미지</h3>
<span className="text-gray-500 text-[8px] sm:text-[9px] md:text-[10px]">{imageList.length}장</span>
</div>
<div
ref={imageListRef}
onWheel={handleImageListWheel}
className="overflow-y-auto flex-1 min-h-0 custom-scrollbar"
style={{ overscrollBehavior: 'contain' }}
>
{imageList.length > 0 ? (
<div className="grid grid-cols-3 sm:grid-cols-4 gap-1.5 sm:gap-2">
{imageList.map((item, i) => (
<div
key={i}
className="aspect-square bg-[#121a1d]/50 rounded-lg border border-white/5 relative overflow-hidden group"
>
<img
src={getImageSrc(item)}
alt={`이미지 ${i + 1}`}
className="w-full h-full object-cover"
/>
{/* 업로드된 파일 표시 배지 */}
{item.type === 'file' && (
<div className="absolute top-1 left-1 px-1 py-0.5 bg-[#a682ff]/80 rounded text-[7px] sm:text-[8px] text-white font-medium">
NEW
</div>
)}
<button
onClick={() => onRemoveImage(i)}
className="absolute top-1 right-1 w-4 h-4 sm:w-5 sm:h-5 bg-black/60 hover:bg-red-500/80 rounded flex items-center justify-center text-white/70 hover:text-white transition-colors opacity-0 group-hover:opacity-100"
>
<svg className="w-2.5 h-2.5 sm:w-3 sm:h-3" 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 className="flex items-center justify-center text-gray-500 text-[9px] sm:text-[10px] py-6 sm:py-10 h-full">
이미지가 없습니다
</div>
)}
</div>
</div>
{/* 이미지 업로드 */}
<div className="flex-1 bg-[#1c2a2e] rounded-xl sm:rounded-2xl md:rounded-3xl p-3 sm:p-4 md:p-5 border border-white/5 shadow-2xl flex flex-col min-h-[120px] sm:min-h-[150px]">
<h3 className="text-[#a6ffea] text-[9px] sm:text-[10px] md:text-xs font-bold mb-2 sm:mb-3 tracking-wide shrink-0">이미지 업로드</h3>
<div
onClick={handleFileSelect}
onDragOver={handleDragOver}
onDrop={handleDrop}
className="flex-1 border-2 border-dashed border-gray-700 rounded-xl sm:rounded-2xl flex flex-col items-center justify-center p-3 sm:p-4 text-center group cursor-pointer hover:border-[#a6ffea]/50 transition-colors"
>
<div className="mb-2 text-gray-500 group-hover:text-[#a6ffea]">
<svg className="w-6 h-6 sm:w-8 sm:h-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<polyline points="17 8 12 3 7 8"/>
<line x1="12" y1="3" x2="12" y2="15"/>
</svg>
</div>
<p className="text-gray-400 text-[8px] sm:text-[9px] md:text-[10px] font-medium leading-relaxed">
이미지를 드래그하여<br/>업로드
</p>
<p className="text-gray-600 text-[7px] sm:text-[8px] mt-1">
또는 클릭하여 파일 선택
</p>
</div>
<input
ref={fileInputRef}
type="file"
accept="image/*"
multiple
onChange={handleFileChange}
className="hidden"
/>
</div>
</div>
<div className="flex justify-center py-2 sm:py-3 md:py-4 shrink-0">
<button
onClick={onNext}
disabled={imageList.length === 0}
className={`font-bold py-2 sm:py-2.5 md:py-3 px-6 sm:px-10 md:px-14 rounded-full transition-all transform active:scale-95 shadow-2xl text-[9px] sm:text-[10px] md:text-xs tracking-wide ${
imageList.length > 0
? 'bg-[#a682ff] hover:bg-[#9570f0] text-white shadow-[#a682ff44]'
: 'bg-gray-600 text-gray-400 cursor-not-allowed shadow-none'
}`}
>
다음 단계
</button>
</div>
</main>
);
};
export default AssetManagementContent;