first commit
This commit is contained in:
commit
086d898b68
154 files changed
+68619
No files matched your search
@@ -0,0 +1,150 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Key } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* ApiKeySelector 컴포넌트의 props 정의
|
||||
* @interface ApiKeySelectorProps
|
||||
* @property {(key?: string) => void} onKeySelected - API 키가 성공적으로 선택되거나 입력되었을 때 호출될 콜백 함수. (선택된 키를 인자로 받을 수 있음)
|
||||
* @property {string | null} [initialError] - 초기 에러 메시지 (선택 사항)
|
||||
*/
|
||||
interface ApiKeySelectorProps {
|
||||
onKeySelected: (key?: string) => void;
|
||||
initialError?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* API 키 선택 및 입력 컴포넌트
|
||||
* Gemini 및 Veo 모델 사용을 위해 Google Cloud Project의 API 키를 설정하도록 안내하고,
|
||||
* AI Studio 환경 또는 수동 입력 방식을 제공합니다.
|
||||
*/
|
||||
const ApiKeySelector: React.FC<ApiKeySelectorProps> = ({ onKeySelected, initialError }) => {
|
||||
const [loading, setLoading] = useState(false); // 로딩 상태 관리
|
||||
const [error, setError] = useState<string | null>(initialError || null); // 에러 메시지 관리
|
||||
const [manualKey, setManualKey] = useState(''); // 수동으로 입력된 API 키
|
||||
const [isAiStudio, setIsAiStudio] = useState(false); // 현재 환경이 Google AI Studio인지 여부
|
||||
|
||||
/**
|
||||
* 환경 체크 및 초기 API 키 확인
|
||||
* 컴포넌트 마운트 시 Google AI Studio 환경인지 확인하고, 이미 API 키가 선택되어 있는지 검사합니다.
|
||||
*/
|
||||
const checkKey = async () => {
|
||||
try {
|
||||
// window 객체에 aistudio 속성이 있는지 확인하여 AI Studio 환경을 감지합니다.
|
||||
if ((window as any).aistudio) {
|
||||
setIsAiStudio(true);
|
||||
// AI Studio에서 이미 API 키가 선택되어 있는지 확인합니다.
|
||||
const hasKey = await (window as any).aistudio.hasSelectedApiKey();
|
||||
if (hasKey && !initialError) {
|
||||
// 키가 이미 선택되어 있고 초기 에러가 없으면 onKeySelected 콜백을 호출하여 앱 시작
|
||||
onKeySelected();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("API 키 확인 중 오류 발생:", e);
|
||||
// 오류가 발생해도 isAiStudio 상태는 유지
|
||||
}
|
||||
};
|
||||
|
||||
// 컴포넌트가 처음 렌더링될 때 한 번만 checkKey 함수 실행
|
||||
useEffect(() => {
|
||||
checkKey();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* AI Studio에서 API 키 선택 핸들러
|
||||
* AI Studio의 `openSelectKey()` 함수를 호출하여 API 키 선택 UI를 띄웁니다.
|
||||
*/
|
||||
const handleSelectKey = async () => {
|
||||
setLoading(true); // 로딩 상태 시작
|
||||
setError(null); // 기존 에러 메시지 초기화
|
||||
try {
|
||||
if((window as any).aistudio) {
|
||||
await (window as any).aistudio.openSelectKey(); // AI Studio 키 선택 대화 상자 열기
|
||||
onKeySelected(); // 키 선택 성공 시 콜백 호출
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error("API 키 선택 중 오류 발생:", e);
|
||||
// 특정 에러 메시지에 따라 사용자에게 더 명확한 안내 제공
|
||||
if (e.message && e.message.includes("Requested entity was not found")) {
|
||||
setError("유효하지 않은 프로젝트/키가 선택되었습니다. 다시 시도해주세요.");
|
||||
} else {
|
||||
setError("API 키 선택에 실패했습니다. 다시 시도해주세요.");
|
||||
}
|
||||
} finally {
|
||||
setLoading(false); // 로딩 상태 종료
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 수동 API 키 입력 폼 제출 핸들러
|
||||
* 사용자가 직접 입력한 API 키를 검증하고 콜백 함수를 호출합니다.
|
||||
*/
|
||||
const handleManualSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault(); // 폼 기본 제출 동작 방지
|
||||
if(!manualKey.trim()) {
|
||||
setError("유효한 API 키를 입력해주세요."); // 빈 값일 경우 에러 메시지
|
||||
return;
|
||||
}
|
||||
onKeySelected(manualKey.trim()); // 유효한 키가 입력되면 콜백 호출
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-90 p-4">
|
||||
<div className="glass-panel p-8 rounded-2xl max-w-md w-full text-center border border-purple-500/30 shadow-2xl shadow-purple-900/20">
|
||||
<div className="mb-6 flex justify-center">
|
||||
<div className="p-4 bg-purple-900/30 rounded-full">
|
||||
<Key className="w-8 h-8 text-purple-400" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 className="text-2xl font-bold text-white mb-2">API 키 필요</h2>
|
||||
<p className="text-gray-400 mb-6">
|
||||
Veo 및 Gemini로 고품질 뮤직 비디오를 생성하려면, 결제 가능한 Google Cloud 프로젝트의 API 키를 선택해주세요.
|
||||
</p>
|
||||
|
||||
{error && (
|
||||
<div className="mb-4 p-3 bg-red-900/30 border border-red-500/30 rounded text-red-200 text-sm">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isAiStudio ? (
|
||||
// AI Studio 환경일 경우 API 키 선택 버튼 제공
|
||||
<button
|
||||
onClick={handleSelectKey}
|
||||
disabled={loading}
|
||||
className="w-full py-3 px-4 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500 text-white font-bold rounded-xl transition-all transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg"
|
||||
>
|
||||
{loading ? '연결 중...' : 'API 키 선택'}
|
||||
</button>
|
||||
) : (
|
||||
// 일반 브라우저 환경일 경우 수동 API 키 입력 폼 제공
|
||||
<form onSubmit={handleManualSubmit} className="flex flex-col gap-4">
|
||||
<input
|
||||
type="password" // 비밀번호 타입으로 입력 값 숨김
|
||||
value={manualKey}
|
||||
onChange={(e) => setManualKey(e.target.value)}
|
||||
placeholder="Gemini API 키 입력"
|
||||
className="w-full p-3 rounded-xl bg-white/10 border border-white/20 text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-purple-500"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-full py-3 px-4 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500 text-white font-bold rounded-xl transition-all transform hover:scale-105 shadow-lg"
|
||||
>
|
||||
앱 시작
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<div className="mt-4 text-xs text-gray-500">
|
||||
<a href="https://ai.google.dev/gemini-api/docs/billing" target="_blank" rel="noreferrer" className="underline hover:text-gray-300">
|
||||
결제 문서 보기
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApiKeySelector;
|
||||
@@ -0,0 +1,100 @@
|
||||
import React from 'react';
|
||||
|
||||
interface CaStADLogoProps {
|
||||
size?: 'sm' | 'md' | 'lg' | 'xl';
|
||||
showText?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const sizeClasses = {
|
||||
sm: { icon: 'w-8 h-8', text: 'text-lg' },
|
||||
md: { icon: 'w-12 h-12', text: 'text-xl' },
|
||||
lg: { icon: 'w-16 h-16', text: 'text-2xl' },
|
||||
xl: { icon: 'w-24 h-24', text: 'text-4xl' },
|
||||
};
|
||||
|
||||
// Main CaStAD Logo with custard pudding icon
|
||||
export const CaStADLogo: React.FC<CaStADLogoProps> = ({
|
||||
size = 'md',
|
||||
showText = true,
|
||||
className
|
||||
}) => {
|
||||
const { icon, text } = sizeClasses[size];
|
||||
|
||||
return (
|
||||
<div className={`flex items-center gap-2 ${className || ''}`}>
|
||||
{/* Custard Pudding SVG Icon */}
|
||||
<div className={`${icon} relative`}>
|
||||
<img
|
||||
src="/images/castad-logo.svg"
|
||||
alt="CaStAD"
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
{showText && (
|
||||
<div className="flex flex-col">
|
||||
<span className={`${text} font-bold bg-gradient-to-r from-amber-600 via-amber-500 to-yellow-600 bg-clip-text text-transparent`}>
|
||||
CaStAD
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground tracking-wide">
|
||||
카스타드
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// Inline version with custard cream colors
|
||||
export const CaStADLogoInline: React.FC<CaStADLogoProps> = ({
|
||||
size = 'md',
|
||||
className
|
||||
}) => {
|
||||
const { icon, text } = sizeClasses[size];
|
||||
|
||||
return (
|
||||
<div className={`flex items-center gap-2 ${className || ''}`}>
|
||||
{/* Custard emoji as simple icon */}
|
||||
<span className={`${icon} flex items-center justify-center`}>
|
||||
<span className="text-2xl">🍮</span>
|
||||
</span>
|
||||
<span className={`${text} font-bold bg-gradient-to-r from-amber-600 via-amber-500 to-yellow-600 bg-clip-text text-transparent`}>
|
||||
CaStAD
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// Icon only version
|
||||
export const CaStADIcon: React.FC<{ size?: 'sm' | 'md' | 'lg' | 'xl'; className?: string }> = ({
|
||||
size = 'md',
|
||||
className
|
||||
}) => {
|
||||
const { icon } = sizeClasses[size];
|
||||
|
||||
return (
|
||||
<div className={`${icon} ${className || ''}`}>
|
||||
<img
|
||||
src="/images/castad-logo.svg"
|
||||
alt="CaStAD"
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// Text only gradient version
|
||||
export const CaStADText: React.FC<{ size?: 'sm' | 'md' | 'lg' | 'xl'; className?: string }> = ({
|
||||
size = 'md',
|
||||
className
|
||||
}) => {
|
||||
const { text } = sizeClasses[size];
|
||||
|
||||
return (
|
||||
<span className={`${text} font-bold bg-gradient-to-r from-amber-600 via-amber-500 to-yellow-600 bg-clip-text text-transparent ${className || ''}`}>
|
||||
CaStAD
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export default CaStADLogo;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,133 @@
|
||||
import React from 'react';
|
||||
import { useLanguage } from '../src/contexts/LanguageContext';
|
||||
import { cn } from '../src/lib/utils';
|
||||
import { Card, CardContent } from '../src/components/ui/card';
|
||||
import { Progress } from '../src/components/ui/progress';
|
||||
import { Loader2, Sparkles, Music, Image, Video, CheckCircle } from 'lucide-react';
|
||||
|
||||
interface LoadingOverlayProps {
|
||||
status: string;
|
||||
message: string;
|
||||
progress?: number;
|
||||
}
|
||||
|
||||
const STEP_ICONS: Record<string, React.ReactNode> = {
|
||||
'crawling': <Sparkles className="w-6 h-6" />,
|
||||
'generating_text': <Sparkles className="w-6 h-6" />,
|
||||
'generating_audio': <Music className="w-6 h-6" />,
|
||||
'generating_poster': <Image className="w-6 h-6" />,
|
||||
'generating_video': <Video className="w-6 h-6" />,
|
||||
'completed': <CheckCircle className="w-6 h-6 text-green-500" />,
|
||||
};
|
||||
|
||||
const LoadingOverlay: React.FC<LoadingOverlayProps> = ({ status, message, progress }) => {
|
||||
const { t } = useLanguage();
|
||||
|
||||
let displayMessage = message;
|
||||
|
||||
switch (status) {
|
||||
case 'crawling':
|
||||
case 'generating_text':
|
||||
displayMessage = t('loadingStep1');
|
||||
break;
|
||||
case 'generating_audio':
|
||||
displayMessage = t('loadingStep2').replace('{style}', 'Auto');
|
||||
break;
|
||||
case 'generating_poster':
|
||||
case 'generating_video':
|
||||
displayMessage = t('loadingStep3');
|
||||
break;
|
||||
case 'completed':
|
||||
displayMessage = t('loadingStep4');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const currentProgress = progress || (
|
||||
status === 'crawling' ? 10 :
|
||||
status === 'generating_text' ? 25 :
|
||||
status === 'generating_audio' ? 50 :
|
||||
status === 'generating_poster' ? 70 :
|
||||
status === 'generating_video' ? 85 :
|
||||
status === 'completed' ? 100 : 10
|
||||
);
|
||||
|
||||
const currentIcon = STEP_ICONS[status] || <Sparkles className="w-6 h-6" />;
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm">
|
||||
<Card className="w-full max-w-md mx-4 border-border/50 shadow-2xl">
|
||||
<CardContent className="pt-8 pb-8 text-center">
|
||||
|
||||
{/* Animated Icon */}
|
||||
<div className="relative w-24 h-24 mx-auto mb-8">
|
||||
{/* Outer ring */}
|
||||
<div className="absolute inset-0 rounded-full border-4 border-primary/20 animate-ping" style={{ animationDuration: '2s' }} />
|
||||
|
||||
{/* Spinning ring */}
|
||||
<div className="absolute inset-0 rounded-full border-4 border-transparent border-t-primary border-r-accent animate-spin" style={{ animationDuration: '1.5s' }} />
|
||||
|
||||
{/* Center icon */}
|
||||
<div className="absolute inset-3 rounded-full bg-gradient-to-br from-primary to-accent flex items-center justify-center shadow-lg">
|
||||
<div className="text-primary-foreground animate-pulse">
|
||||
{currentIcon}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 className="text-2xl font-bold text-foreground mb-2">
|
||||
{t('loadingTitle')}
|
||||
</h2>
|
||||
<p className="text-muted-foreground text-sm mb-6">
|
||||
{t('loadingSubtitle')}
|
||||
</p>
|
||||
|
||||
{/* Progress Bar */}
|
||||
<div className="mb-6">
|
||||
<Progress value={currentProgress} className="h-2" />
|
||||
<div className="flex items-center justify-between mt-2 text-xs text-muted-foreground">
|
||||
<span>{t('textStyle') === '자막 스타일' ? '진행률' : 'Progress'}</span>
|
||||
<span className="font-medium">{currentProgress}%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Status Message */}
|
||||
<div className="flex items-center justify-center gap-2 mb-4">
|
||||
<Loader2 className="w-4 h-4 animate-spin text-primary" />
|
||||
<p className="text-lg font-semibold gradient-text">
|
||||
{displayMessage}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Steps indicator */}
|
||||
<div className="flex items-center justify-center gap-2 mb-6">
|
||||
{['generating_text', 'generating_audio', 'generating_poster', 'completed'].map((step, idx) => {
|
||||
const isActive = status === step;
|
||||
const isPast = ['generating_text', 'generating_audio', 'generating_poster', 'generating_video', 'completed'].indexOf(status) >
|
||||
['generating_text', 'generating_audio', 'generating_poster', 'completed'].indexOf(step);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={step}
|
||||
className={cn(
|
||||
"w-2 h-2 rounded-full transition-all",
|
||||
isActive && "w-6 bg-primary",
|
||||
isPast && "bg-primary/60",
|
||||
!isActive && !isPast && "bg-muted-foreground/30"
|
||||
)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t('loadingWait')}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoadingOverlay;
|
||||
@@ -0,0 +1,555 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Link, useNavigate, useLocation } from 'react-router-dom';
|
||||
import { useAuth } from '../src/contexts/AuthContext';
|
||||
import { useLanguage } from '../src/contexts/LanguageContext';
|
||||
import { useTheme, PALETTES, ColorPalette } from '../src/contexts/ThemeContext';
|
||||
import {
|
||||
LogOut,
|
||||
User,
|
||||
LayoutDashboard,
|
||||
Menu,
|
||||
Settings,
|
||||
Globe,
|
||||
ChevronDown,
|
||||
Video,
|
||||
Shield,
|
||||
X,
|
||||
Coins,
|
||||
AlertCircle,
|
||||
Sun,
|
||||
Moon,
|
||||
Palette,
|
||||
Check
|
||||
} from 'lucide-react';
|
||||
import { CaStADLogo, CaStADLogoInline } from './CaStADLogo';
|
||||
import { Language } from '../types';
|
||||
import { cn } from '../src/lib/utils';
|
||||
import { Button } from '../src/components/ui/button';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '../src/components/ui/dropdown-menu';
|
||||
import {
|
||||
Sheet,
|
||||
SheetContent,
|
||||
SheetHeader,
|
||||
SheetTitle,
|
||||
SheetTrigger,
|
||||
SheetClose,
|
||||
} from '../src/components/ui/sheet';
|
||||
import { Avatar, AvatarFallback } from '../src/components/ui/avatar';
|
||||
import { Badge } from '../src/components/ui/badge';
|
||||
import { Separator } from '../src/components/ui/separator';
|
||||
|
||||
const LANGUAGES = [
|
||||
{ code: 'KO', label: '한국어', flag: 'kr' },
|
||||
{ code: 'EN', label: 'English', flag: 'us' },
|
||||
{ code: 'JP', label: '日本語', flag: 'jp' },
|
||||
{ code: 'CN', label: '中文', flag: 'cn' },
|
||||
{ code: 'TH', label: 'ไทย', flag: 'th' },
|
||||
{ code: 'VN', label: 'Tiếng Việt', flag: 'vn' },
|
||||
] as const;
|
||||
|
||||
const Navbar: React.FC = () => {
|
||||
const { user, logout, token } = useAuth();
|
||||
const { language, setLanguage, t } = useLanguage();
|
||||
const { theme, palette, toggleTheme, setPalette } = useTheme();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [isScrolled, setIsScrolled] = useState(false);
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
const [credits, setCredits] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
setIsScrolled(window.scrollY > 10);
|
||||
};
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
return () => window.removeEventListener('scroll', handleScroll);
|
||||
}, []);
|
||||
|
||||
// 크레딧 조회
|
||||
useEffect(() => {
|
||||
const fetchCredits = async () => {
|
||||
if (!user || !token) {
|
||||
setCredits(null);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const backendPort = import.meta.env.VITE_BACKEND_PORT || '3001';
|
||||
const res = await fetch(`http://localhost:${backendPort}/api/credits`, {
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setCredits(data.credits);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch credits:', err);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCredits();
|
||||
// 주기적으로 업데이트 (30초마다)
|
||||
const interval = setInterval(fetchCredits, 30000);
|
||||
return () => clearInterval(interval);
|
||||
}, [user, token]);
|
||||
|
||||
const handleLogout = () => {
|
||||
logout();
|
||||
navigate('/login');
|
||||
setMobileOpen(false);
|
||||
};
|
||||
|
||||
// Hide navbar during server rendering (autoplay mode)
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
if (searchParams.get('autoplay') === 'true') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentLanguage = LANGUAGES.find(l => l.code === language) || LANGUAGES[0];
|
||||
|
||||
const NavLink = ({ to, children, icon: Icon }: { to: string; children: React.ReactNode; icon?: React.ElementType }) => {
|
||||
const isActive = location.pathname === to;
|
||||
return (
|
||||
<Link
|
||||
to={to}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className={cn(
|
||||
"flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-all duration-200",
|
||||
isActive
|
||||
? "bg-primary/10 text-primary"
|
||||
: "text-muted-foreground hover:text-foreground hover:bg-accent"
|
||||
)}
|
||||
>
|
||||
{Icon && <Icon className="w-4 h-4" />}
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<nav
|
||||
className={cn(
|
||||
"fixed top-0 left-0 right-0 z-50 transition-all duration-300",
|
||||
isScrolled
|
||||
? "bg-background/80 backdrop-blur-xl border-b border-border shadow-sm"
|
||||
: "bg-background/50 backdrop-blur-md"
|
||||
)}
|
||||
>
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6">
|
||||
<div className="flex items-center justify-between h-16">
|
||||
{/* Logo */}
|
||||
<Link to="/" className="flex items-center group hover:opacity-90 transition-opacity">
|
||||
<CaStADLogo size="sm" />
|
||||
</Link>
|
||||
|
||||
{/* Desktop Navigation */}
|
||||
<div className="hidden md:flex items-center gap-1">
|
||||
<NavLink to="/" icon={Video}>
|
||||
{t('menuCreate')}
|
||||
</NavLink>
|
||||
{user && (
|
||||
<NavLink to="/dashboard" icon={LayoutDashboard}>
|
||||
{t('menuLibrary')}
|
||||
</NavLink>
|
||||
)}
|
||||
{user?.role === 'admin' && (
|
||||
<NavLink to="/admin" icon={Shield}>
|
||||
{t('menuAdmin')}
|
||||
</NavLink>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right Actions */}
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Language Switcher */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="gap-1.5 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<span className={`fi fi-${currentLanguage.flag} rounded-sm`} />
|
||||
<span className="hidden sm:inline text-xs font-medium">
|
||||
{currentLanguage.code}
|
||||
</span>
|
||||
<ChevronDown className="w-3 h-3 opacity-50" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-40">
|
||||
<DropdownMenuLabel className="text-xs text-muted-foreground">
|
||||
{t('settingLanguage') || 'Language'}
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
{LANGUAGES.map((lang) => (
|
||||
<DropdownMenuItem
|
||||
key={lang.code}
|
||||
onClick={() => setLanguage(lang.code as Language)}
|
||||
className={cn(
|
||||
"gap-2 cursor-pointer",
|
||||
language === lang.code && "bg-accent"
|
||||
)}
|
||||
>
|
||||
<span className={`fi fi-${lang.flag} rounded-sm`} />
|
||||
<span className="text-sm">{lang.label}</span>
|
||||
{language === lang.code && (
|
||||
<Badge variant="secondary" className="ml-auto text-[10px] px-1.5">
|
||||
✓
|
||||
</Badge>
|
||||
)}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
{/* Theme Toggle */}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={toggleTheme}
|
||||
className="w-9 h-9 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{theme === 'dark' ? (
|
||||
<Sun className="w-4 h-4" />
|
||||
) : (
|
||||
<Moon className="w-4 h-4" />
|
||||
)}
|
||||
<span className="sr-only">테마 변경</span>
|
||||
</Button>
|
||||
|
||||
{/* Palette Selector */}
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="w-9 h-9 text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Palette className="w-4 h-4" />
|
||||
<span className="sr-only">컬러 팔레트</span>
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-44">
|
||||
<DropdownMenuLabel className="text-xs text-muted-foreground">
|
||||
컬러 팔레트
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
{(Object.keys(PALETTES) as ColorPalette[]).map((key) => (
|
||||
<DropdownMenuItem
|
||||
key={key}
|
||||
onClick={() => setPalette(key)}
|
||||
className="gap-2 cursor-pointer"
|
||||
>
|
||||
<div className={cn(
|
||||
"w-5 h-5 rounded-full bg-gradient-to-r",
|
||||
PALETTES[key].preview
|
||||
)} />
|
||||
<span className="text-sm">{PALETTES[key].name}</span>
|
||||
{palette === key && (
|
||||
<Check className="w-4 h-4 ml-auto text-primary" />
|
||||
)}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
{/* User Menu / Auth Buttons */}
|
||||
{user ? (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="gap-2 pl-2">
|
||||
<Avatar className="w-7 h-7">
|
||||
<AvatarFallback className="bg-primary/10 text-primary text-xs font-semibold">
|
||||
{user.name?.charAt(0).toUpperCase() || 'U'}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="hidden sm:inline text-sm font-medium max-w-[100px] truncate">
|
||||
{user.name}
|
||||
</span>
|
||||
<ChevronDown className="w-3 h-3 opacity-50" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" className="w-56">
|
||||
<DropdownMenuLabel className="font-normal">
|
||||
<div className="flex flex-col gap-1">
|
||||
<p className="text-sm font-medium">{user.name}</p>
|
||||
<p className="text-xs text-muted-foreground">@{user.username}</p>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
<DropdownMenuSeparator />
|
||||
{/* 크레딧 표시 */}
|
||||
{user.role !== 'admin' && credits !== null && (
|
||||
<>
|
||||
<div className="px-2 py-2">
|
||||
<div className={cn(
|
||||
"flex items-center justify-between px-3 py-2 rounded-lg",
|
||||
credits <= 0 ? "bg-destructive/10" : credits <= 3 ? "bg-yellow-500/10" : "bg-primary/10"
|
||||
)}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Coins className={cn(
|
||||
"w-4 h-4",
|
||||
credits <= 0 ? "text-destructive" : credits <= 3 ? "text-yellow-600" : "text-primary"
|
||||
)} />
|
||||
<span className="text-sm font-medium">크레딧</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className={cn(
|
||||
"text-lg font-bold",
|
||||
credits <= 0 ? "text-destructive" : credits <= 3 ? "text-yellow-600" : "text-primary"
|
||||
)}>
|
||||
{credits}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">개</span>
|
||||
</div>
|
||||
</div>
|
||||
{credits <= 3 && (
|
||||
<Link
|
||||
to="/credits"
|
||||
className="flex items-center gap-1.5 mt-2 text-xs text-muted-foreground hover:text-primary transition-colors"
|
||||
>
|
||||
<AlertCircle className="w-3 h-3" />
|
||||
{credits <= 0 ? '크레딧이 부족합니다. 충전 요청하기' : '크레딧이 부족합니다'}
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<DropdownMenuSeparator />
|
||||
</>
|
||||
)}
|
||||
<DropdownMenuItem asChild className="cursor-pointer">
|
||||
<Link to="/dashboard" className="flex items-center gap-2">
|
||||
<LayoutDashboard className="w-4 h-4" />
|
||||
{t('menuLibrary')}
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
{user.role === 'admin' && (
|
||||
<DropdownMenuItem asChild className="cursor-pointer">
|
||||
<Link to="/admin" className="flex items-center gap-2">
|
||||
<Shield className="w-4 h-4" />
|
||||
{t('menuAdmin')}
|
||||
</Link>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
onClick={handleLogout}
|
||||
className="cursor-pointer text-destructive focus:text-destructive"
|
||||
>
|
||||
<LogOut className="w-4 h-4 mr-2" />
|
||||
{t('menuLogout')}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
<div className="hidden md:flex items-center gap-2">
|
||||
<Button variant="ghost" size="sm" asChild>
|
||||
<Link to="/login">{t('menuLogin')}</Link>
|
||||
</Button>
|
||||
<Button size="sm" className="shadow-lg shadow-primary/20" asChild>
|
||||
<Link to="/register">{t('menuStart')}</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Mobile Menu Button */}
|
||||
<Sheet open={mobileOpen} onOpenChange={setMobileOpen}>
|
||||
<SheetTrigger asChild className="md:hidden">
|
||||
<Button variant="ghost" size="icon" className="shrink-0">
|
||||
<Menu className="w-5 h-5" />
|
||||
<span className="sr-only">메뉴 열기</span>
|
||||
</Button>
|
||||
</SheetTrigger>
|
||||
<SheetContent side="right" className="w-[300px] sm:w-[350px]">
|
||||
<SheetHeader className="text-left">
|
||||
<SheetTitle>
|
||||
<CaStADLogo size="sm" />
|
||||
</SheetTitle>
|
||||
</SheetHeader>
|
||||
|
||||
<div className="mt-8 flex flex-col gap-2">
|
||||
{/* Mobile Navigation Links */}
|
||||
<NavLink to="/" icon={Video}>
|
||||
{t('menuCreate')}
|
||||
</NavLink>
|
||||
{user && (
|
||||
<NavLink to="/dashboard" icon={LayoutDashboard}>
|
||||
{t('menuLibrary')}
|
||||
</NavLink>
|
||||
)}
|
||||
{user?.role === 'admin' && (
|
||||
<NavLink to="/admin" icon={Shield}>
|
||||
{t('menuAdmin')}
|
||||
</NavLink>
|
||||
)}
|
||||
|
||||
<Separator className="my-4" />
|
||||
|
||||
{/* Mobile User Section */}
|
||||
{user ? (
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-3 px-3 py-2">
|
||||
<Avatar className="w-10 h-10">
|
||||
<AvatarFallback className="bg-primary/10 text-primary font-semibold">
|
||||
{user.name?.charAt(0).toUpperCase() || 'U'}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium truncate">{user.name}</p>
|
||||
<p className="text-xs text-muted-foreground">@{user.username}</p>
|
||||
</div>
|
||||
{user.role === 'admin' && (
|
||||
<Badge variant="secondary" className="text-[10px]">Admin</Badge>
|
||||
)}
|
||||
</div>
|
||||
{/* 모바일 크레딧 표시 */}
|
||||
{user.role !== 'admin' && credits !== null && (
|
||||
<div className={cn(
|
||||
"flex items-center justify-between px-3 py-3 rounded-lg mx-3",
|
||||
credits <= 0 ? "bg-destructive/10" : credits <= 3 ? "bg-yellow-500/10" : "bg-primary/10"
|
||||
)}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Coins className={cn(
|
||||
"w-5 h-5",
|
||||
credits <= 0 ? "text-destructive" : credits <= 3 ? "text-yellow-600" : "text-primary"
|
||||
)} />
|
||||
<span className="font-medium">크레딧</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className={cn(
|
||||
"text-xl font-bold",
|
||||
credits <= 0 ? "text-destructive" : credits <= 3 ? "text-yellow-600" : "text-primary"
|
||||
)}>
|
||||
{credits}
|
||||
</span>
|
||||
<span className="text-sm text-muted-foreground">개</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{user.role !== 'admin' && credits !== null && credits <= 3 && (
|
||||
<Link
|
||||
to="/credits"
|
||||
onClick={() => setMobileOpen(false)}
|
||||
className="flex items-center justify-center gap-2 mx-3 px-3 py-2 rounded-lg bg-primary/10 text-primary text-sm font-medium hover:bg-primary/20 transition-colors"
|
||||
>
|
||||
<Coins className="w-4 h-4" />
|
||||
크레딧 충전 요청
|
||||
</Link>
|
||||
)}
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-start gap-2 text-destructive hover:text-destructive"
|
||||
onClick={handleLogout}
|
||||
>
|
||||
<LogOut className="w-4 h-4" />
|
||||
{t('menuLogout')}
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
<Button variant="outline" className="w-full" asChild>
|
||||
<Link to="/login" onClick={() => setMobileOpen(false)}>
|
||||
{t('menuLogin')}
|
||||
</Link>
|
||||
</Button>
|
||||
<Button className="w-full" asChild>
|
||||
<Link to="/register" onClick={() => setMobileOpen(false)}>
|
||||
{t('menuStart')}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Separator className="my-4" />
|
||||
|
||||
{/* Mobile Theme Settings */}
|
||||
<div className="px-3 space-y-4">
|
||||
{/* Theme Toggle */}
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-sm font-medium">
|
||||
{theme === 'dark' ? '다크 모드' : '라이트 모드'}
|
||||
</span>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={toggleTheme}
|
||||
className="gap-2"
|
||||
>
|
||||
{theme === 'dark' ? (
|
||||
<>
|
||||
<Sun className="w-4 h-4" />
|
||||
<span>라이트</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Moon className="w-4 h-4" />
|
||||
<span>다크</span>
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Palette Selection */}
|
||||
<div>
|
||||
<p className="text-xs font-medium text-muted-foreground mb-2">
|
||||
컬러 팔레트
|
||||
</p>
|
||||
<div className="flex gap-2">
|
||||
{(Object.keys(PALETTES) as ColorPalette[]).map((key) => (
|
||||
<button
|
||||
key={key}
|
||||
onClick={() => setPalette(key)}
|
||||
className={cn(
|
||||
"w-8 h-8 rounded-full bg-gradient-to-r transition-all",
|
||||
PALETTES[key].preview,
|
||||
palette === key
|
||||
? "ring-2 ring-offset-2 ring-offset-background ring-primary scale-110"
|
||||
: "hover:scale-105"
|
||||
)}
|
||||
title={PALETTES[key].name}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator className="my-4" />
|
||||
|
||||
{/* Mobile Language Selection */}
|
||||
<div className="px-3">
|
||||
<p className="text-xs font-medium text-muted-foreground mb-2">
|
||||
{t('settingLanguage') || 'Language'}
|
||||
</p>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{LANGUAGES.map((lang) => (
|
||||
<button
|
||||
key={lang.code}
|
||||
onClick={() => setLanguage(lang.code as Language)}
|
||||
className={cn(
|
||||
"flex items-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors",
|
||||
language === lang.code
|
||||
? "bg-primary/10 text-primary border border-primary/20"
|
||||
: "bg-accent/50 hover:bg-accent"
|
||||
)}
|
||||
>
|
||||
<span className={`fi fi-${lang.flag} rounded-sm`} />
|
||||
<span className="truncate">{lang.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
||||
export default Navbar;
|
||||
@@ -0,0 +1,234 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { X, ChevronRight, Check } from 'lucide-react';
|
||||
|
||||
interface TourStep {
|
||||
target: string;
|
||||
title: string;
|
||||
description: string;
|
||||
placement?: 'top' | 'bottom' | 'left' | 'right';
|
||||
}
|
||||
|
||||
interface OnboardingTourProps {
|
||||
steps: TourStep[];
|
||||
onComplete: () => void;
|
||||
onSkip: () => void;
|
||||
}
|
||||
|
||||
const OnboardingTour: React.FC<OnboardingTourProps> = ({ steps, onComplete, onSkip }) => {
|
||||
const [currentStep, setCurrentStep] = useState(0);
|
||||
const [position, setPosition] = useState({ top: 0, left: 0 });
|
||||
|
||||
useEffect(() => {
|
||||
// Remove previous highlights
|
||||
document.querySelectorAll('.tour-highlight').forEach(el => {
|
||||
el.classList.remove('tour-highlight');
|
||||
});
|
||||
|
||||
const updatePosition = () => {
|
||||
const target = document.querySelector(steps[currentStep].target);
|
||||
|
||||
if (!target) {
|
||||
console.warn(`Tour target not found: ${steps[currentStep].target}`);
|
||||
// Try again after a short delay
|
||||
setTimeout(updatePosition, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
// 팝업을 화면 기준으로 고정 배치 (스크롤에 영향받지 않음)
|
||||
const viewportWidth = window.innerWidth;
|
||||
|
||||
// 모바일/데스크톱 구분
|
||||
const isMobile = viewportWidth < 768;
|
||||
|
||||
let top: number;
|
||||
let left: number;
|
||||
|
||||
if (isMobile) {
|
||||
// 모바일: 화면 하단 고정
|
||||
top = 20; // viewport 기준
|
||||
left = 20;
|
||||
} else {
|
||||
// 데스크톱: 화면 우측 상단 고정
|
||||
top = 20; // viewport 기준 (상단에서 20px)
|
||||
left = viewportWidth - 340; // 우측에서 340px (카드 너비 320 + 여유 20)
|
||||
}
|
||||
|
||||
setPosition({ top, left });
|
||||
|
||||
// Highlight target element
|
||||
target.classList.add('tour-highlight');
|
||||
|
||||
// Scroll into view
|
||||
target.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
};
|
||||
|
||||
// Wait for DOM to be ready
|
||||
const timer = setTimeout(updatePosition, 150);
|
||||
|
||||
window.addEventListener('resize', updatePosition);
|
||||
window.addEventListener('scroll', updatePosition);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
window.removeEventListener('resize', updatePosition);
|
||||
window.removeEventListener('scroll', updatePosition);
|
||||
};
|
||||
}, [currentStep, steps]);
|
||||
|
||||
const handleNext = () => {
|
||||
if (currentStep < steps.length - 1) {
|
||||
setCurrentStep(currentStep + 1);
|
||||
} else {
|
||||
onComplete();
|
||||
}
|
||||
};
|
||||
|
||||
const handlePrev = () => {
|
||||
if (currentStep > 0) {
|
||||
setCurrentStep(currentStep - 1);
|
||||
}
|
||||
};
|
||||
|
||||
const currentStepData = steps[currentStep];
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Overlay - 매우 투명하게 */}
|
||||
<div className="fixed inset-0 bg-black/5 z-40 animate-in fade-in" />
|
||||
|
||||
{/* Tour Card - viewport 기준 고정 위치 */}
|
||||
<div
|
||||
className="fixed z-50 w-80 bg-gray-900/98 backdrop-blur-md border-2 border-purple-500 rounded-2xl shadow-2xl animate-in fade-in zoom-in-95"
|
||||
style={{
|
||||
top: `${position.top}px`, // viewport 기준
|
||||
right: '20px', // 우측 고정
|
||||
maxHeight: 'calc(100vh - 40px)', // 화면 높이에서 여유 40px
|
||||
overflowY: 'auto'
|
||||
}}
|
||||
>
|
||||
{/* Header */}
|
||||
<div className="p-4 border-b border-gray-700 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-1">
|
||||
{steps.map((_, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className={`h-2 rounded-full transition-all ${
|
||||
idx === currentStep
|
||||
? 'w-8 bg-purple-500'
|
||||
: idx < currentStep
|
||||
? 'w-2 bg-green-500'
|
||||
: 'w-2 bg-gray-600'
|
||||
}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<span className="text-xs text-gray-400 ml-2">
|
||||
{currentStep + 1} / {steps.length}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={onSkip}
|
||||
className="text-gray-400 hover:text-white transition-colors"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="p-5">
|
||||
<h3 className="text-xl font-bold text-white mb-2 flex items-center gap-2">
|
||||
<span className="w-8 h-8 rounded-full bg-purple-600 flex items-center justify-center text-sm">
|
||||
{currentStep + 1}
|
||||
</span>
|
||||
{currentStepData.title}
|
||||
</h3>
|
||||
<p className="text-gray-300 text-sm leading-relaxed">
|
||||
{currentStepData.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="p-4 border-t border-gray-700 flex items-center justify-between">
|
||||
<button
|
||||
onClick={onSkip}
|
||||
className="text-sm text-gray-400 hover:text-white transition-colors"
|
||||
>
|
||||
건너뛰기
|
||||
</button>
|
||||
<div className="flex gap-2">
|
||||
{currentStep > 0 && (
|
||||
<button
|
||||
onClick={handlePrev}
|
||||
className="px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg text-sm font-semibold transition-all"
|
||||
>
|
||||
이전
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
onClick={handleNext}
|
||||
className="px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg text-sm font-semibold transition-all flex items-center gap-2"
|
||||
>
|
||||
{currentStep === steps.length - 1 ? (
|
||||
<>
|
||||
<Check className="w-4 h-4" />
|
||||
완료
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
다음
|
||||
<ChevronRight className="w-4 h-4" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* CSS for highlight effect */}
|
||||
<style>{`
|
||||
.tour-highlight {
|
||||
position: relative !important;
|
||||
z-index: 9999 !important;
|
||||
background-color: white !important;
|
||||
box-shadow:
|
||||
0 0 0 6px rgba(168, 85, 247, 1),
|
||||
0 0 0 12px rgba(168, 85, 247, 0.5),
|
||||
0 0 40px 0 rgba(168, 85, 247, 0.6),
|
||||
0 0 80px 0 rgba(168, 85, 247, 0.3) !important;
|
||||
border-radius: 16px !important;
|
||||
animation: pulse-highlight 2s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
|
||||
outline: none !important;
|
||||
transform: scale(1.02) !important;
|
||||
transition: all 0.3s ease !important;
|
||||
}
|
||||
|
||||
.tour-highlight * {
|
||||
position: relative !important;
|
||||
z-index: 10000 !important;
|
||||
}
|
||||
|
||||
@keyframes pulse-highlight {
|
||||
0%, 100% {
|
||||
box-shadow:
|
||||
0 0 0 6px rgba(168, 85, 247, 1),
|
||||
0 0 0 12px rgba(168, 85, 247, 0.5),
|
||||
0 0 40px 0 rgba(168, 85, 247, 0.6),
|
||||
0 0 80px 0 rgba(168, 85, 247, 0.3);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
50% {
|
||||
box-shadow:
|
||||
0 0 0 8px rgba(168, 85, 247, 1),
|
||||
0 0 0 16px rgba(168, 85, 247, 0.6),
|
||||
0 0 60px 0 rgba(168, 85, 247, 0.8),
|
||||
0 0 100px 0 rgba(168, 85, 247, 0.4);
|
||||
transform: scale(1.03);
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default OnboardingTour;
|
||||
@@ -0,0 +1,157 @@
|
||||
import React from 'react';
|
||||
import { GeneratedAssets } from '../types';
|
||||
import { Play, Clock, Music, Mic, Video, Image as ImageIcon, Download } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* ResultList 컴포넌트의 Props 정의
|
||||
* @interface ResultListProps
|
||||
* @property {GeneratedAssets[]} history - 생성된 에셋들의 배열 (기록)
|
||||
* @property {(asset: GeneratedAssets) => void} onSelect - 목록에서 에셋 선택 시 호출될 콜백 함수
|
||||
* @property {string} [currentId] - 현재 선택된 에셋의 ID (선택 사항, UI에서 강조 표시용)
|
||||
*/
|
||||
interface ResultListProps {
|
||||
history: GeneratedAssets[];
|
||||
onSelect: (asset: GeneratedAssets) => void;
|
||||
currentId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 생성 기록 목록 컴포넌트
|
||||
* 이전에 생성된 AI 광고 영상/포스터 목록을 보여주고, 클릭 시 해당 에셋을 다시 볼 수 있도록 합니다.
|
||||
*/
|
||||
const ResultList: React.FC<ResultListProps> = ({ history, onSelect, currentId }) => {
|
||||
// 파일 강제 다운로드 핸들러
|
||||
const handleDirectDownload = async (e: React.MouseEvent, url: string, filename: string) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const blob = await response.blob();
|
||||
const blobUrl = window.URL.createObjectURL(blob);
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = blobUrl;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
a.remove();
|
||||
} catch (err) {
|
||||
console.error("다운로드 실패:", err);
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
};
|
||||
|
||||
if (history.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="w-full max-w-5xl mx-auto mt-12 mb-20 animate-in slide-in-from-bottom-10 duration-700">
|
||||
<div className="flex items-center gap-3 mb-6 px-4">
|
||||
<Clock className="w-5 h-5 text-purple-400" />
|
||||
<h3 className="text-xl font-bold text-white">생성 기록 (History)</h3>
|
||||
<span className="px-2 py-0.5 bg-purple-500/20 text-purple-300 text-xs rounded-full font-mono">{history.length}</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 px-4">
|
||||
{history.map((asset) => (
|
||||
<div
|
||||
key={asset.id}
|
||||
onClick={() => onSelect(asset)}
|
||||
className={`group relative bg-white/5 border rounded-2xl overflow-hidden cursor-pointer transition-all hover:scale-[1.02] hover:shadow-xl hover:shadow-purple-500/10
|
||||
${currentId === asset.id ? 'border-purple-500 ring-1 ring-purple-500 bg-white/10' : 'border-white/10 hover:border-purple-500/50'}
|
||||
`}
|
||||
>
|
||||
{/* 포스터 썸네일 */}
|
||||
<div className="aspect-video bg-black relative overflow-hidden">
|
||||
{asset.posterUrl ? (
|
||||
<img
|
||||
src={asset.posterUrl}
|
||||
alt={asset.businessName}
|
||||
className="w-full h-full object-cover opacity-80 group-hover:opacity-100 transition-opacity"
|
||||
onError={(e) => {
|
||||
e.currentTarget.style.display = 'none'; // 이미지 숨김
|
||||
e.currentTarget.nextElementSibling?.classList.remove('hidden'); // 대체 div 표시 (구조상 별도 처리 필요하지만 간단히 숨김 처리)
|
||||
// 부모 요소에 배경색이 있으므로 이미지가 숨겨지면 배경색이 보임.
|
||||
// 더 완벽하게 하려면 state로 관리해야 하나, 여기선 간단히 처리.
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full h-full bg-gray-800 flex items-center justify-center text-gray-500"><ImageIcon /></div>
|
||||
)}
|
||||
{/* 이미지 로드 실패 시 보여줄 폴백 (JS로 제어하기보다, 위 onError에서 이미지 숨기면 아래 배경이 보임) */}
|
||||
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 group-hover:opacity-100 transition-opacity backdrop-blur-[2px]">
|
||||
<div className="p-3 rounded-full bg-white/20 backdrop-blur-sm border border-white/30">
|
||||
<Play className="w-6 h-6 text-white fill-white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="absolute top-2 left-2 flex gap-1 flex-wrap">
|
||||
{asset.audioMode === 'Song' ? (
|
||||
<div className="p-1 bg-purple-600/90 rounded text-white shadow-sm"><Music className="w-3 h-3" /></div>
|
||||
) : (
|
||||
<div className="p-1 bg-blue-600/90 rounded text-white shadow-sm"><Mic className="w-3 h-3" /></div>
|
||||
)}
|
||||
<div className="px-2 py-0.5 bg-black/60 backdrop-blur-sm rounded text-[10px] text-white font-bold border border-white/10 flex items-center">
|
||||
{asset.textEffect}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 정보 영역 */}
|
||||
<div className="p-4">
|
||||
<h4 className="text-white font-bold truncate mb-1 text-base">{asset.businessName}</h4>
|
||||
|
||||
{asset.sourceUrl && (
|
||||
<a href={asset.sourceUrl} target="_blank" rel="noreferrer" onClick={(e) => e.stopPropagation()} className="text-xs text-blue-400 hover:underline truncate block mb-2 opacity-70 hover:opacity-100">
|
||||
{asset.sourceUrl}
|
||||
</a>
|
||||
)}
|
||||
|
||||
<div className="flex items-center justify-between text-xs text-gray-400">
|
||||
{/* 생성 날짜 및 시간 */}
|
||||
<span>
|
||||
{new Date(asset.createdAt).toLocaleDateString()}
|
||||
</span>
|
||||
{/* 장르 또는 비디오 타입 표시 */}
|
||||
<span className="flex items-center gap-1 bg-white/5 px-1.5 py-0.5 rounded">
|
||||
{asset.audioMode === 'Song' ? (
|
||||
<>{asset.musicGenre || 'Music'}</>
|
||||
) : (
|
||||
<><Mic className="w-3 h-3" /> Narration</>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 하단 버튼 영역 */}
|
||||
<div className="px-4 pb-4 pt-0 flex gap-2">
|
||||
{asset.finalVideoPath ? (
|
||||
<button
|
||||
onClick={(e) => handleDirectDownload(e, asset.finalVideoPath!, `CastAD_${asset.businessName}_Final.mp4`)}
|
||||
className="flex-1 py-2 bg-green-600 hover:bg-green-500 rounded-lg text-sm font-bold text-white transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
<Download className="w-4 h-4" /> 다운로드
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onSelect(asset);
|
||||
}}
|
||||
className={`flex-1 py-2 bg-purple-600 hover:bg-purple-500 rounded-lg text-sm font-bold text-white transition-colors flex items-center justify-center gap-2 ${asset.finalVideoPath ? 'bg-gray-700 hover:bg-gray-600' : ''}`}
|
||||
>
|
||||
<Play className="w-4 h-4" /> {asset.finalVideoPath ? '수정/재생성' : '결과 보기 / 다운로드'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ResultList;
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,189 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { X, Copy, Check, Share2, Smartphone, Link as LinkIcon } from 'lucide-react';
|
||||
|
||||
/**
|
||||
* ShareModal 컴포넌트의 Props 정의
|
||||
* @interface ShareModalProps
|
||||
* @property {string} videoUrl - 공유할 비디오 파일의 URL
|
||||
* @property {string} posterUrl - (현재 사용되지 않지만, 공유 데이터에 포함될 수 있는) 포스터 이미지 URL
|
||||
* @property {string} businessName - 비디오의 비즈니스 이름 (파일 이름 등에 사용)
|
||||
* @property {() => void} onClose - 모달을 닫을 때 호출될 콜백 함수
|
||||
*/
|
||||
interface ShareModalProps {
|
||||
videoUrl: string;
|
||||
posterUrl: string; // 현재 사용되지 않음
|
||||
businessName: string;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 공유 모달 컴포넌트
|
||||
* 생성된 비디오를 공유하기 위한 옵션을 제공합니다. (링크 복사, 파일 직접 공유 등)
|
||||
*/
|
||||
const ShareModal: React.FC<ShareModalProps> = ({ videoUrl, businessName, onClose }) => {
|
||||
const [isGenerating, setIsGenerating] = useState(true); // 공유 링크 생성 중 여부
|
||||
const [shareLink, setShareLink] = useState(''); // 생성된 공유 링크
|
||||
const [copied, setCopied] = useState(false); // 링크 복사 성공 여부
|
||||
const [canShareFile, setCanShareFile] = useState(false); // Web Share API로 파일 공유 가능한지 여부
|
||||
|
||||
/**
|
||||
* 컴포넌트 마운트 시 공유 링크를 생성하고 Web Share API 지원 여부를 확인합니다.
|
||||
*/
|
||||
useEffect(() => {
|
||||
// 고유 ID를 기반으로 목업 공유 링크를 생성합니다. (실제 서비스에서는 백엔드에서 생성)
|
||||
const uniqueId = Math.random().toString(36).substring(2, 10);
|
||||
const mockLink = `${window.location.origin}/share/${uniqueId}`; // 실제 앱에서는 호스팅된 비디오 URL이 됩니다.
|
||||
|
||||
// 링크 생성 시뮬레이션 (1.5초 후 완료)
|
||||
const timer = setTimeout(() => {
|
||||
setShareLink(mockLink);
|
||||
setIsGenerating(false);
|
||||
}, 1500);
|
||||
|
||||
// Web Share API (파일 공유) 지원 여부 확인
|
||||
if (navigator.share && navigator.canShare) {
|
||||
setCanShareFile(true);
|
||||
}
|
||||
|
||||
return () => clearTimeout(timer); // 컴포넌트 언마운트 시 타이머 정리
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* 공유 링크를 클립보드에 복사하는 핸들러
|
||||
*/
|
||||
const handleCopy = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(shareLink);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000); // 2초 후 복사 상태 초기화
|
||||
} catch (err) {
|
||||
console.error('링크 복사 실패:', err);
|
||||
alert("링크 복사에 실패했습니다. 수동으로 복사해주세요.");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 네이티브 웹 공유 API를 사용하여 비디오 파일을 직접 공유하는 핸들러
|
||||
* Instagram, KakaoTalk 등 모바일 앱으로 직접 공유할 때 유용합니다.
|
||||
*/
|
||||
const handleNativeShare = async () => {
|
||||
try {
|
||||
// 비디오 Blob URL을 File 객체로 변환하여 공유 데이터에 포함시킵니다.
|
||||
const response = await fetch(videoUrl);
|
||||
const blob = await response.blob();
|
||||
// 파일 이름은 업체명과 광고로 구성
|
||||
const file = new File([blob], `${businessName.replace(/\s+/g, '_')}_광고.mp4`, { type: 'video/mp4' });
|
||||
|
||||
const shareData = {
|
||||
title: `${businessName} AI 광고 영상`,
|
||||
text: 'BizVibe로 제작된 AI 음악 비디오 광고를 확인해보세요!',
|
||||
files: [file] // 공유할 파일 배열
|
||||
};
|
||||
|
||||
// 파일 공유가 가능한지 다시 확인 후 공유
|
||||
if (navigator.canShare(shareData)) {
|
||||
await navigator.share(shareData);
|
||||
} else {
|
||||
// 파일 공유가 지원되지 않을 경우, 텍스트와 링크만 공유하는 폴백
|
||||
await navigator.share({
|
||||
title: shareData.title,
|
||||
text: shareData.text,
|
||||
url: shareLink
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('공유 중 오류 발생:', err);
|
||||
alert("공유 기능 사용 중 오류가 발생했습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm animate-in fade-in duration-200"> {/* 모달 배경 및 페이드인 애니메이션 */}
|
||||
<div className="relative w-full max-w-md mx-4 bg-[#1a1a1d] border border-purple-500/30 rounded-2xl shadow-2xl overflow-hidden">
|
||||
|
||||
{/* 모달 헤더 */}
|
||||
<div className="p-6 border-b border-white/10 flex items-center justify-between bg-white/5">
|
||||
<h3 className="text-xl font-bold text-white flex items-center gap-2">
|
||||
<Share2 className="w-5 h-5 text-purple-400" />
|
||||
공유하기
|
||||
</h3>
|
||||
<button
|
||||
onClick={onClose} // 모달 닫기 버튼
|
||||
className="p-2 rounded-full hover:bg-white/10 text-gray-400 hover:text-white transition-colors"
|
||||
>
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="p-6 space-y-6">
|
||||
{isGenerating ? (
|
||||
// 링크 생성 중일 때 로딩 스피너 표시
|
||||
<div className="text-center py-8 space-y-4">
|
||||
<div className="relative w-16 h-16 mx-auto">
|
||||
<div className="absolute inset-0 border-4 border-purple-500/30 rounded-full"></div>
|
||||
<div className="absolute inset-0 border-4 border-t-purple-500 rounded-full animate-spin"></div>
|
||||
</div>
|
||||
<p className="text-gray-300 animate-pulse">고유 공유 링크 생성 중...</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{/* 고유 링크 섹션 */}
|
||||
<div className="space-y-2">
|
||||
<label className="text-xs font-bold text-gray-400 uppercase tracking-wider flex items-center gap-1">
|
||||
<LinkIcon className="w-3 h-3" /> 공개 링크
|
||||
</label>
|
||||
<div className="flex items-center gap-2 p-2 bg-black/50 rounded-xl border border-gray-700">
|
||||
<input
|
||||
type="text"
|
||||
readOnly // 읽기 전용
|
||||
value={shareLink}
|
||||
className="flex-1 bg-transparent text-sm text-purple-300 outline-none font-mono"
|
||||
/>
|
||||
<button
|
||||
onClick={handleCopy} // 복사 버튼
|
||||
className={`p-2 rounded-lg transition-all ${
|
||||
copied
|
||||
? 'bg-green-500/20 text-green-400' // 복사 완료 시 초록색 강조
|
||||
: 'bg-white/10 hover:bg-white/20 text-white'
|
||||
}`}
|
||||
>
|
||||
{copied ? <Check className="w-4 h-4" /> : <Copy className="w-4 h-4" />} {/* 복사 아이콘 변경 */}
|
||||
</button>
|
||||
</div>
|
||||
<p className="text-[10px] text-gray-500">
|
||||
* 이 링크는 데모용이며 실제로는 호스팅되지 않습니다. 비디오 파일을 직접 공유하려면 아래 버튼을 사용하세요.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 네이티브 공유 섹션 */}
|
||||
{canShareFile && (
|
||||
<button
|
||||
onClick={handleNativeShare} // 네이티브 공유 버튼
|
||||
className="w-full py-4 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-500 hover:to-pink-500 text-white font-bold rounded-xl shadow-lg shadow-purple-900/30 transform transition-all hover:scale-[1.02] flex items-center justify-center gap-3"
|
||||
>
|
||||
<Smartphone className="w-5 h-5" />
|
||||
영상 파일 직접 공유 (Instagram, Kakao 등)
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* 소셜 아이콘 목업 (클릭 시 새 탭 열림) */}
|
||||
<div className="grid grid-cols-3 gap-3 pt-2">
|
||||
{['Twitter', 'Facebook', 'LinkedIn'].map((platform) => (
|
||||
<button
|
||||
key={platform}
|
||||
className="py-3 rounded-xl bg-white/5 hover:bg-white/10 border border-white/5 text-gray-400 hover:text-white text-xs font-medium transition-all"
|
||||
onClick={() => window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent('BizVibe로 만든 AI 음악 비디오를 확인해보세요! ' + shareLink)}`, '_blank')} // 소셜 공유 링크 생성
|
||||
>
|
||||
{platform}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShareModal;
|
||||
@@ -0,0 +1,222 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { TransitionEffect } from '../types';
|
||||
|
||||
interface SlideshowBackgroundProps {
|
||||
images: string[];
|
||||
durationPerImage?: number;
|
||||
transitionDuration?: number;
|
||||
effect?: TransitionEffect; // 선택된 효과
|
||||
}
|
||||
|
||||
const EFFECTS_MAP: Record<TransitionEffect, string[]> = {
|
||||
'Mix': ['fade', 'blur-fade'],
|
||||
'Zoom': ['zoom-in', 'zoom-out', 'ken-burns-extreme'],
|
||||
'Slide': ['slide-left', 'slide-right', 'slide-up', 'slide-down'],
|
||||
'Wipe': ['pixelate-sim', 'flash', 'glitch'] // Wipe 대신 화려한 효과들을 매핑
|
||||
};
|
||||
|
||||
const ALL_EFFECTS = [
|
||||
'fade',
|
||||
'slide-left', 'slide-right', 'slide-up', 'slide-down',
|
||||
'zoom-in', 'zoom-out', 'zoom-spin',
|
||||
'flip-x', 'flip-y',
|
||||
'blur-fade',
|
||||
'glitch',
|
||||
'ken-burns-extreme',
|
||||
'pixelate-sim',
|
||||
'flash'
|
||||
];
|
||||
|
||||
/**
|
||||
* 사용자 선택에 따른 전환 효과를 적용한 슬라이드쇼 컴포넌트
|
||||
*/
|
||||
const SlideshowBackground: React.FC<SlideshowBackgroundProps> = ({
|
||||
images,
|
||||
durationPerImage = 6000,
|
||||
transitionDuration = 1500,
|
||||
effect = 'Mix' // 기본값 Mix
|
||||
}) => {
|
||||
const [activeIndex, setActiveIndex] = useState(0);
|
||||
const [currentAnimName, setCurrentAnimName] = useState('fade');
|
||||
|
||||
// 효과 매핑 로직
|
||||
const getNextEffect = () => {
|
||||
const candidates = EFFECTS_MAP[effect] || EFFECTS_MAP['Mix'];
|
||||
return candidates[Math.floor(Math.random() * candidates.length)];
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (images.length <= 1) return;
|
||||
|
||||
// 초기 효과 설정
|
||||
setCurrentAnimName(getNextEffect());
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const nextIndex = (activeIndex + 1) % images.length;
|
||||
setCurrentAnimName(getNextEffect()); // 다음 효과 랜덤 선택 (카테고리 내에서)
|
||||
setActiveIndex(nextIndex);
|
||||
}, durationPerImage);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [activeIndex, images.length, durationPerImage, effect]);
|
||||
|
||||
if (!images || images.length === 0) return <div className="w-full h-full bg-black" />;
|
||||
|
||||
return (
|
||||
<div className="absolute inset-0 w-full h-full overflow-hidden bg-black perspective-1000">
|
||||
{images.map((src, index) => {
|
||||
const isActive = index === activeIndex;
|
||||
const isPrev = index === (activeIndex - 1 + images.length) % images.length;
|
||||
|
||||
let effectClass = '';
|
||||
if (isActive) {
|
||||
effectClass = `animate-${currentAnimName}-in`;
|
||||
} else if (isPrev) {
|
||||
effectClass = `animate-fade-out`;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
key={`${src}-${index}`}
|
||||
className={`absolute inset-0 w-full h-full
|
||||
${isActive ? 'z-20 opacity-100' : isPrev ? 'z-10 opacity-100' : 'z-0 opacity-0'}
|
||||
${effectClass}
|
||||
`}
|
||||
style={{
|
||||
animationDuration: `${transitionDuration}ms`,
|
||||
animationFillMode: 'forwards',
|
||||
transformOrigin: 'center center'
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={src}
|
||||
alt={`Slide ${index}`}
|
||||
className="w-full h-full object-cover"
|
||||
style={{ objectPosition: 'center' }}
|
||||
/>
|
||||
{/* 텍스트 가독성을 위한 오버레이 */}
|
||||
<div className="absolute inset-0 bg-black/30 pointer-events-none" />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
<style>{`
|
||||
.perspective-1000 { perspective: 1000px; }
|
||||
|
||||
/* === Common Out Animation === */
|
||||
@keyframes fade-out {
|
||||
0% { opacity: 1; }
|
||||
100% { opacity: 0; }
|
||||
}
|
||||
.animate-fade-out { animation-name: fade-out; }
|
||||
|
||||
/* === 1. Fade === */
|
||||
@keyframes fade-in {
|
||||
0% { opacity: 0; }
|
||||
100% { opacity: 1; }
|
||||
}
|
||||
.animate-fade-in { animation-name: fade-in; }
|
||||
|
||||
/* === 2-5. Slides === */
|
||||
@keyframes slide-left-in {
|
||||
0% { transform: translateX(100%); opacity: 0; }
|
||||
100% { transform: translateX(0); opacity: 1; }
|
||||
}
|
||||
.animate-slide-left-in { animation-name: slide-left-in; }
|
||||
|
||||
@keyframes slide-right-in {
|
||||
0% { transform: translateX(-100%); opacity: 0; }
|
||||
100% { transform: translateX(0); opacity: 1; }
|
||||
}
|
||||
.animate-slide-right-in { animation-name: slide-right-in; }
|
||||
|
||||
@keyframes slide-up-in {
|
||||
0% { transform: translateY(100%); opacity: 0; }
|
||||
100% { transform: translateY(0); opacity: 1; }
|
||||
}
|
||||
.animate-slide-up-in { animation-name: slide-up-in; }
|
||||
|
||||
@keyframes slide-down-in {
|
||||
0% { transform: translateY(-100%); opacity: 0; }
|
||||
100% { transform: translateY(0); opacity: 1; }
|
||||
}
|
||||
.animate-slide-down-in { animation-name: slide-down-in; }
|
||||
|
||||
/* === 6-8. Zooms === */
|
||||
@keyframes zoom-in-in {
|
||||
0% { transform: scale(0.5); opacity: 0; }
|
||||
100% { transform: scale(1); opacity: 1; }
|
||||
}
|
||||
.animate-zoom-in-in { animation-name: zoom-in-in; }
|
||||
|
||||
@keyframes zoom-out-in {
|
||||
0% { transform: scale(1.5); opacity: 0; }
|
||||
100% { transform: scale(1); opacity: 1; }
|
||||
}
|
||||
.animate-zoom-out-in { animation-name: zoom-out-in; }
|
||||
|
||||
@keyframes zoom-spin-in {
|
||||
0% { transform: scale(0) rotate(-180deg); opacity: 0; }
|
||||
100% { transform: scale(1) rotate(0deg); opacity: 1; }
|
||||
}
|
||||
.animate-zoom-spin-in { animation-name: zoom-spin-in; }
|
||||
|
||||
/* === 9-10. Flips (3D) === */
|
||||
@keyframes flip-x-in {
|
||||
0% { transform: perspective(400px) rotateX(90deg); opacity: 0; }
|
||||
100% { transform: perspective(400px) rotateX(0deg); opacity: 1; }
|
||||
}
|
||||
.animate-flip-x-in { animation-name: flip-x-in; }
|
||||
|
||||
@keyframes flip-y-in {
|
||||
0% { transform: perspective(400px) rotateY(90deg); opacity: 0; }
|
||||
100% { transform: perspective(400px) rotateY(0deg); opacity: 1; }
|
||||
}
|
||||
.animate-flip-y-in { animation-name: flip-y-in; }
|
||||
|
||||
/* === 11. Blur Fade === */
|
||||
@keyframes blur-fade-in {
|
||||
0% { filter: blur(20px); opacity: 0; transform: scale(1.1); }
|
||||
100% { filter: blur(0px); opacity: 1; transform: scale(1); }
|
||||
}
|
||||
.animate-blur-fade-in { animation-name: blur-fade-in; }
|
||||
|
||||
/* === 12. Glitch === */
|
||||
@keyframes glitch-in {
|
||||
0% { transform: translate(0); opacity: 0; }
|
||||
20% { transform: translate(-5px, 5px); opacity: 1; }
|
||||
40% { transform: translate(-5px, -5px); }
|
||||
60% { transform: translate(5px, 5px); }
|
||||
80% { transform: translate(5px, -5px); }
|
||||
100% { transform: translate(0); opacity: 1; }
|
||||
}
|
||||
.animate-glitch-in { animation-name: glitch-in; }
|
||||
|
||||
/* === 13. Ken Burns Extreme === */
|
||||
@keyframes ken-burns-extreme-in {
|
||||
0% { transform: scale(1.5) translate(10%, 10%); opacity: 0; }
|
||||
100% { transform: scale(1) translate(0, 0); opacity: 1; }
|
||||
}
|
||||
.animate-ken-burns-extreme-in { animation-name: ken-burns-extreme-in; }
|
||||
|
||||
/* === 14. Pixelate Simulation === */
|
||||
@keyframes pixelate-sim-in {
|
||||
0% { filter: blur(10px) contrast(200%); opacity: 0; }
|
||||
50% { filter: blur(5px) contrast(150%); opacity: 0.5; }
|
||||
100% { filter: blur(0) contrast(100%); opacity: 1; }
|
||||
}
|
||||
.animate-pixelate-sim-in { animation-name: pixelate-sim-in; }
|
||||
|
||||
/* === 15. Flash (Lens Flare Vibe) === */
|
||||
@keyframes flash-in {
|
||||
0% { filter: brightness(300%); opacity: 0; }
|
||||
50% { filter: brightness(200%); opacity: 1; }
|
||||
100% { filter: brightness(100%); opacity: 1; }
|
||||
}
|
||||
.animate-flash-in { animation-name: flash-in; }
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SlideshowBackground;
|
||||
Reference in new issue
Block a user