feat: complete dynamic JSON-driven photo tools frontend connected to FastAPI backend
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
||||
|
||||
interface BeforeAfterSliderProps {
|
||||
beforeUrl: string;
|
||||
afterUrl: string;
|
||||
beforeLabel?: string;
|
||||
afterLabel?: string;
|
||||
caption?: string;
|
||||
aspectRatio?: string;
|
||||
}
|
||||
|
||||
export function BeforeAfterSlider({
|
||||
beforeUrl,
|
||||
afterUrl,
|
||||
beforeLabel = 'Original',
|
||||
afterLabel = 'AI Result',
|
||||
caption,
|
||||
aspectRatio = 'aspect-[4/3]',
|
||||
}: BeforeAfterSliderProps) {
|
||||
const [sliderPosition, setSliderPosition] = useState(50);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const handleMove = useCallback((clientX: number) => {
|
||||
if (!containerRef.current) return;
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
const x = Math.max(0, Math.min(clientX - rect.left, rect.width));
|
||||
const percent = Math.max(0, Math.min(100, (x / rect.width) * 100));
|
||||
setSliderPosition(percent);
|
||||
}, []);
|
||||
|
||||
const handleTouchMove = useCallback((e: TouchEvent) => {
|
||||
if (!isDragging) return;
|
||||
handleMove(e.touches[0].clientX);
|
||||
}, [isDragging, handleMove]);
|
||||
|
||||
const handleMouseMove = useCallback((e: MouseEvent) => {
|
||||
if (!isDragging) return;
|
||||
handleMove(e.clientX);
|
||||
}, [isDragging, handleMove]);
|
||||
|
||||
const handleMouseUp = useCallback(() => {
|
||||
setIsDragging(false);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (isDragging) {
|
||||
window.addEventListener('mousemove', handleMouseMove);
|
||||
window.addEventListener('mouseup', handleMouseUp);
|
||||
window.addEventListener('touchmove', handleTouchMove);
|
||||
window.addEventListener('touchend', handleMouseUp);
|
||||
}
|
||||
return () => {
|
||||
window.removeEventListener('mousemove', handleMouseMove);
|
||||
window.removeEventListener('mouseup', handleMouseUp);
|
||||
window.removeEventListener('touchmove', handleTouchMove);
|
||||
window.removeEventListener('touchend', handleMouseUp);
|
||||
};
|
||||
}, [isDragging, handleMouseMove, handleMouseUp, handleTouchMove]);
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<div
|
||||
ref={containerRef}
|
||||
onMouseDown={() => setIsDragging(true)}
|
||||
onTouchStart={() => setIsDragging(true)}
|
||||
className={`relative w-full ${aspectRatio} rounded-2xl overflow-hidden select-none cursor-ew-resize shadow-lg border border-slate-200 dark:border-slate-800 bg-slate-950`}
|
||||
>
|
||||
{/* After Image (Background) */}
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
src={afterUrl}
|
||||
alt="After result"
|
||||
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
|
||||
/>
|
||||
|
||||
{/* Before Image (Clipped) */}
|
||||
<div
|
||||
className="absolute inset-0 overflow-hidden pointer-events-none"
|
||||
style={{ clipPath: `polygon(0 0, ${sliderPosition}% 0, ${sliderPosition}% 100%, 0 100%)` }}
|
||||
>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
src={beforeUrl}
|
||||
alt="Before result"
|
||||
className="absolute inset-0 w-full h-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Split Divider Line */}
|
||||
<div
|
||||
className="absolute top-0 bottom-0 w-0.5 bg-white shadow-[0_0_10px_rgba(0,0,0,0.5)] z-20 pointer-events-none"
|
||||
style={{ left: `${sliderPosition}%` }}
|
||||
>
|
||||
{/* Center Handle */}
|
||||
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-8 h-8 rounded-full bg-white dark:bg-slate-900 border-2 border-blue-600 shadow-md flex items-center justify-center pointer-events-auto cursor-ew-resize">
|
||||
<svg
|
||||
className="w-4 h-4 text-blue-600"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Floating Labels */}
|
||||
<div className="absolute top-3 left-3 bg-black/60 backdrop-blur-md px-2.5 py-1 rounded-md text-xs font-semibold text-white pointer-events-none z-10">
|
||||
{beforeLabel}
|
||||
</div>
|
||||
<div className="absolute top-3 right-3 bg-blue-600/90 backdrop-blur-md px-2.5 py-1 rounded-md text-xs font-semibold text-white pointer-events-none z-10">
|
||||
{afterLabel}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{caption && (
|
||||
<p className="mt-2 text-center text-xs text-slate-500 dark:text-slate-400">
|
||||
{caption}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Sparkles, Shield, Heart } from 'lucide-react';
|
||||
import { SiteConfig, resolveLocalised } from '@/types';
|
||||
|
||||
interface FooterProps {
|
||||
config: SiteConfig;
|
||||
currentLocale: string;
|
||||
}
|
||||
|
||||
export function Footer({ config, currentLocale }: FooterProps) {
|
||||
return (
|
||||
<footer className="bg-slate-50 dark:bg-slate-950 border-t border-slate-200 dark:border-slate-800 transition-colors">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 lg:py-16">
|
||||
<div className="grid grid-cols-1 md:grid-cols-4 gap-8">
|
||||
{/* Brand info */}
|
||||
<div className="md:col-span-2 space-y-4">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-8 h-8 rounded-lg bg-blue-600 flex items-center justify-center text-white">
|
||||
<Sparkles className="w-4 h-4" />
|
||||
</div>
|
||||
<span className="text-xl font-bold text-slate-900 dark:text-white">
|
||||
{config.brand.name}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm text-slate-600 dark:text-slate-400 max-w-sm">
|
||||
{resolveLocalised(config.brand.tagline, currentLocale)}. Try our professional photo AI tools free online, then unlock 4K batch processing in our native mobile apps.
|
||||
</p>
|
||||
<div className="flex items-center space-x-2 text-xs text-emerald-600 dark:text-emerald-400 font-medium">
|
||||
<Shield className="w-4 h-4" />
|
||||
<span>Zero-Storage Policy: Photos processed in RAM and streamed directly back.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Quick Links */}
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold uppercase tracking-wider text-slate-900 dark:text-white mb-4">
|
||||
Explore
|
||||
</h4>
|
||||
<ul className="space-y-2 text-sm">
|
||||
<li>
|
||||
<Link href="/tools" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
All Photo Tools
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/apps" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
Mobile Apps Suite
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/pricing" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
Pricing & In-App Credits
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/catalog-manager" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
API Catalogue Inspector
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Legal & Trust */}
|
||||
<div>
|
||||
<h4 className="text-sm font-semibold uppercase tracking-wider text-slate-900 dark:text-white mb-4">
|
||||
Trust & Legal
|
||||
</h4>
|
||||
<ul className="space-y-2 text-sm">
|
||||
<li>
|
||||
<Link href="/trust" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
Trust & Security
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/privacy" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
Privacy Policy
|
||||
</Link>
|
||||
</li>
|
||||
<li>
|
||||
<Link href="/terms" className="text-slate-600 dark:text-slate-400 hover:text-blue-600 dark:hover:text-blue-400">
|
||||
Terms of Service
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bottom Bar */}
|
||||
<div className="mt-12 pt-8 border-t border-slate-200 dark:border-slate-800 flex flex-col sm:flex-row items-center justify-between text-xs text-slate-500 dark:text-slate-500">
|
||||
<p>{config.footer.copyright}</p>
|
||||
<p className="mt-2 sm:mt-0 flex items-center space-x-1">
|
||||
<span>Built with precision for creators</span>
|
||||
<Heart className="w-3.5 h-3.5 text-rose-500 inline fill-rose-500" />
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { Sparkles, Moon, Sun, Menu, X, Smartphone, Globe } from 'lucide-react';
|
||||
import { SiteConfig, resolveLocalised } from '@/types';
|
||||
|
||||
interface NavbarProps {
|
||||
config: SiteConfig;
|
||||
currentLocale: string;
|
||||
onLocaleChange?: (locale: string) => void;
|
||||
}
|
||||
|
||||
export function Navbar({ config, currentLocale, onLocaleChange }: NavbarProps) {
|
||||
const [isScrolled, setIsScrolled] = useState(false);
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [isDark, setIsDark] = useState(false);
|
||||
const pathname = usePathname();
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
setIsScrolled(window.scrollY > 20);
|
||||
};
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
return () => window.removeEventListener('scroll', handleScroll);
|
||||
}, []);
|
||||
|
||||
const toggleTheme = () => {
|
||||
const nextDark = !isDark;
|
||||
setIsDark(nextDark);
|
||||
if (nextDark) {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<header
|
||||
className={`sticky top-0 z-50 transition-all duration-200 ${
|
||||
isScrolled
|
||||
? 'bg-white/90 dark:bg-slate-900/90 backdrop-blur-md shadow-sm border-b border-slate-200 dark:border-slate-800'
|
||||
: 'bg-white dark:bg-slate-900 border-b border-transparent'
|
||||
}`}
|
||||
>
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between">
|
||||
{/* Brand Logo */}
|
||||
<Link href="/" className="flex items-center space-x-3 group">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-tr from-blue-600 to-teal-500 flex items-center justify-center text-white shadow-md shadow-blue-500/20 group-hover:scale-105 transition-transform">
|
||||
<Sparkles className="w-5 h-5" />
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-teal-600 dark:from-blue-400 dark:to-teal-400">
|
||||
{config.brand.name}
|
||||
</span>
|
||||
<span className="hidden sm:block text-xs text-slate-500 dark:text-slate-400">
|
||||
{resolveLocalised(config.brand.tagline, currentLocale)}
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
{/* Desktop Navigation Links */}
|
||||
<nav className="hidden md:flex items-center space-x-1 lg:space-x-2">
|
||||
{config.nav.header.map((item) => {
|
||||
const active = pathname === item.href;
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className={`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${
|
||||
active
|
||||
? 'text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950/40'
|
||||
: 'text-slate-700 dark:text-slate-200 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-slate-50 dark:hover:bg-slate-800/50'
|
||||
}`}
|
||||
>
|
||||
{resolveLocalised(item.label, currentLocale)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* Right Action Buttons */}
|
||||
<div className="hidden md:flex items-center space-x-3">
|
||||
{/* Theme Toggle */}
|
||||
<button
|
||||
onClick={toggleTheme}
|
||||
aria-label="Toggle theme"
|
||||
className="p-2 rounded-lg text-slate-500 dark:text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors"
|
||||
>
|
||||
{isDark ? <Sun className="w-5 h-5 text-amber-400" /> : <Moon className="w-5 h-5 text-slate-600" />}
|
||||
</button>
|
||||
|
||||
{/* Primary CTA Button */}
|
||||
<Link
|
||||
href={config.nav.cta.href}
|
||||
className="inline-flex items-center space-x-2 px-4 py-2 rounded-xl text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 shadow-md shadow-blue-500/20 transition-all hover:shadow-lg active:scale-95"
|
||||
>
|
||||
<Smartphone className="w-4 h-4" />
|
||||
<span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Mobile menu trigger */}
|
||||
<div className="flex md:hidden items-center space-x-2">
|
||||
<button
|
||||
onClick={toggleTheme}
|
||||
className="p-2 rounded-lg text-slate-600 dark:text-slate-300"
|
||||
>
|
||||
{isDark ? <Sun className="w-5 h-5 text-amber-400" /> : <Moon className="w-5 h-5" />}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||
className="p-2 rounded-lg text-slate-700 dark:text-slate-200 hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
aria-label="Open menu"
|
||||
>
|
||||
{mobileMenuOpen ? <X className="w-6 h-6" /> : <Menu className="w-6 h-6" />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mobile Menu Dropdown */}
|
||||
{mobileMenuOpen && (
|
||||
<div className="md:hidden border-b border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 px-4 pt-2 pb-6 space-y-2">
|
||||
{config.nav.header.map((item) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
className="block px-3 py-2 rounded-lg text-base font-medium text-slate-700 dark:text-slate-200 hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
>
|
||||
{resolveLocalised(item.label, currentLocale)}
|
||||
</Link>
|
||||
))}
|
||||
<div className="pt-2">
|
||||
<Link
|
||||
href={config.nav.cta.href}
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
className="flex items-center justify-center space-x-2 w-full px-4 py-3 rounded-xl text-sm font-medium text-white bg-blue-600 hover:bg-blue-700"
|
||||
>
|
||||
<Smartphone className="w-4 h-4" />
|
||||
<span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user