fix(ui): restore tool links and reduce animation overhead

This commit is contained in:
2026-11-03 18:34:29 +05:30
parent f9c98a87b4
commit 34daaf57af
9 changed files with 28 additions and 81 deletions
+5 -1
View File
@@ -202,14 +202,18 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
observer.observe(container);
const clock = new THREE.Clock();
let lastFrameTime = 0;
const frameInterval = prefersReducedMotion ? 1000 : 1000 / 30;
const animate = () => {
const animate = (time = 0) => {
if (!isVisible || !renderer) {
animFrameId = 0;
return;
}
animFrameId = requestAnimationFrame(animate);
if (time - lastFrameTime < frameInterval) return;
lastFrameTime = time;
const elapsedTime = clock.getElapsedTime();
+1 -2
View File
@@ -55,8 +55,7 @@ export function HeroSection({
</div>
<Kinetic3DText
primaryText="Make every photo"
highlightText="feel finished."
primaryText={resolvedTitle}
subtitle={resolvedSubtitle}
className="mt-7 text-left [&_h1]:text-left [&_h1]:text-[2.7rem] sm:[&_h1]:text-6xl lg:[&_h1]:text-[4.25rem] [&_h1]:leading-[1.02] [&_p]:mx-0 [&_p]:mt-5 [&_p]:max-w-lg [&_p]:text-base [&_p]:sm:text-lg"
/>
@@ -99,6 +99,7 @@ function SectionContent({ section, context }: SectionRendererProps) {
context={{
tools: context.tools || [],
categories: context.categories || [],
apps: context.apps || [],
locale,
}}
/>
-1
View File
@@ -235,7 +235,6 @@ export function TryItWidget({
ref={fileInputRef}
type="file"
accept="image/jpeg,image/png,image/webp"
accept="image/jpeg,image/png,image/webp"
className="hidden"
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
/>
@@ -15,7 +15,7 @@ import {
Cpu,
Smartphone,
} from 'lucide-react';
import { resolveLocalised, ToolItem, CategoryItem } from '@/types';
import { resolveLocalised, ToolItem, CategoryItem, AppItem } from '@/types';
import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider';
import { SpotlightCard } from '@/components/animate-ui/SpotlightCard';
import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge';
@@ -26,6 +26,7 @@ export interface VerticalToolStackProps {
context: {
tools: ToolItem[];
categories: CategoryItem[];
apps: AppItem[];
locale: string;
};
}
@@ -70,7 +71,7 @@ const ACCENT_STYLES: Record<string, { badge: string; text: string }> = {
};
export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
const { tools, categories, locale } = context;
const { tools, categories, apps, locale } = context;
const [selectedCategory, setSelectedCategory] = useState<string>('all');
const filteredCategories = selectedCategory === 'all'
@@ -185,6 +186,7 @@ export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
{/* Dynamic Multi-Format Tool Cards with Alternating Layouts */}
<div className="space-y-10 sm:space-y-12">
{catTools.map((tool, toolIdx) => {
const homeApp = apps.find((app) => app.id === tool.homeApp);
const badgeInfo = MODEL_BADGES[tool.id] || {
model: 'Neural Vision v2.0',
latency: '< 450ms',
@@ -339,7 +341,7 @@ export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
</Link>
<Link
href={`/apps/${tool.homeApp}`}
href={homeApp ? `/apps/${homeApp.slug}` : '/apps'}
className="inline-flex items-center gap-1.5 px-5 py-3 rounded-full text-xs font-bold text-slate-700 bg-slate-100 border border-slate-200 hover:bg-slate-200 transition-colors"
>
<Smartphone className="w-3.5 h-3.5 text-blue-600" />
+10 -16
View File
@@ -1,6 +1,6 @@
'use client';
import React, { useRef, useState, useCallback } from 'react';
import React, { useRef, useCallback } from 'react';
interface Kinetic3DTextProps {
primaryText: string;
@@ -15,23 +15,22 @@ export function Kinetic3DText({
subtitle,
className = '',
}: Kinetic3DTextProps) {
const [tilt, setTilt] = useState({ rx: 0, ry: 0, active: false });
const containerRef = useRef<HTMLDivElement>(null);
const textRef = useRef<HTMLDivElement>(null);
const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
if (!containerRef.current) return;
const rect = containerRef.current.getBoundingClientRect();
const nx = (e.clientX - rect.left) / rect.width - 0.5;
const ny = (e.clientY - rect.top) / rect.height - 0.5;
setTilt({
rx: Math.max(Math.min(-ny * 10, 8), -8),
ry: Math.max(Math.min(nx * 12, 10), -10),
active: true,
});
if (!textRef.current || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const rx = Math.max(Math.min(-ny * 3, 2.5), -2.5);
const ry = Math.max(Math.min(nx * 4, 3), -3);
textRef.current.style.transform = `perspective(1000px) rotateX(${rx}deg) rotateY(${ry}deg)`;
}, []);
const handleMouseLeave = useCallback(() => {
setTilt({ rx: 0, ry: 0, active: false });
if (textRef.current) textRef.current.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg)';
}, []);
return (
@@ -40,16 +39,11 @@ export function Kinetic3DText({
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
className={`relative select-none ${className}`}
style={{ perspective: 1000 }}
>
<div
className="transition-transform duration-200 ease-out"
style={{
transform: tilt.active
? `rotateX(${tilt.rx.toFixed(2)}deg) rotateY(${tilt.ry.toFixed(2)}deg)`
: 'rotateX(0deg) rotateY(0deg)',
transformStyle: 'preserve-3d',
}}
ref={textRef}
className="transition-transform duration-300 ease-out will-change-transform"
style={{ transform: 'perspective(1000px) rotateX(0deg) rotateY(0deg)', transformStyle: 'preserve-3d' }}
>
{/* Main Floating Headline (100% Visible, Crisp, Zero Disappearance) */}
<h1 className="text-4xl sm:text-5xl lg:text-6xl xl:text-7xl font-display font-black text-slate-900 tracking-tight leading-[1.08] relative z-10">
+4 -4
View File
@@ -9,10 +9,10 @@ export function SectionEntrance({ children, id }: { children: React.ReactNode; i
return (
<motion.div
data-section-entrance={id}
initial={reduceMotion ? false : { opacity: 0, y: 22, filter: 'blur(5px)' }}
whileInView={{ opacity: 1, y: 0, filter: 'blur(0px)' }}
viewport={{ once: true, amount: 0.12, margin: '0px 0px -48px 0px' }}
transition={{ duration: 0.65, ease: [0.22, 1, 0.36, 1] }}
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] }}
>
{children}
</motion.div>
+1 -53
View File
@@ -1,58 +1,6 @@
'use client';
import { useEffect } from 'react';
import Lenis from 'lenis';
/** Keep native browser scrolling: it is interruptible, accessible, and avoids a permanent RAF loop. */
export function SmoothScroll() {
useEffect(() => {
// Check prefers-reduced-motion
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const lenis = new Lenis({
duration: 0.75, // Extra smooth, luxurious gliding friction
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
orientation: 'vertical',
gestureOrientation: 'vertical',
smoothWheel: true,
syncTouch: false,
wheelMultiplier: 1.05,
touchMultiplier: 1.0,
});
let rafId: number;
function raf(time: number) {
lenis.raf(time);
rafId = requestAnimationFrame(raf);
}
rafId = requestAnimationFrame(raf);
// Smooth scroll for anchor clicks (e.g. #studio-suite, #flagship-models)
const handleAnchorClick = (e: MouseEvent) => {
const target = e.target as HTMLElement;
const anchor = target.closest('a');
if (!anchor) return;
const href = anchor.getAttribute('href');
if (href && href.startsWith('#') && href.length > 1) {
const targetEl = document.querySelector(href);
if (targetEl) {
e.preventDefault();
lenis.scrollTo(targetEl as HTMLElement, { offset: -90, duration: 0.75 });
}
}
};
document.addEventListener('click', handleAnchorClick);
// Expose lenis to window for external triggers
(window as any).lenis = lenis;
return () => {
cancelAnimationFrame(rafId);
document.removeEventListener('click', handleAnchorClick);
lenis.destroy();
delete (window as any).lenis;
};
}, []);
return null;
}