feat: implement management folder architecture, hover-only tool sliders, grain transform animation, and prominent upload studio
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import React, { useRef, useEffect, useCallback } from 'react';
|
||||
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
||||
|
||||
interface CardBeforeAfterSliderProps {
|
||||
beforeUrl: string;
|
||||
@@ -18,9 +18,11 @@ export function CardBeforeAfterSlider({
|
||||
aspectRatio = 'aspect-[16/10]',
|
||||
}: CardBeforeAfterSliderProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const isHoveredRef = useRef(false);
|
||||
const isDraggingRef = useRef(false);
|
||||
const isInteractedRef = useRef(false);
|
||||
const animIdRef = useRef<number>(0);
|
||||
const [isHoveredState, setIsHoveredState] = useState(false);
|
||||
|
||||
const setSplit = useCallback((percent: number) => {
|
||||
const clamped = Math.max(3, Math.min(97, percent));
|
||||
@@ -41,51 +43,50 @@ export function CardBeforeAfterSlider({
|
||||
[setSplit]
|
||||
);
|
||||
|
||||
// Gentle auto-sliding animation until the user actively clicks
|
||||
// Smooth, gentle before/after slide sweep: RUNS ONLY ON HOVER OVER THIS SPECIFIC CARD!
|
||||
useEffect(() => {
|
||||
let startTime: number | null = null;
|
||||
let isVisible = true;
|
||||
|
||||
const animate = (time: number) => {
|
||||
if (!isVisible) return;
|
||||
if (!isInteractedRef.current) {
|
||||
// ONLY animate when actively hovered and not manually dragging
|
||||
if (isHoveredRef.current && !isDraggingRef.current && !isInteractedRef.current) {
|
||||
if (startTime === null) startTime = time;
|
||||
const elapsed = time - startTime;
|
||||
// Smooth sine wave between 28% and 72% over a 3.4-second cycle
|
||||
const currentSplit = 50 + 22 * Math.sin((elapsed / 3400) * 2 * Math.PI);
|
||||
// Calm, luxurious 3.6-second oscillation between 28% and 72%
|
||||
const currentSplit = 50 + 22 * Math.sin((elapsed / 3600) * 2 * Math.PI);
|
||||
setSplit(currentSplit);
|
||||
animIdRef.current = requestAnimationFrame(animate);
|
||||
}
|
||||
};
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
isVisible = entry.isIntersecting;
|
||||
if (isVisible && !isInteractedRef.current) {
|
||||
startTime = null;
|
||||
animIdRef.current = requestAnimationFrame(animate);
|
||||
} else {
|
||||
cancelAnimationFrame(animIdRef.current);
|
||||
}
|
||||
},
|
||||
{ threshold: 0.05 }
|
||||
);
|
||||
|
||||
if (containerRef.current) {
|
||||
observer.observe(containerRef.current);
|
||||
}
|
||||
|
||||
if (!isInteractedRef.current) {
|
||||
if (isHoveredState && !isInteractedRef.current) {
|
||||
startTime = null;
|
||||
animIdRef.current = requestAnimationFrame(animate);
|
||||
} else {
|
||||
cancelAnimationFrame(animIdRef.current);
|
||||
}
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(animIdRef.current);
|
||||
observer.disconnect();
|
||||
};
|
||||
}, [isHoveredState, setSplit]);
|
||||
|
||||
const handleMouseEnter = useCallback(() => {
|
||||
isHoveredRef.current = true;
|
||||
setIsHoveredState(true);
|
||||
}, []);
|
||||
|
||||
const handleMouseLeave = useCallback(() => {
|
||||
isHoveredRef.current = false;
|
||||
isDraggingRef.current = false;
|
||||
setIsHoveredState(false);
|
||||
// Smoothly return to clean 50% rest state
|
||||
if (!isInteractedRef.current) {
|
||||
setSplit(50);
|
||||
}
|
||||
}, [setSplit]);
|
||||
|
||||
// Click & Drag handlers: DOES NOT WORK ON HOVER - REQUIRES CURSOR CLICK!
|
||||
// Click & Drag handlers: manual inspection when user clicks or drags
|
||||
const handleMouseDown = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
@@ -138,6 +139,8 @@ export function CardBeforeAfterSlider({
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
onMouseDown={handleMouseDown}
|
||||
onTouchStart={handleTouchStart}
|
||||
onTouchMove={handleTouchMove}
|
||||
@@ -147,7 +150,7 @@ export function CardBeforeAfterSlider({
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
style={{ '--split': '50%' } as React.CSSProperties}
|
||||
className={`relative w-full ${aspectRatio} overflow-hidden cursor-ew-resize select-none bg-slate-900 group/slider`}
|
||||
className={`relative w-full ${aspectRatio} overflow-hidden cursor-ew-resize select-none bg-slate-900 group/slider transition-shadow duration-300 hover:shadow-cream-lg`}
|
||||
>
|
||||
{/* Layer 1: After Image (Transformed Neural Result) */}
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
@@ -198,9 +201,9 @@ export function CardBeforeAfterSlider({
|
||||
{afterLabel}
|
||||
</div>
|
||||
|
||||
{/* Click / Drag Hint */}
|
||||
<div className="pointer-events-none absolute top-2.5 right-2.5 z-20 rounded-full bg-white/90 px-2.5 py-0.5 text-[9px] font-semibold text-slate-700 shadow-sm backdrop-blur-xs opacity-0 group-hover/slider:opacity-100 transition-opacity">
|
||||
Click & drag to compare
|
||||
{/* Hover & Slide Hint */}
|
||||
<div className="pointer-events-none absolute top-2.5 right-2.5 z-20 rounded-full bg-white/92 px-2.5 py-0.5 text-[9px] font-semibold text-slate-700 shadow-sm backdrop-blur-xs opacity-0 group-hover/slider:opacity-100 transition-opacity">
|
||||
Drag to inspect
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
'use client';
|
||||
|
||||
import dynamic from 'next/dynamic';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
const Cinematic3DComparison = dynamic(
|
||||
() => import('./Cinematic3DComparison').then((module) => module.Cinematic3DComparison),
|
||||
{ ssr: false }
|
||||
);
|
||||
|
||||
interface DeferredComparisonProps {
|
||||
beforeUrl: string;
|
||||
afterUrl: string;
|
||||
beforeLabel?: string;
|
||||
afterLabel?: string;
|
||||
aspectRatio?: string;
|
||||
}
|
||||
|
||||
/** A fast static preview that upgrades to the comparison control near the viewport. */
|
||||
export function DeferredComparison({ beforeUrl, afterUrl, beforeLabel, afterLabel, aspectRatio = 'aspect-[4/3]' }: DeferredComparisonProps) {
|
||||
const previewRef = useRef<HTMLDivElement>(null);
|
||||
const [active, setActive] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const element = previewRef.current;
|
||||
if (!element) return;
|
||||
const observer = new IntersectionObserver(([entry]) => {
|
||||
if (!entry.isIntersecting) return;
|
||||
setActive(true);
|
||||
observer.disconnect();
|
||||
}, { rootMargin: '240px 0px' });
|
||||
observer.observe(element);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
if (active) {
|
||||
return <Cinematic3DComparison beforeUrl={beforeUrl} afterUrl={afterUrl} beforeLabel={beforeLabel} afterLabel={afterLabel} aspectRatio={aspectRatio} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div ref={previewRef} className={`relative overflow-hidden bg-slate-100 ${aspectRatio}`}>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img src={afterUrl} alt="AI-enhanced preview" loading="lazy" decoding="async" className="h-full w-full object-cover" />
|
||||
<span className="absolute bottom-3 left-3 rounded-full bg-white/92 px-3 py-1 text-xs font-semibold text-slate-800 shadow-sm">Drag to compare</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import { Menu, X, Smartphone, Layers, ArrowUpRight } from 'lucide-react';
|
||||
@@ -16,8 +16,6 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
const [isScrolled, setIsScrolled] = useState(false);
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const pathname = usePathname();
|
||||
const navRef = useRef<HTMLDivElement>(null);
|
||||
const glintRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
@@ -36,41 +34,13 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
return () => document.removeEventListener('keydown', closeOnEscape);
|
||||
}, [mobileMenuOpen]);
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!glintRef.current) return;
|
||||
const rect = e.currentTarget.getBoundingClientRect();
|
||||
const x = ((e.clientX - rect.left) / rect.width) * 100;
|
||||
const y = ((e.clientY - rect.top) / rect.height) * 100;
|
||||
glintRef.current.style.opacity = '0.6';
|
||||
glintRef.current.style.background = `radial-gradient(ellipse 260px 80px at ${x.toFixed(1)}% ${y.toFixed(1)}%, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.08) 40%, transparent 70%)`;
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
if (glintRef.current) {
|
||||
glintRef.current.style.opacity = '0';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="fixed top-3 sm:top-5 left-0 right-0 z-50 px-3 sm:px-6 lg:px-8 pointer-events-none transition-all duration-300">
|
||||
<div
|
||||
ref={navRef}
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
className={`relative max-w-6xl mx-auto liquid-glass-nav rounded-2xl sm:rounded-[22px] px-3.5 sm:px-6 py-2.5 sm:py-3 flex items-center justify-between transition-all duration-300 pointer-events-auto ${
|
||||
isScrolled ? 'nav-scrolled' : ''
|
||||
}`}
|
||||
>
|
||||
{/* Optical Glass Caustic Reflection Sheen */}
|
||||
<div className="liquid-caustic-refraction" aria-hidden="true" />
|
||||
|
||||
{/* Dynamic Specular Caustic Glint - Direct DOM, 0 React re-renders */}
|
||||
<div
|
||||
ref={glintRef}
|
||||
className="absolute inset-0 pointer-events-none transition-opacity duration-300 z-[2] opacity-0"
|
||||
/>
|
||||
|
||||
{/* Foreground Content: 100% Crisp, High-Contrast, Rock-Solid Static (Zero Wobble) */}
|
||||
<div className="relative z-20 flex items-center justify-between w-full">
|
||||
{/* Brand Logo */}
|
||||
<div className="relative z-20">
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
interface NeuralGrainOverlayProps {
|
||||
intensity?: number;
|
||||
active?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function NeuralGrainOverlay({
|
||||
intensity = 0.22,
|
||||
active = true,
|
||||
className = '',
|
||||
}: NeuralGrainOverlayProps) {
|
||||
if (!active) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className={`pointer-events-none absolute inset-0 z-10 overflow-hidden mix-blend-overlay ${className}`}
|
||||
style={{ opacity: intensity }}
|
||||
>
|
||||
{/* High-frequency animated SVG noise filter */}
|
||||
<svg className="absolute inset-0 h-full w-full opacity-65">
|
||||
<filter id="neural-grain-noise">
|
||||
<feTurbulence
|
||||
type="fractalNoise"
|
||||
baseFrequency="0.75"
|
||||
numOctaves="3"
|
||||
stitchTiles="stitch"
|
||||
>
|
||||
<animate
|
||||
attributeName="seed"
|
||||
from="1"
|
||||
to="60"
|
||||
dur="1.8s"
|
||||
repeatCount="indefinite"
|
||||
/>
|
||||
</feTurbulence>
|
||||
<feColorMatrix type="saturate" values="0" />
|
||||
</filter>
|
||||
<rect width="100%" height="100%" filter="url(#neural-grain-noise)" />
|
||||
</svg>
|
||||
|
||||
{/* Latent Neural Scan Sweep Beam */}
|
||||
<div className="absolute inset-y-0 w-28 bg-gradient-to-r from-transparent via-blue-400/25 to-transparent animate-neural-sweep pointer-events-none" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,20 +1,36 @@
|
||||
'use client';
|
||||
|
||||
import { motion, useReducedMotion } from 'framer-motion';
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
/** Subtle, viewport-triggered entrance shared by every JSON-driven page section. */
|
||||
/** Lightweight progressive enhancement: content is visible before JavaScript runs. */
|
||||
export function SectionEntrance({ children, id }: { children: React.ReactNode; id: string }) {
|
||||
const reduceMotion = useReducedMotion();
|
||||
const sectionRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const element = sectionRef.current;
|
||||
if (!element || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
if (!entry.isIntersecting) return;
|
||||
element.dataset.revealed = 'true';
|
||||
observer.disconnect();
|
||||
},
|
||||
{ rootMargin: '0px 0px -6% 0px', threshold: 0.03 }
|
||||
);
|
||||
|
||||
observer.observe(element);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
<div
|
||||
ref={sectionRef}
|
||||
data-section-entrance={id}
|
||||
initial={reduceMotion ? false : { opacity: 0, y: 14 }}
|
||||
whileInView={{ opacity: 1, y: 0 }}
|
||||
viewport={{ once: true, amount: 0.08, margin: '0px 0px -24px 0px' }}
|
||||
transition={{ duration: 0.42, ease: [0.22, 1, 0.36, 1] }}
|
||||
data-revealed="false"
|
||||
className={id === 'hero-section' ? 'section-shell section-shell--hero' : 'section-shell'}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user