perf(animations): refactor ShiftableToolsGrid, cursor, hero & sections to locked 60-120fps with zero layout thrashing
This commit is contained in:
@@ -35,45 +35,69 @@ export function Particles({
|
|||||||
context.current = canvasRef.current.getContext('2d');
|
context.current = canvasRef.current.getContext('2d');
|
||||||
initCanvas();
|
initCanvas();
|
||||||
|
|
||||||
// IntersectionObserver to pause loop when scrolled out of view!
|
// IntersectionObserver to pause loop completely when scrolled out of view!
|
||||||
let animId = 0;
|
let animId = 0;
|
||||||
|
let isRunning = false;
|
||||||
|
|
||||||
|
const startAnimation = () => {
|
||||||
|
if (isRunning) return;
|
||||||
|
isRunning = true;
|
||||||
|
const animate = () => {
|
||||||
|
if (!isVisibleRef.current) {
|
||||||
|
isRunning = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (context.current) {
|
||||||
|
clearContext();
|
||||||
|
circles.current.forEach((circle: any) => {
|
||||||
|
const edge = [
|
||||||
|
circle.x + circle.size < 0,
|
||||||
|
circle.x - circle.size > canvasSize.current.w,
|
||||||
|
circle.y + circle.size < 0,
|
||||||
|
circle.y - circle.size > canvasSize.current.h,
|
||||||
|
];
|
||||||
|
if (edge[0] || edge[1]) circle.dx = -circle.dx;
|
||||||
|
if (edge[2] || edge[3]) circle.dy = -circle.dy;
|
||||||
|
|
||||||
|
circle.x += circle.dx;
|
||||||
|
circle.y += circle.dy;
|
||||||
|
|
||||||
|
if (circle.alpha < circle.targetAlpha) {
|
||||||
|
circle.alpha += 0.015;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCircle(circle, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
animId = window.requestAnimationFrame(animate);
|
||||||
|
};
|
||||||
|
animId = window.requestAnimationFrame(animate);
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopAnimation = () => {
|
||||||
|
isRunning = false;
|
||||||
|
if (animId) {
|
||||||
|
cancelAnimationFrame(animId);
|
||||||
|
animId = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
isVisibleRef.current = entry.isIntersecting;
|
isVisibleRef.current = entry.isIntersecting;
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
startAnimation();
|
||||||
|
} else {
|
||||||
|
stopAnimation();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{ threshold: 0.05 }
|
{ threshold: 0.05 }
|
||||||
);
|
);
|
||||||
observer.observe(container);
|
observer.observe(container);
|
||||||
|
|
||||||
const animate = () => {
|
startAnimation();
|
||||||
if (isVisibleRef.current && context.current) {
|
|
||||||
clearContext();
|
|
||||||
circles.current.forEach((circle: any) => {
|
|
||||||
const edge = [
|
|
||||||
circle.x + circle.size < 0,
|
|
||||||
circle.x - circle.size > canvasSize.current.w,
|
|
||||||
circle.y + circle.size < 0,
|
|
||||||
circle.y - circle.size > canvasSize.current.h,
|
|
||||||
];
|
|
||||||
if (edge[0] || edge[1]) circle.dx = -circle.dx;
|
|
||||||
if (edge[2] || edge[3]) circle.dy = -circle.dy;
|
|
||||||
|
|
||||||
circle.x += circle.dx;
|
|
||||||
circle.y += circle.dy;
|
|
||||||
|
|
||||||
if (circle.alpha < circle.targetAlpha) {
|
|
||||||
circle.alpha += 0.015;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawCircle(circle, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
animId = window.requestAnimationFrame(animate);
|
|
||||||
};
|
|
||||||
|
|
||||||
animId = window.requestAnimationFrame(animate);
|
|
||||||
|
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
resizeCanvas();
|
resizeCanvas();
|
||||||
|
|||||||
@@ -56,32 +56,31 @@ export function SmoothCursor() {
|
|||||||
const target = e.target as HTMLElement | null;
|
const target = e.target as HTMLElement | null;
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
const interactive = target.closest('a, button, input, textarea, select, [role="button"], .cursor-pointer');
|
const interactive = target.closest('a, button, input, textarea, select, [role="button"], .cursor-pointer');
|
||||||
isHovered = !!interactive;
|
const nextHovered = !!interactive;
|
||||||
|
|
||||||
if (isHovered) {
|
if (nextHovered !== isHovered) {
|
||||||
ring.style.width = '52px';
|
isHovered = nextHovered;
|
||||||
ring.style.height = '52px';
|
if (isHovered) {
|
||||||
ring.style.borderColor = 'rgba(37, 99, 235, 0.7)';
|
ring.style.borderColor = 'rgba(37, 99, 235, 0.7)';
|
||||||
ring.style.backgroundColor = 'rgba(37, 99, 235, 0.12)';
|
ring.style.backgroundColor = 'rgba(37, 99, 235, 0.12)';
|
||||||
dot.style.transform = `translate3d(${mouseX}px, ${mouseY}px, 0) scale(0)`;
|
} else {
|
||||||
} else {
|
ring.style.borderColor = 'rgba(37, 99, 235, 0.35)';
|
||||||
ring.style.width = '30px';
|
ring.style.backgroundColor = 'rgba(37, 99, 235, 0.04)';
|
||||||
ring.style.height = '30px';
|
}
|
||||||
ring.style.borderColor = 'rgba(37, 99, 235, 0.4)';
|
|
||||||
ring.style.backgroundColor = 'rgba(37, 99, 235, 0.05)';
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ultra-smooth 120fps/60fps RAF lerp loop (Zero React re-renders!)
|
// Locked 60-120fps RAF lerp loop (Zero React re-renders, 100% GPU composited transforms)
|
||||||
const loop = () => {
|
const loop = () => {
|
||||||
// Smooth linear interpolation for trailing ring
|
// Smooth linear interpolation for trailing ring
|
||||||
ringX += (mouseX - ringX) * 0.22;
|
ringX += (mouseX - ringX) * 0.22;
|
||||||
ringY += (mouseY - ringY) * 0.22;
|
ringY += (mouseY - ringY) * 0.22;
|
||||||
|
|
||||||
ring.style.transform = `translate3d(${ringX}px, ${ringY}px, 0) translate(-50%, -50%)`;
|
const ringScale = isHovered ? 1.45 : 1;
|
||||||
if (!isHovered) {
|
ring.style.transform = `translate3d(${ringX}px, ${ringY}px, 0) translate3d(-50%, -50%, 0) scale(${ringScale})`;
|
||||||
dot.style.transform = `translate3d(${mouseX}px, ${mouseY}px, 0) translate(-50%, -50%) scale(1)`;
|
|
||||||
}
|
const dotScale = isHovered ? 0 : 1;
|
||||||
|
dot.style.transform = `translate3d(${mouseX}px, ${mouseY}px, 0) translate3d(-50%, -50%, 0) scale(${dotScale})`;
|
||||||
|
|
||||||
animId = requestAnimationFrame(loop);
|
animId = requestAnimationFrame(loop);
|
||||||
};
|
};
|
||||||
@@ -104,20 +103,16 @@ export function SmoothCursor() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="pointer-events-none fixed inset-0 z-[9999] overflow-hidden select-none">
|
<div className="pointer-events-none fixed inset-0 z-[9999] overflow-hidden select-none">
|
||||||
{/* Trailing Fluid Squircle Ring */}
|
{/* Trailing Fluid Squircle Ring (GPU-scale transform only, zero layout reflows) */}
|
||||||
<div
|
<div
|
||||||
ref={cursorRingRef}
|
ref={cursorRingRef}
|
||||||
className="fixed top-0 left-0 rounded-full border border-blue-500/40 bg-blue-500/5 backdrop-blur-[0.5px] pointer-events-none opacity-0 transition-[width,height,background-color,border-color] duration-200 ease-out will-change-transform"
|
className="fixed top-0 left-0 w-8 h-8 rounded-full border border-blue-500/35 bg-blue-500/4 pointer-events-none opacity-0 transition-[border-color,background-color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] will-change-transform transform-gpu [backface-visibility:hidden]"
|
||||||
style={{
|
|
||||||
width: '30px',
|
|
||||||
height: '30px',
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Precision Dot */}
|
{/* Precision Dot (GPU-scale transform only) */}
|
||||||
<div
|
<div
|
||||||
ref={cursorDotRef}
|
ref={cursorDotRef}
|
||||||
className="fixed top-0 left-0 w-2 h-2 rounded-full bg-blue-600 shadow-sm pointer-events-none opacity-0 transition-transform duration-100 ease-out will-change-transform"
|
className="fixed top-0 left-0 w-2 h-2 rounded-full bg-blue-600 shadow-sm pointer-events-none opacity-0 will-change-transform transform-gpu [backface-visibility:hidden]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -78,16 +78,16 @@ export function FaqSection({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={idx}
|
key={idx}
|
||||||
className="rounded-2xl border border-slate-200/90 bg-white overflow-hidden shadow-cream-sm hover:shadow-cream-md transition-all duration-200"
|
className="rounded-2xl border border-slate-200/90 bg-white overflow-hidden shadow-cream-sm hover:border-blue-300 transition-[border-color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setOpenIndex(isOpen ? null : idx)}
|
onClick={() => setOpenIndex(isOpen ? null : idx)}
|
||||||
className="w-full p-6 text-left flex items-center justify-between gap-4 font-bold text-slate-900 hover:text-blue-600 transition-colors"
|
className="w-full p-6 text-left flex items-center justify-between gap-4 font-bold text-slate-900 hover:text-blue-600 transition-colors duration-200"
|
||||||
>
|
>
|
||||||
<span className="text-base sm:text-lg font-display">{item.q}</span>
|
<span className="text-base sm:text-lg font-display">{item.q}</span>
|
||||||
<ChevronDown
|
<ChevronDown
|
||||||
className={`w-5 h-5 text-slate-400 shrink-0 transition-transform duration-200 ${
|
className={`w-5 h-5 text-slate-400 shrink-0 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||||
isOpen ? 'rotate-180 text-blue-600' : ''
|
isOpen ? 'rotate-180 text-blue-600' : ''
|
||||||
}`}
|
}`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -167,14 +167,14 @@ export function HeroSection({
|
|||||||
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
|
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
|
||||||
<a
|
<a
|
||||||
href={primaryCtaHref}
|
href={primaryCtaHref}
|
||||||
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-9 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-all duration-300 hover:scale-105 hover:from-blue-600 hover:to-indigo-600 active:scale-95"
|
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-9 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-[transform,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 active:scale-95"
|
||||||
>
|
>
|
||||||
<span>{primaryCtaLabel}</span>
|
<span>{primaryCtaLabel}</span>
|
||||||
<ArrowDown className="w-4 h-4 transition-transform group-hover:translate-y-0.5" />
|
<ArrowDown className="w-4 h-4 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-y-0.5" />
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href={secondaryCtaHref}
|
href={secondaryCtaHref}
|
||||||
className="inline-flex items-center gap-2.5 rounded-full border border-slate-300/80 bg-white/90 backdrop-blur-md px-8 py-4 text-xs sm:text-sm font-semibold text-slate-800 shadow-sm transition-all duration-300 hover:scale-105 hover:border-blue-400 hover:text-blue-600 hover:bg-white active:scale-95"
|
className="inline-flex items-center gap-2.5 rounded-full border border-slate-300/80 bg-white/90 backdrop-blur-md px-8 py-4 text-xs sm:text-sm font-semibold text-slate-800 shadow-sm transition-[transform,opacity,border-color,color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 hover:border-blue-400 hover:text-blue-600 hover:bg-white active:scale-95"
|
||||||
>
|
>
|
||||||
<Smartphone className="w-4 h-4 text-blue-600" />
|
<Smartphone className="w-4 h-4 text-blue-600" />
|
||||||
<span>{secondaryCtaLabel}</span>
|
<span>{secondaryCtaLabel}</span>
|
||||||
@@ -250,16 +250,14 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
|||||||
|
|
||||||
// Geometry: Floating Octahedron Crystal Prism
|
// Geometry: Floating Octahedron Crystal Prism
|
||||||
const geometry = new THREE.OctahedronGeometry(1.65, 0);
|
const geometry = new THREE.OctahedronGeometry(1.65, 0);
|
||||||
const material = new THREE.MeshPhysicalMaterial({
|
const material = new THREE.MeshStandardMaterial({
|
||||||
color: 0x2563eb,
|
color: 0x2563eb,
|
||||||
emissive: 0x1d4ed8,
|
emissive: 0x1d4ed8,
|
||||||
emissiveIntensity: 0.15,
|
emissiveIntensity: 0.25,
|
||||||
roughness: 0.25,
|
roughness: 0.2,
|
||||||
metalness: 0.1,
|
metalness: 0.2,
|
||||||
transmission: 0.85,
|
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.75,
|
opacity: 0.8,
|
||||||
ior: 1.5,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const crystal = new THREE.Mesh(geometry, material);
|
const crystal = new THREE.Mesh(geometry, material);
|
||||||
|
|||||||
@@ -120,8 +120,13 @@ export function RecommendedAppsSection({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={slug}
|
key={slug}
|
||||||
className="group relative flex flex-col justify-between rounded-3xl bg-white border border-slate-200/90 p-7 shadow-cream-sm hover:shadow-cream-lg transition-all duration-300 hover:-translate-y-1 hover:border-blue-400/60"
|
className="group relative flex flex-col justify-between rounded-3xl bg-white border border-slate-200/90 p-7 shadow-cream-sm transition-[transform,border-color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:-translate-y-1 hover:border-blue-400/60 will-change-transform transform-gpu"
|
||||||
>
|
>
|
||||||
|
{/* GPU Shadow Elevation Layer */}
|
||||||
|
<div
|
||||||
|
className="absolute -inset-px rounded-3xl shadow-cream-lg opacity-0 group-hover:opacity-100 transition-opacity duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
<div>
|
<div>
|
||||||
{/* Top App Icon & Rating */}
|
{/* Top App Icon & Rating */}
|
||||||
<div className="flex items-center justify-between mb-5">
|
<div className="flex items-center justify-between mb-5">
|
||||||
@@ -168,10 +173,10 @@ export function RecommendedAppsSection({
|
|||||||
<div className="pt-6 mt-5 border-t border-slate-100">
|
<div className="pt-6 mt-5 border-t border-slate-100">
|
||||||
<Link
|
<Link
|
||||||
href={`/apps/${slug}`}
|
href={`/apps/${slug}`}
|
||||||
className="w-full flex items-center justify-center gap-2 py-3.5 rounded-xl text-xs font-bold text-white bg-slate-950 group-hover:bg-blue-600 transition-all duration-300 shadow-sm group-hover:shadow-md"
|
className="w-full flex items-center justify-center gap-2 py-3.5 rounded-xl text-xs font-bold text-white bg-slate-950 group-hover:bg-blue-600 transition-colors duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] shadow-sm"
|
||||||
>
|
>
|
||||||
<span>Get App & QR Code</span>
|
<span>Get App & QR Code</span>
|
||||||
<ArrowRight className="w-3.5 h-3.5 transition-transform group-hover:translate-x-1" />
|
<ArrowRight className="w-3.5 h-3.5 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-x-1" />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ function ReviewCard({
|
|||||||
tool: string;
|
tool: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<figure className="relative w-80 sm:w-96 cursor-pointer overflow-hidden rounded-2xl border border-slate-200/90 bg-white p-5 shadow-cream-sm hover:shadow-cream-md hover:border-blue-300 transition-all duration-300">
|
<figure className="relative w-80 sm:w-96 cursor-pointer overflow-hidden rounded-2xl border border-slate-200/90 bg-white p-5 shadow-cream-sm hover:border-blue-300 transition-[border-color,transform] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div className="w-10 h-10 rounded-full bg-gradient-to-tr from-blue-600 to-indigo-600 flex items-center justify-center text-white text-xs font-bold tracking-wider shadow-sm">
|
<div className="w-10 h-10 rounded-full bg-gradient-to-tr from-blue-600 to-indigo-600 flex items-center justify-center text-white text-xs font-bold tracking-wider shadow-sm">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useState, useRef, useEffect } from 'react';
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { ArrowRight, Sparkles, Video, Sliders, Image as ImageIcon } from 'lucide-react';
|
import { ArrowRight, Sparkles, Video, Sliders, Image as ImageIcon } from 'lucide-react';
|
||||||
import { TextAnimate } from '@/components/magicui/text-animate';
|
import { TextAnimate } from '@/components/magicui/text-animate';
|
||||||
@@ -18,7 +18,7 @@ export interface ToolMediaItem {
|
|||||||
afterUrl?: string;
|
afterUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShiftableToolsGridProps {
|
export interface ShiftableToolsGridProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
subtitle?: string;
|
subtitle?: string;
|
||||||
tools?: ToolItem[];
|
tools?: ToolItem[];
|
||||||
@@ -26,7 +26,7 @@ interface ShiftableToolsGridProps {
|
|||||||
locale?: string;
|
locale?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||||
// ROW 1 (4 items) - Landscape 16:9 assets
|
// ROW 1 (4 items) - Landscape 16:9 assets
|
||||||
{
|
{
|
||||||
id: 'tool-blemish',
|
id: 'tool-blemish',
|
||||||
@@ -134,7 +134,7 @@ export function ShiftableToolsGridSection({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 2-Row Shiftable Grid Container (Pure Horizontal Expansion, Fixed Height, No Vertical Shifts) */}
|
{/* 2-Row Shiftable Grid Container (Slow, Calm, Pure Horizontal Expansion with Locked Height) */}
|
||||||
<div className="space-y-6 sm:space-y-8">
|
<div className="space-y-6 sm:space-y-8">
|
||||||
<ShiftableRow items={row1} />
|
<ShiftableRow items={row1} />
|
||||||
<ShiftableRow items={row2} />
|
<ShiftableRow items={row2} />
|
||||||
@@ -144,10 +144,10 @@ export function ShiftableToolsGridSection({
|
|||||||
<div className="pt-6 text-center">
|
<div className="pt-6 text-center">
|
||||||
<Link
|
<Link
|
||||||
href="/tools"
|
href="/tools"
|
||||||
className="group inline-flex items-center gap-2.5 px-8 py-4 rounded-full font-bold text-xs sm:text-sm text-white bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 hover:from-blue-600 hover:to-indigo-600 border border-white/10 shadow-lg shadow-slate-900/15 transition-all duration-300 hover:scale-105 active:scale-95"
|
className="group inline-flex items-center gap-2.5 px-8 py-4 rounded-full font-bold text-xs sm:text-sm text-white bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 hover:from-blue-600 hover:to-indigo-600 border border-white/10 shadow-lg shadow-slate-900/15 transition-[transform,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 active:scale-95"
|
||||||
>
|
>
|
||||||
<span>See More Tools</span>
|
<span>See More Tools</span>
|
||||||
<ArrowRight className="w-4 h-4 transition-transform group-hover:translate-x-1" />
|
<ArrowRight className="w-4 h-4 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-x-1" />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -164,31 +164,44 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
|||||||
const isHovered = hoveredId === item.id;
|
const isHovered = hoveredId === item.id;
|
||||||
const hasOtherHovered = hoveredId !== null && !isHovered;
|
const hasOtherHovered = hoveredId !== null && !isHovered;
|
||||||
|
|
||||||
// Luxurious, slow, and smooth horizontal expansion (flex weighting)
|
// Slow, calm, luxurious horizontal expansion:
|
||||||
// No vertical scaling, no height changes, purely horizontal shift
|
// When hovered: 1.85 flex-grow (~46% width)
|
||||||
const flexClass = isHovered
|
// When other is hovered: 0.716 flex-grow (~18% width)
|
||||||
? 'md:flex-[1.75]'
|
// At rest: 1.0 flex-grow (25% width each)
|
||||||
: hasOtherHovered
|
// Sum is always mathematically conserved at exactly 4.0 (1.85 + 3 * 0.716 = 4.00)
|
||||||
? 'md:flex-[0.75]'
|
// Fixed flex-basis: 0 eliminates conflicting layout calculations
|
||||||
: 'md:flex-1';
|
const flexGrowValue = isHovered ? 1.85 : hasOtherHovered ? 0.716 : 1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
onMouseEnter={() => setHoveredId(item.id)}
|
onMouseEnter={() => setHoveredId(item.id)}
|
||||||
onMouseLeave={() => setHoveredId(null)}
|
onMouseLeave={() => setHoveredId(null)}
|
||||||
className={`w-full ${flexClass} transition-[flex-grow,flex-basis] duration-700 ease-[cubic-bezier(0.25,1,0.5,1)] flex flex-col flex-shrink-0 min-w-0`}
|
style={{
|
||||||
|
flexGrow: flexGrowValue,
|
||||||
|
flexShrink: 1,
|
||||||
|
flexBasis: '0%',
|
||||||
|
}}
|
||||||
|
className="w-full transition-[flex-grow] duration-1000 ease-[cubic-bezier(0.16,1,0.3,1)] will-change-[flex-grow] flex flex-col min-w-0"
|
||||||
>
|
>
|
||||||
{/* Window Container with strictly locked pixel height & landscape aspect */}
|
{/* Window Container with strictly locked pixel height & landscape aspect */}
|
||||||
<Link
|
<Link
|
||||||
href={`/tools/${item.slug}`}
|
href={`/tools/${item.slug}`}
|
||||||
className="group block relative w-full h-[220px] sm:h-[240px] lg:h-[260px] rounded-2xl sm:rounded-3xl overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm hover:shadow-cream-lg transition-shadow duration-500"
|
className="group block relative w-full h-[220px] sm:h-[240px] lg:h-[260px] rounded-2xl sm:rounded-3xl overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm"
|
||||||
>
|
>
|
||||||
|
{/* GPU-Composited Shadow Elevation Layer (Opacity-only transition, zero paint thrash) */}
|
||||||
|
<div
|
||||||
|
className="absolute -inset-px rounded-2xl sm:rounded-3xl shadow-cream-lg opacity-0 group-hover:opacity-100 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none z-30"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Media Renderer */}
|
{/* Media Renderer */}
|
||||||
<ToolWindowMedia item={item} isHovered={isHovered} />
|
<ToolWindowMedia item={item} isHovered={isHovered} />
|
||||||
|
|
||||||
{/* Hover Media Type Pill */}
|
{/* Hover Media Type Pill (Smooth GPU Opacity Transition) */}
|
||||||
<div className="absolute top-3 left-3 z-20 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500">
|
<div
|
||||||
|
className="absolute top-3 left-3 z-20 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500 ease-[cubic-bezier(0.16,1,0.3,1)]"
|
||||||
|
>
|
||||||
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-slate-950/85 backdrop-blur-md text-white border border-white/20">
|
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-slate-950/85 backdrop-blur-md text-white border border-white/20">
|
||||||
{item.mediaType === 'video' && <Video className="w-3 h-3 text-cyan-400" />}
|
{item.mediaType === 'video' && <Video className="w-3 h-3 text-cyan-400" />}
|
||||||
{item.mediaType === 'comparison' && <Sliders className="w-3 h-3 text-amber-400" />}
|
{item.mediaType === 'comparison' && <Sliders className="w-3 h-3 text-amber-400" />}
|
||||||
@@ -201,10 +214,10 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
|||||||
{/* Little Title Below Window (Fixed height, no vertical jumping) */}
|
{/* Little Title Below Window (Fixed height, no vertical jumping) */}
|
||||||
<Link
|
<Link
|
||||||
href={`/tools/${item.slug}`}
|
href={`/tools/${item.slug}`}
|
||||||
className="mt-2.5 h-6 px-1 flex items-center justify-between text-xs sm:text-sm font-display font-semibold text-slate-800 hover:text-blue-600 transition-colors group"
|
className="mt-2.5 h-6 px-1 flex items-center justify-between text-xs sm:text-sm font-display font-semibold text-slate-800 hover:text-blue-600 transition-colors duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group"
|
||||||
>
|
>
|
||||||
<span className="truncate">{item.title}</span>
|
<span className="truncate">{item.title}</span>
|
||||||
<ArrowRight className="w-3.5 h-3.5 text-slate-400 group-hover:text-blue-600 group-hover:translate-x-0.5 transition-all flex-shrink-0 ml-1.5" />
|
<ArrowRight className="w-3.5 h-3.5 text-slate-400 group-hover:text-blue-600 group-hover:translate-x-0.5 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] flex-shrink-0 ml-1.5" />
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -215,9 +228,26 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
|||||||
|
|
||||||
function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered: boolean }) {
|
function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered: boolean }) {
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
const [sliderPos, setSliderPos] = useState<number>(50);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const [isManualHover, setIsManualHover] = useState(false);
|
const dividerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const afterImgRef = useRef<HTMLImageElement>(null);
|
||||||
|
|
||||||
|
// High performance refs - completely eliminates per-frame React re-renders!
|
||||||
|
const isManualRef = useRef(false);
|
||||||
const animFrameRef = useRef<number | null>(null);
|
const animFrameRef = useRef<number | null>(null);
|
||||||
|
const pointerRafRef = useRef<number | null>(null);
|
||||||
|
const cachedRectRef = useRef<{ left: number; width: number } | null>(null);
|
||||||
|
|
||||||
|
// Directly mutate DOM styles on the GPU layer without triggering React reconciliation
|
||||||
|
const setSliderDOM = useCallback((percent: number) => {
|
||||||
|
const clamped = Math.max(8, Math.min(92, percent));
|
||||||
|
if (dividerRef.current) {
|
||||||
|
dividerRef.current.style.left = `${clamped}%`;
|
||||||
|
}
|
||||||
|
if (afterImgRef.current) {
|
||||||
|
afterImgRef.current.style.clipPath = `inset(0 ${100 - clamped}% 0 0)`;
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Video Autoplay Muted Loop only on Hover (No zoom, no scale)
|
// Video Autoplay Muted Loop only on Hover (No zoom, no scale)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -231,23 +261,28 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
|||||||
}
|
}
|
||||||
}, [isHovered, item.mediaType]);
|
}, [isHovered, item.mediaType]);
|
||||||
|
|
||||||
// Before/After Smooth Automatic Oscillating Scan when hovered
|
// Smooth Automatic Oscillating Scan when hovered:
|
||||||
|
// Runs at 60-120fps directly mutating DOM refs (0 React re-renders!)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (item.mediaType !== 'comparison') return;
|
if (item.mediaType !== 'comparison') return;
|
||||||
|
|
||||||
if (!isHovered) {
|
if (!isHovered) {
|
||||||
setSliderPos(50);
|
isManualRef.current = false;
|
||||||
setIsManualHover(false);
|
if (animFrameRef.current) {
|
||||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
cancelAnimationFrame(animFrameRef.current);
|
||||||
|
animFrameRef.current = null;
|
||||||
|
}
|
||||||
|
setSliderDOM(50);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let startTime = Date.now();
|
const startTime = performance.now();
|
||||||
const sweep = () => {
|
const sweep = (now: number) => {
|
||||||
if (!isManualHover) {
|
if (!isManualRef.current) {
|
||||||
const elapsed = (Date.now() - startTime) / 1000;
|
const elapsed = (now - startTime) / 1000;
|
||||||
const pos = 50 + Math.sin(elapsed * 2.2) * 24;
|
// Calm, breathing oscillation: 1.4 rad/s sine wave with 22% sweep amplitude
|
||||||
setSliderPos(pos);
|
const pos = 50 + Math.sin(elapsed * 1.4) * 22;
|
||||||
|
setSliderDOM(pos);
|
||||||
}
|
}
|
||||||
animFrameRef.current = requestAnimationFrame(sweep);
|
animFrameRef.current = requestAnimationFrame(sweep);
|
||||||
};
|
};
|
||||||
@@ -255,22 +290,53 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
|||||||
animFrameRef.current = requestAnimationFrame(sweep);
|
animFrameRef.current = requestAnimationFrame(sweep);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
if (animFrameRef.current) {
|
||||||
|
cancelAnimationFrame(animFrameRef.current);
|
||||||
|
animFrameRef.current = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, [isHovered, isManualHover, item.mediaType]);
|
}, [isHovered, item.mediaType, setSliderDOM]);
|
||||||
|
|
||||||
// Pointer position tracking when mouse moves over the comparison window
|
// Pointer position tracking:
|
||||||
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
// Caches container bounding rect on enter to avoid layout thrashing in pointermove.
|
||||||
|
// Updates slider DOM in requestAnimationFrame with zero React state calls.
|
||||||
|
const handlePointerEnter = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||||
if (item.mediaType !== 'comparison') return;
|
if (item.mediaType !== 'comparison') return;
|
||||||
setIsManualHover(true);
|
|
||||||
const rect = e.currentTarget.getBoundingClientRect();
|
const rect = e.currentTarget.getBoundingClientRect();
|
||||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
cachedRectRef.current = { left: rect.left, width: rect.width };
|
||||||
const percent = Math.max(10, Math.min(90, (x / rect.width) * 100));
|
|
||||||
setSliderPos(percent);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseLeave = () => {
|
const handlePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||||
setIsManualHover(false);
|
if (item.mediaType !== 'comparison') return;
|
||||||
|
isManualRef.current = true;
|
||||||
|
|
||||||
|
const clientX = e.clientX;
|
||||||
|
if (pointerRafRef.current) {
|
||||||
|
cancelAnimationFrame(pointerRafRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
pointerRafRef.current = requestAnimationFrame(() => {
|
||||||
|
let rect = cachedRectRef.current;
|
||||||
|
if (!rect && containerRef.current) {
|
||||||
|
const r = containerRef.current.getBoundingClientRect();
|
||||||
|
rect = { left: r.left, width: r.width };
|
||||||
|
cachedRectRef.current = rect;
|
||||||
|
}
|
||||||
|
if (!rect || rect.width <= 0) return;
|
||||||
|
|
||||||
|
const x = Math.max(0, Math.min(clientX - rect.left, rect.width));
|
||||||
|
const percent = (x / rect.width) * 100;
|
||||||
|
setSliderDOM(percent);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePointerLeave = () => {
|
||||||
|
isManualRef.current = false;
|
||||||
|
cachedRectRef.current = null;
|
||||||
|
if (pointerRafRef.current) {
|
||||||
|
cancelAnimationFrame(pointerRafRef.current);
|
||||||
|
pointerRafRef.current = null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1. VIDEO (Strictly locked to fixed 680px centered width - ZERO ZOOM)
|
// 1. VIDEO (Strictly locked to fixed 680px centered width - ZERO ZOOM)
|
||||||
@@ -284,9 +350,10 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
|||||||
muted
|
muted
|
||||||
loop
|
loop
|
||||||
playsInline
|
playsInline
|
||||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-0 bg-slate-950/10 group-hover:bg-transparent transition-colors duration-500" />
|
{/* GPU-composited overlay (opacity only) */}
|
||||||
|
<div className="absolute inset-0 bg-slate-950/10 opacity-100 group-hover:opacity-0 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -295,51 +362,57 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
|||||||
if (item.mediaType === 'comparison' && item.beforeUrl && item.afterUrl) {
|
if (item.mediaType === 'comparison' && item.beforeUrl && item.afterUrl) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onMouseMove={handleMouseMove}
|
ref={containerRef}
|
||||||
onMouseLeave={handleMouseLeave}
|
onPointerEnter={handlePointerEnter}
|
||||||
className="relative w-full h-full select-none cursor-ew-resize overflow-hidden bg-slate-950"
|
onPointerMove={handlePointerMove}
|
||||||
|
onPointerLeave={handlePointerLeave}
|
||||||
|
className="relative w-full h-full select-none cursor-ew-resize overflow-hidden bg-slate-950 transform-gpu [backface-visibility:hidden]"
|
||||||
>
|
>
|
||||||
{/* BEFORE Image (Base layer, fixed scale & position, 0% zoom) */}
|
{/* BEFORE Image (Base layer, fixed scale & position, 0% zoom) */}
|
||||||
<img
|
<img
|
||||||
src={item.beforeUrl}
|
src={item.beforeUrl}
|
||||||
alt="Before"
|
alt="Before"
|
||||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* AFTER Image (Top layer, exact same position & scale, clipped via clip-path) */}
|
{/* AFTER Image (Top layer, exact same position & scale, clipped via clip-path) */}
|
||||||
<img
|
<img
|
||||||
|
ref={afterImgRef}
|
||||||
src={item.afterUrl}
|
src={item.afterUrl}
|
||||||
alt="After"
|
alt="After"
|
||||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||||
style={{
|
style={{
|
||||||
clipPath: `inset(0 ${100 - sliderPos}% 0 0)`,
|
clipPath: 'inset(0 50% 0 0)',
|
||||||
}}
|
}}
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Glowing Slider Divider Line */}
|
{/* Glowing Slider Divider Line (Direct GPU transform & position) */}
|
||||||
<div
|
<div
|
||||||
className="absolute top-0 bottom-0 w-[2px] bg-white shadow-[0_0_12px_rgba(255,255,255,1)] pointer-events-none z-10"
|
ref={dividerRef}
|
||||||
style={{ left: `${sliderPos}%` }}
|
className="absolute top-0 bottom-0 w-[2px] bg-white shadow-[0_0_12px_rgba(255,255,255,1)] pointer-events-none z-10 will-change-transform transform-gpu -translate-x-1/2"
|
||||||
|
style={{ left: '50%' }}
|
||||||
>
|
>
|
||||||
{/* Circular Grab Handle with Before/After Arrow Cue */}
|
{/* Circular Grab Handle with Before/After Arrow Cue */}
|
||||||
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-7 h-7 rounded-full bg-white shadow-lg border border-slate-200/90 flex items-center justify-center text-[10px] font-bold text-slate-900 pointer-events-none">
|
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-7 h-7 rounded-full bg-white shadow-lg border border-slate-200/90 flex items-center justify-center text-[10px] font-bold text-slate-900 pointer-events-none">
|
||||||
↔
|
↔
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Clean Badges Visible on Hover */}
|
{/* Badges with Smooth GPU Opacity Transition (No DOM mounting/unmounting) */}
|
||||||
{isHovered && (
|
<div
|
||||||
<div className="absolute bottom-3 inset-x-3 flex justify-between pointer-events-none z-20 text-[9px] font-mono font-bold uppercase tracking-wider text-white">
|
className={`absolute bottom-3 inset-x-3 flex justify-between pointer-events-none z-20 text-[9px] font-mono font-bold uppercase tracking-wider text-white transition-opacity duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||||
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
isHovered ? 'opacity-100' : 'opacity-0'
|
||||||
AFTER
|
}`}
|
||||||
</span>
|
>
|
||||||
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
||||||
BEFORE
|
AFTER
|
||||||
</span>
|
</span>
|
||||||
</div>
|
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
||||||
)}
|
BEFORE
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -350,10 +423,11 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
|||||||
<img
|
<img
|
||||||
src={item.imageUrl || item.afterUrl || item.beforeUrl || '/brand/og-default.png'}
|
src={item.imageUrl || item.afterUrl || item.beforeUrl || '/brand/og-default.png'}
|
||||||
alt={item.title}
|
alt={item.title}
|
||||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-0 bg-slate-950/10 group-hover:bg-transparent transition-colors duration-500" />
|
{/* GPU-composited overlay (opacity only) */}
|
||||||
|
<div className="absolute inset-0 bg-slate-950/10 opacity-100 group-hover:opacity-0 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ export function TrendyBentoSection({
|
|||||||
<button
|
<button
|
||||||
key={cat.id}
|
key={cat.id}
|
||||||
onClick={() => setActiveCategory(cat.id)}
|
onClick={() => setActiveCategory(cat.id)}
|
||||||
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-all duration-200 ${
|
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-[transform,background-color,color] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||||
isActive
|
isActive
|
||||||
? 'bg-slate-950 text-white shadow-md shadow-slate-900/15 scale-105'
|
? 'bg-slate-950 text-white shadow-md shadow-slate-900/15 scale-105'
|
||||||
: 'bg-white/90 text-slate-700 hover:bg-slate-100 border border-slate-200 shadow-sm'
|
: 'bg-white/90 text-slate-700 hover:bg-slate-100 border border-slate-200 shadow-sm'
|
||||||
@@ -259,18 +259,24 @@ export function TrendyBentoSection({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={tile.id}
|
key={tile.id}
|
||||||
className={`group relative flex flex-col justify-between overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm hover:shadow-cream-lg transition-all duration-300 hover:-translate-y-1.5 transform-gpu ${tileClasses}`}
|
className={`group relative flex flex-col justify-between overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm transition-[transform] duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] hover:-translate-y-1.5 transform-gpu will-change-transform ${tileClasses}`}
|
||||||
>
|
>
|
||||||
|
{/* GPU-composited shadow elevation layer */}
|
||||||
|
<div
|
||||||
|
className="absolute -inset-px rounded-[36px] sm:rounded-[42px] shadow-cream-lg opacity-0 group-hover:opacity-100 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none z-30"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Background Image (Covering the squarical tile) */}
|
{/* Background Image (Covering the squarical tile) */}
|
||||||
<img
|
<img
|
||||||
src={tile.imageUrl}
|
src={tile.imageUrl}
|
||||||
alt={tile.name}
|
alt={tile.name}
|
||||||
className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
className="absolute inset-0 w-full h-full object-cover transition-transform duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:scale-105 will-change-transform transform-gpu"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Vignette Overlay for Readability */}
|
{/* Vignette Overlay for Readability (GPU Opacity) */}
|
||||||
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/90 via-slate-950/30 to-slate-950/20 group-hover:via-slate-950/15 transition-all duration-300 pointer-events-none" />
|
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/90 via-slate-950/30 to-slate-950/20 opacity-100 group-hover:opacity-85 transition-opacity duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none" />
|
||||||
|
|
||||||
{/* Top Tile Bar: Badge and Quick-Settings Resize Button */}
|
{/* Top Tile Bar: Badge and Quick-Settings Resize Button */}
|
||||||
<div className="relative z-20 flex items-center justify-between p-5">
|
<div className="relative z-20 flex items-center justify-between p-5">
|
||||||
@@ -282,7 +288,7 @@ export function TrendyBentoSection({
|
|||||||
<button
|
<button
|
||||||
onClick={(e) => toggleTileSize(tile.id, e)}
|
onClick={(e) => toggleTileSize(tile.id, e)}
|
||||||
title={tile.isWide ? 'Shrink tile' : 'Expand tile'}
|
title={tile.isWide ? 'Shrink tile' : 'Expand tile'}
|
||||||
className="w-9 h-9 rounded-2xl bg-white/90 hover:bg-white text-slate-800 shadow-md flex items-center justify-center transition-all duration-200 hover:scale-110 active:scale-95"
|
className="w-9 h-9 rounded-2xl bg-white/90 hover:bg-white text-slate-800 shadow-md flex items-center justify-center transition-[transform,background-color] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-110 active:scale-95"
|
||||||
>
|
>
|
||||||
{tile.isWide ? (
|
{tile.isWide ? (
|
||||||
<Minimize2 className="w-4 h-4 text-blue-600" />
|
<Minimize2 className="w-4 h-4 text-blue-600" />
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
|||||||
}, [mobileMenuOpen]);
|
}, [mobileMenuOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="fixed top-0 left-0 right-0 w-full z-50 pointer-events-none transition-all duration-300">
|
<header className="fixed top-0 left-0 right-0 w-full z-50 pointer-events-none">
|
||||||
{/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Zero lag, locks at 60/120fps) */}
|
{/* 1. Ultra-Smooth High-Performance Gradient Blur Canopy (Zero lag, locks at 60/120fps) */}
|
||||||
<div className="absolute top-0 inset-x-0 h-28 sm:h-32 pointer-events-none overflow-hidden select-none">
|
<div className="absolute top-0 inset-x-0 h-28 sm:h-32 pointer-events-none overflow-hidden select-none">
|
||||||
{/* Single hardware-accelerated progressive blur */}
|
{/* Single hardware-accelerated progressive blur */}
|
||||||
@@ -57,7 +57,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
|||||||
<div className="absolute top-0 inset-x-0 h-[1px] bg-gradient-to-r from-transparent via-white/80 to-transparent pointer-events-none z-30" />
|
<div className="absolute top-0 inset-x-0 h-[1px] bg-gradient-to-r from-transparent via-white/80 to-transparent pointer-events-none z-30" />
|
||||||
|
|
||||||
{/* 3. Main Aligned Edge-to-Edge Navigation Bar */}
|
{/* 3. Main Aligned Edge-to-Edge Navigation Bar */}
|
||||||
<div className={`relative z-30 pointer-events-auto transition-all duration-300 ${isScrolled ? 'py-3' : 'py-3.5 sm:py-4'}`}>
|
<div className="relative z-30 pointer-events-auto py-3 sm:py-3.5">
|
||||||
<div className="max-w-[1640px] mx-auto px-4 sm:px-6 lg:px-10 flex items-center justify-between">
|
<div className="max-w-[1640px] mx-auto px-4 sm:px-6 lg:px-10 flex items-center justify-between">
|
||||||
{/* Brand Logo */}
|
{/* Brand Logo */}
|
||||||
<div className="relative z-20 flex-shrink-0">
|
<div className="relative z-20 flex-shrink-0">
|
||||||
@@ -70,7 +70,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
|||||||
<Link
|
<Link
|
||||||
href="/"
|
href="/"
|
||||||
aria-current={pathname === '/' ? 'page' : undefined}
|
aria-current={pathname === '/' ? 'page' : undefined}
|
||||||
className={`relative flex items-center gap-1.5 px-4 py-2 rounded-full text-xs font-bold tracking-wide transition-all duration-200 ${
|
className={`relative flex items-center gap-1.5 px-4 py-2 rounded-full text-xs font-bold tracking-wide transition-[background-color,color,box-shadow] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||||
pathname === '/'
|
pathname === '/'
|
||||||
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]'
|
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]'
|
||||||
: 'text-slate-800 hover:text-slate-950 hover:bg-white/60'
|
: 'text-slate-800 hover:text-slate-950 hover:bg-white/60'
|
||||||
@@ -87,7 +87,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
|||||||
key={item.href}
|
key={item.href}
|
||||||
href={item.href}
|
href={item.href}
|
||||||
aria-current={active ? 'page' : undefined}
|
aria-current={active ? 'page' : undefined}
|
||||||
className={`relative px-4 py-2 rounded-full text-xs font-bold tracking-wide transition-all duration-200 ${
|
className={`relative px-4 py-2 rounded-full text-xs font-bold tracking-wide transition-[background-color,color,box-shadow] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||||
active
|
active
|
||||||
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]'
|
? 'text-blue-700 bg-white shadow-sm border border-slate-900/[0.06]'
|
||||||
: 'text-slate-800 hover:text-slate-950 hover:bg-white/60'
|
: 'text-slate-800 hover:text-slate-950 hover:bg-white/60'
|
||||||
@@ -112,7 +112,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
|||||||
<div className="hidden md:flex items-center space-x-3 relative z-20 flex-shrink-0">
|
<div className="hidden md:flex items-center space-x-3 relative z-20 flex-shrink-0">
|
||||||
<Link
|
<Link
|
||||||
href={config.nav.cta.href}
|
href={config.nav.cta.href}
|
||||||
className="group relative inline-flex items-center gap-1.5 lg:gap-2 px-3.5 py-2 lg:px-5 lg:py-2.5 rounded-full text-xs font-bold text-white bg-gradient-to-r from-blue-600 via-indigo-600 to-blue-600 hover:from-blue-700 hover:to-indigo-700 shadow-md shadow-blue-500/25 hover:shadow-lg hover:shadow-blue-500/35 transition-all duration-300 hover:scale-105 active:scale-95"
|
className="group relative inline-flex items-center gap-1.5 lg:gap-2 px-3.5 py-2 lg:px-5 lg:py-2.5 rounded-full text-xs font-bold text-white bg-gradient-to-r from-blue-600 via-indigo-600 to-blue-600 hover:from-blue-700 hover:to-indigo-700 shadow-md shadow-blue-500/25 hover:shadow-lg hover:shadow-blue-500/35 transition-[transform,opacity,box-shadow] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 active:scale-95"
|
||||||
>
|
>
|
||||||
<Smartphone className="w-3.5 h-3.5 lg:w-4 lg:h-4 text-white group-hover:rotate-6 transition-transform" />
|
<Smartphone className="w-3.5 h-3.5 lg:w-4 lg:h-4 text-white group-hover:rotate-6 transition-transform" />
|
||||||
<span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span>
|
<span>{resolveLocalised(config.nav.cta.label, currentLocale)}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user