feat(ui): add Three.js 3D neural prism, 3D tilt cards, cursor aura, and flagship banners
This commit is contained in:
+2
-48
@@ -48,8 +48,8 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "use-cases",
|
||||
"type": "visualUseCases",
|
||||
"id": "flagship-banners",
|
||||
"type": "majorToolBanners",
|
||||
"props": {}
|
||||
},
|
||||
{
|
||||
@@ -62,57 +62,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "featured-tools",
|
||||
"type": "toolGrid",
|
||||
"props": {
|
||||
"title": {
|
||||
"en": "Explore Full Suite of AI Photo Tools",
|
||||
"hi": "एआई फोटो टूल्स के पूरे सूट का अन्वेषण करें"
|
||||
},
|
||||
"subtitle": {
|
||||
"en": "Select any tool below to launch an instant trial in your browser with zero watermark restrictions.",
|
||||
"hi": "बिना वॉटरमार्क के तुरंत आज़माने के लिए नीचे से कोई भी टूल चुनें।"
|
||||
},
|
||||
"source": "all",
|
||||
"showCategoryFilter": true,
|
||||
"showSearch": true,
|
||||
"columns": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "workflow-pipeline",
|
||||
"type": "workflowVisualizer",
|
||||
"props": {}
|
||||
},
|
||||
{
|
||||
"id": "showcase-before-after",
|
||||
"type": "beforeAfter",
|
||||
"props": {
|
||||
"title": {
|
||||
"en": "Precision Side-by-Side Comparisons",
|
||||
"hi": "सटीक पहले और बाद की तुलना"
|
||||
},
|
||||
"subtitle": {
|
||||
"en": "Drag the split slider to verify sub-millimeter pore textures and clean edge alpha matting.",
|
||||
"hi": "सटीक बनावट और स्पष्ट किनारों की जांच के लिए स्लाइडर को खींचें।"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"before": "https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80",
|
||||
"after": "https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80",
|
||||
"alt": "Portrait Blemish Removal",
|
||||
"caption": "Sub-pore facial blemish removal preserving real skin pore texture"
|
||||
},
|
||||
{
|
||||
"before": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=800&auto=format&fit=crop&q=80",
|
||||
"after": "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=80",
|
||||
"alt": "P3M AI Matting",
|
||||
"caption": "Precision alpha matting with individual hair strand detection"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "apps-section",
|
||||
"type": "appCards",
|
||||
|
||||
@@ -23,16 +23,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "tools-vertical-stack",
|
||||
"type": "verticalToolStack",
|
||||
"props": {
|
||||
"title": {
|
||||
"en": "The Creative Studio Suite",
|
||||
"hi": "क्रिएटिव स्टूडियो सूट"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "all-tools-grid",
|
||||
"type": "toolGrid",
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# 3D Motion Graphics & Neural Prism Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Elevate the CRE Innovations front page with interactive Three.js 3D motion graphics, perspective card tilt, specular reflections, and kinetic telemetry inspired by Squared Media (squared-media.nl), while ensuring zero SEO degradation and ultra-fast 60fps performance.
|
||||
|
||||
**Architecture:**
|
||||
- A lightweight, lazy-loaded Three.js WebGL canvas (`Hero3DCanvas`) rendering a 3D neural crystal prism and particle constellation with inertial mouse tracking, paused via `IntersectionObserver` when offscreen.
|
||||
- A high-performance 3D perspective tilt component (`TiltCard`) with dynamic specular glare overlay.
|
||||
- An ambient desktop cursor aura follower (`CursorAura`) delivering agency-grade polish.
|
||||
- Full preservation of semantic HTML, Schema.org JSON-LD, and zero impact on Core Web Vitals or mobile responsiveness.
|
||||
|
||||
**Tech Stack:** Next.js 14 (App Router), React 18, Three.js (`three` + `@types/three`), Tailwind CSS, Lucide React.
|
||||
|
||||
---
|
||||
|
||||
## Global Constraints
|
||||
- Brand name: strictly **CRE Innovations**.
|
||||
- Palette: Light creamy off-white (`#FAF8F5` / `#F5F2EB`) with slate-900 typography and electric neural blue/indigo accents.
|
||||
- Zero SEO degradation: All H1/H2/H3/p tags, Schema.org structured data, and meta tags must remain intact; 3D canvas is `aria-hidden="true"` and non-blocking.
|
||||
- Ultra-fast & lightweight: Canvas uses DPR clamp <= 2, pauses RAF when out of viewport, and disposes WebGL resources on unmount.
|
||||
- Python commands: Use `/home/creserver/extras/local_venv/bin/python` per user global rule.
|
||||
|
||||
---
|
||||
|
||||
## Task Decomposition
|
||||
|
||||
### Task 1: Create `Hero3DCanvas.tsx`
|
||||
- File: `src/components/3d/Hero3DCanvas.tsx`
|
||||
- Build Three.js 3D neural crystal (icosahedron wireframe + inner glowing sphere + 60 floating neural particles).
|
||||
- Implement smooth lerp mouse tracking `(targetX, targetY)`.
|
||||
- Implement `IntersectionObserver` to halt RAF loop when canvas is not visible.
|
||||
- Add full WebGL resource disposal on unmount.
|
||||
|
||||
### Task 2: Create `TiltCard.tsx` and `CursorAura.tsx`
|
||||
- File: `src/components/ui/TiltCard.tsx`
|
||||
- Mouse move perspective tilt (`perspective(1000px) rotateX(...) rotateY(...) scale3d(1.01, 1.01, 1.01)`).
|
||||
- Dynamic radial specular highlight layer.
|
||||
- Smooth spring reset on mouse leave.
|
||||
- Respects `prefers-reduced-motion` and touch devices.
|
||||
- File: `src/components/ui/CursorAura.tsx`
|
||||
- Desktop-only ambient radial glow follower (`@media(hover:hover)`).
|
||||
- RAF lerp smoothing.
|
||||
|
||||
### Task 3: Integrate 3D Motion Graphics into `HeroSection.tsx`
|
||||
- File: `src/components/sections/HeroSection.tsx`
|
||||
- Dynamically import `Hero3DCanvas` with `{ ssr: false }`.
|
||||
- Position the 3D canvas behind/beside the hero headline with subtle atmospheric glow.
|
||||
- Add kinetic floating telemetry chips (`⚡ CRE Neural Core v2.4`, `In-Memory ~340ms`, `Zero Disk Storage Active`) with staggered orbital float.
|
||||
- Wrap TryItWidget in `TiltCard`.
|
||||
|
||||
### Task 4: Enhance Flagship Banners and Studio Suite with 3D Tilt
|
||||
- Files:
|
||||
- `src/components/sections/MajorToolBannersSection.tsx`
|
||||
- `src/components/sections/VerticalToolStackSection.tsx`
|
||||
- Wrap flagship cards and studio suite cards in `TiltCard` with subtle specular gleam.
|
||||
|
||||
### Task 5: Global Layout Integration & Styling
|
||||
- File: `src/app/layout.tsx`
|
||||
- Mount `CursorAura` at body level.
|
||||
- Add CSS animations for floating telemetry badges in `src/app/globals.css`.
|
||||
|
||||
### Task 6: Production Build, Server Restart & Automated Verification
|
||||
- Run `npm run build` to verify clean compilation without TypeScript or SSR errors.
|
||||
- Restart production server daemon task (`npm run start`).
|
||||
- Run Python audit script to verify all 9 routes return 200 OK, 1 H1, 0 missing alt tags.
|
||||
- Test in Puppeteer: evaluate WebGL canvas rendering, 60fps loop, and card tilt.
|
||||
- Commit all changes with descriptive commit message.
|
||||
@@ -0,0 +1,82 @@
|
||||
# Major Tool Banners & Animated Comparisons Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Eliminate redundant content across pages, implement smooth auto-sliding before/after comparison animations, and create a flagship Major Tool Banners section showcasing flagship AI models in alternating editorial layouts.
|
||||
|
||||
**Architecture:** Next.js 14 App Router, dynamic JSON configs, Canvas/RAF-driven smooth slider oscillation in `BeforeAfterSlider.tsx`, new `MajorToolBannersSection.tsx` registered in `SectionRenderer.tsx`.
|
||||
|
||||
**Tech Stack:** Next.js 14, React 18, TypeScript, Tailwind CSS, Lucide React.
|
||||
|
||||
---
|
||||
|
||||
## Global Constraints
|
||||
- Brand name: strictly **CRE Innovations**.
|
||||
- Color palette: maintain warm, light creamy off-white studio aesthetic (`#FAF8F5` / `#F5F2EB`).
|
||||
- Non-redundancy: eliminate duplicate tool grids and duplicate comparison sliders across pages.
|
||||
- Auto-sliding animation: smooth sine-wave oscillation that pauses instantly on user touch/mouse interaction.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Auto-Sliding Before/After Animation in `BeforeAfterSlider.tsx`
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/components/ui/BeforeAfterSlider.tsx`
|
||||
|
||||
- [ ] **Step 1: Implement RAF-based Auto-Slide Oscillation**
|
||||
- Add `autoSlide?: boolean` (defaults to `true`).
|
||||
- Use `requestAnimationFrame` with a smooth sine function (`50 + 28 * Math.sin(timestamp * 0.0015)`) to oscillate between ~22% and ~78%.
|
||||
- On mouse enter / touch start: pause animation immediately and allow manual dragging.
|
||||
- On mouse leave: resume after a short grace period.
|
||||
- Add mode indicator pill ("Auto-Scanning" / "Manual Inspect").
|
||||
|
||||
- [ ] **Step 2: Verify component in build**
|
||||
- Run `npm run build` to confirm no compilation issues.
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Create Flagship `MajorToolBannersSection.tsx`
|
||||
|
||||
**Files:**
|
||||
- Create: `src/components/sections/MajorToolBannersSection.tsx`
|
||||
- Modify: `src/components/sections/SectionRenderer.tsx`
|
||||
|
||||
- [ ] **Step 1: Build `MajorToolBannersSection.tsx`**
|
||||
- Spotlight 3 flagship tools:
|
||||
1. *P3M-Net Ultra Cutout Studio* (Hair-strand isolation & alpha PNG)
|
||||
2. *RetouchGAN v2.1 Skin Precision* (Pore-preserving acne & blemish removal)
|
||||
3. *GFPGAN + RealESRGAN 4K Enhancer* (Super-resolution & vintage deblurring)
|
||||
- Alternating layout (Left-Right, Right-Left, Left-Right) for rhythm and aesthetic symmetry.
|
||||
- Large-format auto-sliding before/after animation frames.
|
||||
- 1-click "Launch Tool Online" and "Get Mobile App" CTAs.
|
||||
|
||||
- [ ] **Step 2: Register in `SectionRenderer.tsx`**
|
||||
- Add `case 'majorToolBanners': return <MajorToolBannersSection />`.
|
||||
|
||||
---
|
||||
|
||||
### Task 3: De-duplicate Page Content across JSON Configs
|
||||
|
||||
**Files:**
|
||||
- Modify: `content/pages/home.json`
|
||||
- Modify: `content/pages/tools.json`
|
||||
|
||||
- [ ] **Step 1: Clean Up `home.json`**
|
||||
- Add `majorToolBanners` section after `stats-section`.
|
||||
- Remove duplicate `featured-tools` (`toolGrid`) from homepage (now uniquely represented by The Creative Suite and Flagship Banners).
|
||||
- Remove duplicate `showcase-before-after` (redundant with the animated banners).
|
||||
|
||||
- [ ] **Step 2: Clean Up `tools.json`**
|
||||
- Remove `tools-vertical-stack` from `tools.json` so `/tools` is purely the dedicated search and filter directory (`toolGrid`), giving each page a distinct role.
|
||||
|
||||
---
|
||||
|
||||
### Task 4: Comprehensive Verification & Audit
|
||||
|
||||
**Files:**
|
||||
- Audit homepage and all subpages
|
||||
- Verify clean build, zero TypeScript errors, valid SEO & schemas
|
||||
|
||||
- [ ] **Step 1: Run `npm run build`**
|
||||
- [ ] **Step 2: Restart Server & Test Routes**
|
||||
- [ ] **Step 3: Commit and Final Status**
|
||||
Generated
+58
@@ -8,6 +8,7 @@
|
||||
"name": "photo-tools-web",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@types/three": "^0.187.0",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.468.0",
|
||||
"next": "^14.2.15",
|
||||
@@ -15,6 +16,7 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"tailwind-merge": "^2.5.4",
|
||||
"three": "^0.187.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -42,6 +44,12 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@dimforge/rapier3d-compat": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz",
|
||||
"integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.21.5",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
|
||||
@@ -1111,6 +1119,12 @@
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tweenjs/tween.js": {
|
||||
"version": "23.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz",
|
||||
"integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz",
|
||||
@@ -1166,6 +1180,32 @@
|
||||
"@types/react": "^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/stats.js": {
|
||||
"version": "0.17.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz",
|
||||
"integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/three": {
|
||||
"version": "0.187.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/three/-/three-0.187.0.tgz",
|
||||
"integrity": "sha512-v+vKNarUtk4n2QRZ4+CN5ygMM0ARUjXjIQl0R/unMUfmStFeVqGbgqarbrpoGTXRZoulSH16ePrVJVxPJEbMUA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@dimforge/rapier3d-compat": "~0.12.0",
|
||||
"@tweenjs/tween.js": "~23.1.3",
|
||||
"@types/stats.js": "*",
|
||||
"@types/webxr": ">=0.5.17",
|
||||
"fflate": "~0.8.3",
|
||||
"meshoptimizer": "~1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/webxr": {
|
||||
"version": "0.5.24",
|
||||
"resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz",
|
||||
"integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@vitest/expect": {
|
||||
"version": "2.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz",
|
||||
@@ -1846,6 +1886,12 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz",
|
||||
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
||||
@@ -2119,6 +2165,12 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/meshoptimizer": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz",
|
||||
"integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
@@ -2969,6 +3021,12 @@
|
||||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/three": {
|
||||
"version": "0.187.0",
|
||||
"resolved": "https://registry.npmjs.org/three/-/three-0.187.0.tgz",
|
||||
"integrity": "sha512-Qiu7R+Cmh8CstZsY1uJOSWnVlfo7ZtNLV7mF8Jltk3LB3AtDu9cRZlcnRKkAk8Y4z6KKw35z7Y7Urd7jWY8etA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinybench": {
|
||||
"version": "2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/three": "^0.187.0",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.468.0",
|
||||
"next": "^14.2.15",
|
||||
@@ -16,6 +17,7 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"tailwind-merge": "^2.5.4",
|
||||
"three": "^0.187.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -102,3 +102,31 @@
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #C8C2B5;
|
||||
}
|
||||
|
||||
/* 3D Motion Keyframes & Floating Helpers */
|
||||
@keyframes float-slow {
|
||||
0%, 100% {
|
||||
transform: translateY(0px) rotate(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-8px) rotate(1.2deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float-medium {
|
||||
0%, 100% {
|
||||
transform: translateY(0px) rotate(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-12px) rotate(-1.5deg);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-float-slow {
|
||||
animation: float-slow 6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.animate-float-medium {
|
||||
animation: float-medium 7.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -4,6 +4,7 @@ import './globals.css';
|
||||
import { getSiteConfig } from '@/lib/config/loader';
|
||||
import { Navbar } from '@/components/ui/Navbar';
|
||||
import { Footer } from '@/components/ui/Footer';
|
||||
import { CursorAura } from '@/components/ui/CursorAura';
|
||||
|
||||
const sansFont = Plus_Jakarta_Sans({
|
||||
subsets: ['latin'],
|
||||
@@ -87,7 +88,8 @@ export default function RootLayout({
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationJsonLd) }}
|
||||
/>
|
||||
</head>
|
||||
<body className="min-h-screen flex flex-col antialiased selection:bg-blue-600 selection:text-white bg-[#FAF8F5] text-slate-900">
|
||||
<body className="min-h-screen flex flex-col antialiased selection:bg-blue-600 selection:text-white bg-[#FAF8F5] text-slate-900 relative">
|
||||
<CursorAura />
|
||||
<Navbar config={config} currentLocale="en" />
|
||||
<main className="flex-1">{children}</main>
|
||||
<Footer config={config} currentLocale="en" />
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import * as THREE from 'three';
|
||||
|
||||
interface Hero3DCanvasProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (!container) return;
|
||||
|
||||
// Check prefers-reduced-motion
|
||||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
// Dimensions
|
||||
let width = container.clientWidth || 400;
|
||||
let height = container.clientHeight || 400;
|
||||
|
||||
// Scene, Camera, Renderer
|
||||
const scene = new THREE.Scene();
|
||||
const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
|
||||
camera.position.z = 7;
|
||||
|
||||
const renderer = new THREE.WebGLRenderer({
|
||||
alpha: true,
|
||||
antialias: true,
|
||||
powerPreference: 'high-performance',
|
||||
});
|
||||
renderer.setSize(width, height);
|
||||
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
||||
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
||||
container.appendChild(renderer.domElement);
|
||||
|
||||
// Root Group for Mouse Parallax
|
||||
const rootGroup = new THREE.Group();
|
||||
scene.add(rootGroup);
|
||||
|
||||
// 1. Outer Geodesic Wireframe Prism (Icosahedron)
|
||||
const icoGeo = new THREE.IcosahedronGeometry(2.1, 1);
|
||||
const wireframeGeo = new THREE.WireframeGeometry(icoGeo);
|
||||
const wireframeMat = new THREE.LineBasicMaterial({
|
||||
color: 0x3b82f6, // Electric Blue
|
||||
transparent: true,
|
||||
opacity: 0.5,
|
||||
blending: THREE.AdditiveBlending,
|
||||
});
|
||||
const wireframeMesh = new THREE.LineSegments(wireframeGeo, wireframeMat);
|
||||
rootGroup.add(wireframeMesh);
|
||||
|
||||
// Outer Node Dots on Vertices
|
||||
const vertexPositions = icoGeo.attributes.position;
|
||||
const vertexCount = vertexPositions.count;
|
||||
const dotGeo = new THREE.BufferGeometry();
|
||||
dotGeo.setAttribute('position', vertexPositions);
|
||||
const dotMat = new THREE.PointsMaterial({
|
||||
color: 0x60a5fa,
|
||||
size: 0.12,
|
||||
transparent: true,
|
||||
opacity: 0.85,
|
||||
blending: THREE.AdditiveBlending,
|
||||
});
|
||||
const vertexPoints = new THREE.Points(dotGeo, dotMat);
|
||||
rootGroup.add(vertexPoints);
|
||||
|
||||
// 2. Inner Glowing Core Sphere
|
||||
const innerGeo = new THREE.SphereGeometry(1.0, 32, 32);
|
||||
const innerMat = new THREE.MeshStandardMaterial({
|
||||
color: 0x4f46e5, // Indigo
|
||||
roughness: 0.15,
|
||||
metalness: 0.85,
|
||||
emissive: 0x1e40af, // Deep Blue glow
|
||||
emissiveIntensity: 0.6,
|
||||
transparent: true,
|
||||
opacity: 0.9,
|
||||
});
|
||||
const innerMesh = new THREE.Mesh(innerGeo, innerMat);
|
||||
rootGroup.add(innerMesh);
|
||||
|
||||
// 3. Orbiting Neural Tensor Particles (60 Particles)
|
||||
const particleCount = prefersReducedMotion ? 20 : 60;
|
||||
const particlePositions = new Float32Array(particleCount * 3);
|
||||
const particleScales = new Float32Array(particleCount);
|
||||
|
||||
for (let i = 0; i < particleCount; i++) {
|
||||
const radius = 2.6 + Math.random() * 1.6;
|
||||
const theta = Math.random() * Math.PI * 2;
|
||||
const phi = Math.acos(2 * Math.random() - 1);
|
||||
|
||||
particlePositions[i * 3] = radius * Math.sin(phi) * Math.cos(theta);
|
||||
particlePositions[i * 3 + 1] = radius * Math.sin(phi) * Math.sin(theta);
|
||||
particlePositions[i * 3 + 2] = radius * Math.cos(phi);
|
||||
particleScales[i] = Math.random() * 0.08 + 0.04;
|
||||
}
|
||||
|
||||
const particlesGeo = new THREE.BufferGeometry();
|
||||
particlesGeo.setAttribute('position', new THREE.BufferAttribute(particlePositions, 3));
|
||||
const particlesMat = new THREE.PointsMaterial({
|
||||
color: 0x818cf8, // Lavender Indigo
|
||||
size: 0.1,
|
||||
transparent: true,
|
||||
opacity: 0.75,
|
||||
blending: THREE.AdditiveBlending,
|
||||
});
|
||||
const particlesMesh = new THREE.Points(particlesGeo, particlesMat);
|
||||
rootGroup.add(particlesMesh);
|
||||
|
||||
// Lighting
|
||||
const ambientLight = new THREE.AmbientLight(0xffffff, 0.8);
|
||||
scene.add(ambientLight);
|
||||
|
||||
const blueLight = new THREE.PointLight(0x3b82f6, 3, 12);
|
||||
blueLight.position.set(4, 3, 4);
|
||||
scene.add(blueLight);
|
||||
|
||||
const purpleLight = new THREE.PointLight(0xa855f7, 2.5, 12);
|
||||
purpleLight.position.set(-4, -3, 3);
|
||||
scene.add(purpleLight);
|
||||
|
||||
// Mouse Tracking with Smooth Damping
|
||||
let mouseX = 0;
|
||||
let mouseY = 0;
|
||||
let targetRotX = 0;
|
||||
let targetRotY = 0;
|
||||
|
||||
const handleMouseMove = (e: MouseEvent) => {
|
||||
const rect = container.getBoundingClientRect();
|
||||
const centerX = rect.left + rect.width / 2;
|
||||
const centerY = rect.top + rect.height / 2;
|
||||
|
||||
// Distance from center of container normalized
|
||||
mouseX = (e.clientX - centerX) / (window.innerWidth * 0.5);
|
||||
mouseY = (e.clientY - centerY) / (window.innerHeight * 0.5);
|
||||
|
||||
targetRotY = mouseX * 0.65;
|
||||
targetRotX = mouseY * 0.45;
|
||||
};
|
||||
|
||||
window.addEventListener('mousemove', handleMouseMove, { passive: true });
|
||||
|
||||
// Handle Resize
|
||||
const handleResize = () => {
|
||||
if (!container) return;
|
||||
width = container.clientWidth || 400;
|
||||
height = container.clientHeight || 400;
|
||||
camera.aspect = width / height;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize(width, height);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
// IntersectionObserver to halt loop when not visible (Zero waste when scrolled away)
|
||||
let isVisible = true;
|
||||
let animFrameId: number;
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
const [entry] = entries;
|
||||
isVisible = entry.isIntersecting;
|
||||
if (isVisible && !animFrameId) {
|
||||
animate();
|
||||
}
|
||||
},
|
||||
{ threshold: 0.05 }
|
||||
);
|
||||
observer.observe(container);
|
||||
|
||||
// Animation Loop
|
||||
let clock = new THREE.Clock();
|
||||
|
||||
const animate = () => {
|
||||
if (!isVisible) {
|
||||
animFrameId = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
animFrameId = requestAnimationFrame(animate);
|
||||
|
||||
const elapsedTime = clock.getElapsedTime();
|
||||
|
||||
// Smooth Inertial Lerp to Target Rotation
|
||||
rootGroup.rotation.y += (targetRotY - rootGroup.rotation.y) * 0.04;
|
||||
rootGroup.rotation.x += (targetRotX - rootGroup.rotation.x) * 0.04;
|
||||
|
||||
if (!prefersReducedMotion) {
|
||||
// Continuous Gentle Oscillation & Spin
|
||||
wireframeMesh.rotation.y += 0.0035;
|
||||
wireframeMesh.rotation.z += 0.0015;
|
||||
vertexPoints.rotation.y += 0.0035;
|
||||
vertexPoints.rotation.z += 0.0015;
|
||||
|
||||
// Inner core breathing scale
|
||||
const breath = 1.0 + Math.sin(elapsedTime * 1.8) * 0.05;
|
||||
innerMesh.scale.set(breath, breath, breath);
|
||||
|
||||
// Counter-orbit particles
|
||||
particlesMesh.rotation.y -= 0.002;
|
||||
particlesMesh.rotation.x += 0.001;
|
||||
}
|
||||
|
||||
renderer.render(scene, camera);
|
||||
};
|
||||
|
||||
animate();
|
||||
|
||||
// Clean up
|
||||
return () => {
|
||||
if (animFrameId) cancelAnimationFrame(animFrameId);
|
||||
window.removeEventListener('mousemove', handleMouseMove);
|
||||
window.removeEventListener('resize', handleResize);
|
||||
observer.disconnect();
|
||||
|
||||
// Dispose Geometries and Materials
|
||||
icoGeo.dispose();
|
||||
wireframeGeo.dispose();
|
||||
wireframeMat.dispose();
|
||||
dotGeo.dispose();
|
||||
dotMat.dispose();
|
||||
innerGeo.dispose();
|
||||
innerMat.dispose();
|
||||
particlesGeo.dispose();
|
||||
particlesMat.dispose();
|
||||
renderer.dispose();
|
||||
|
||||
if (renderer.domElement && renderer.domElement.parentNode) {
|
||||
renderer.domElement.parentNode.removeChild(renderer.domElement);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className={`relative w-full h-full pointer-events-none select-none ${className}`}
|
||||
aria-hidden="true"
|
||||
role="presentation"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,18 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { Sparkles, ArrowRight, Smartphone, ShieldCheck, Zap, Layers, Cpu } from 'lucide-react';
|
||||
import { resolveLocalised, ToolItem, AppItem, VariantSpec } from '@/types';
|
||||
import { TryItWidget } from './TryItWidget';
|
||||
import { TiltCard } from '@/components/ui/TiltCard';
|
||||
|
||||
// Lazy-load Three.js 3D canvas with ssr: false for ultra-fast initial load & SEO safety
|
||||
const Hero3DCanvas = dynamic(
|
||||
() => import('@/components/3d/Hero3DCanvas').then((mod) => mod.Hero3DCanvas),
|
||||
{ ssr: false }
|
||||
);
|
||||
|
||||
interface HeroSectionProps {
|
||||
title?: any;
|
||||
@@ -35,14 +45,40 @@ export function HeroSection({
|
||||
if (variant === 'tryit' && tool) {
|
||||
return (
|
||||
<section className="relative overflow-hidden pt-12 pb-20 sm:pt-20 sm:pb-28 lg:pt-24 lg:pb-32 bg-[#FAF8F5]">
|
||||
{/* Subtle Ambient Radial Lighting */}
|
||||
{/* Interactive 3D Three.js Neural Prism Canvas Layer */}
|
||||
<div className="absolute top-4 sm:top-8 left-1/2 -translate-x-1/2 w-full max-w-[620px] h-[340px] sm:h-[400px] pointer-events-none z-0 opacity-65 sm:opacity-80">
|
||||
<Hero3DCanvas />
|
||||
</div>
|
||||
|
||||
{/* Ambient Radial Lighting Glow */}
|
||||
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-full max-w-7xl h-[450px] bg-gradient-to-b from-blue-500/[0.04] via-indigo-500/[0.03] to-transparent blur-3xl pointer-events-none -z-10" />
|
||||
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="text-center max-w-3xl mx-auto space-y-6 mb-12 sm:mb-16">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
|
||||
{/* Floating Kinetic Telemetry Badges (Squared Media Style) */}
|
||||
<div className="hidden lg:flex items-center gap-3 px-4 py-2.5 rounded-2xl bg-white/95 backdrop-blur-md border border-slate-900/[0.08] shadow-cream-md absolute top-6 left-6 xl:left-12 animate-float-slow z-20 pointer-events-none">
|
||||
<span className="relative flex h-2.5 w-2.5">
|
||||
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
|
||||
<span className="relative inline-flex rounded-full h-2.5 w-2.5 bg-emerald-500"></span>
|
||||
</span>
|
||||
<div>
|
||||
<div className="text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider">Privacy Engine</div>
|
||||
<div className="text-xs font-mono font-bold text-slate-900">Zero Disk Retention</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="hidden lg:flex items-center gap-3 px-4 py-2.5 rounded-2xl bg-white/95 backdrop-blur-md border border-slate-900/[0.08] shadow-cream-md absolute top-12 right-6 xl:right-12 animate-float-medium z-20 pointer-events-none">
|
||||
<Zap className="w-4 h-4 text-amber-500" />
|
||||
<div>
|
||||
<div className="text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider">Stream Latency</div>
|
||||
<div className="text-xs font-mono font-bold text-slate-900">< 340ms Inference</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Hero Header */}
|
||||
<div className="text-center max-w-3xl mx-auto space-y-6 mb-12 sm:mb-16 relative z-10">
|
||||
{/* Live Core Status Pill */}
|
||||
{resolvedBadge && (
|
||||
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-blue-50 border border-blue-200/80 text-xs font-mono font-semibold text-blue-700 shadow-sm">
|
||||
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-blue-50 border border-blue-200/80 text-xs font-mono font-semibold text-blue-700 shadow-sm backdrop-blur-sm">
|
||||
<span className="relative flex h-2 w-2">
|
||||
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-500 opacity-75"></span>
|
||||
<span className="relative inline-flex rounded-full h-2 w-2 bg-blue-600"></span>
|
||||
@@ -81,14 +117,25 @@ export function HeroSection({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Embedded Interactive Free Try-It Widget */}
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<TryItWidget
|
||||
tool={tool}
|
||||
homeApp={homeApp}
|
||||
variants={variants}
|
||||
locale={locale}
|
||||
/>
|
||||
{/* Embedded Interactive Free Try-It Widget wrapped with 3D Tilt Card */}
|
||||
<div className="max-w-4xl mx-auto relative z-10">
|
||||
<TiltCard maxTilt={4} scale={1.01} showGlare={true}>
|
||||
<TryItWidget
|
||||
tool={tool}
|
||||
homeApp={homeApp}
|
||||
variants={variants}
|
||||
locale={locale}
|
||||
/>
|
||||
</TiltCard>
|
||||
|
||||
{/* Bottom Floating Architecture Chip */}
|
||||
<div className="hidden xl:flex items-center gap-3 px-4 py-2.5 rounded-2xl bg-white/95 backdrop-blur-md border border-slate-900/[0.08] shadow-cream-md absolute -bottom-5 -right-6 animate-float-slow z-20 pointer-events-none">
|
||||
<Cpu className="w-4 h-4 text-indigo-600" />
|
||||
<div>
|
||||
<div className="text-[10px] font-mono font-bold text-slate-500 uppercase tracking-wider">Architecture</div>
|
||||
<div className="text-xs font-mono font-bold text-slate-900">Dual-Stream P3M & GAN</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -98,9 +145,14 @@ export function HeroSection({
|
||||
// Centered Hero for Tools/Apps/Pricing pages
|
||||
return (
|
||||
<section className="relative overflow-hidden pt-20 pb-24 sm:pt-28 sm:pb-32 text-center bg-[#FAF8F5] border-b border-slate-900/[0.07]">
|
||||
{/* Ambient 3D Canvas in background */}
|
||||
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-full max-w-[500px] h-[300px] pointer-events-none -z-0 opacity-40">
|
||||
<Hero3DCanvas />
|
||||
</div>
|
||||
|
||||
<div className="absolute top-0 left-1/2 -translate-x-1/2 w-full max-w-7xl h-96 bg-gradient-to-b from-blue-500/[0.04] to-transparent blur-3xl pointer-events-none -z-10" />
|
||||
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6 relative z-10">
|
||||
{resolvedBadge && (
|
||||
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-blue-50 border border-blue-200 text-xs font-mono font-semibold text-blue-700 shadow-sm">
|
||||
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Sparkles, ArrowRight, Smartphone, CheckCircle2, Zap, Cpu, ShieldCheck } from 'lucide-react';
|
||||
import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider';
|
||||
import { TiltCard } from '@/components/ui/TiltCard';
|
||||
|
||||
interface FlagshipBanner {
|
||||
id: string;
|
||||
badge: string;
|
||||
model: string;
|
||||
latency: string;
|
||||
title: string;
|
||||
tagline: string;
|
||||
description: string;
|
||||
toolSlug: string;
|
||||
appSlug: string;
|
||||
appName: string;
|
||||
beforeUrl: string;
|
||||
afterUrl: string;
|
||||
benefits: string[];
|
||||
align: 'left' | 'right';
|
||||
}
|
||||
|
||||
const flagshipBanners: FlagshipBanner[] = [
|
||||
{
|
||||
id: 'matting',
|
||||
badge: 'FLAGSHIP NEURAL MODEL 01',
|
||||
model: 'P3M-Net Dual-Stream Alpha',
|
||||
latency: '< 520ms Stream',
|
||||
title: 'Hair-Strand Matting & Instant Cutout',
|
||||
tagline: 'Sub-pixel edge alpha isolation ready for commercial catalogs.',
|
||||
description: 'Trained on high-resolution studio portraits, P3M-Net isolates individual flyaway hair strands, fur, and translucent fabrics without halo artifacts or jagged edges. Streams transparent alpha PNGs in real-time.',
|
||||
toolSlug: 'background-remover',
|
||||
appSlug: 'bg-cleaner-app',
|
||||
appName: 'Magic Cutout Studio',
|
||||
beforeUrl: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=800&auto=format&fit=crop&q=80',
|
||||
afterUrl: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=80',
|
||||
benefits: [
|
||||
'Sub-pixel flyaway hair detection',
|
||||
'Clean alpha transparent PNG streaming',
|
||||
'Zero edge bleeding or color fringes',
|
||||
],
|
||||
align: 'left',
|
||||
},
|
||||
{
|
||||
id: 'retouch',
|
||||
badge: 'FLAGSHIP NEURAL MODEL 02',
|
||||
model: 'RetouchGAN v2.1 Micro-Pore',
|
||||
latency: '< 380ms Stream',
|
||||
title: 'Sub-Pore Skin Retouching & Blemish Removal',
|
||||
tagline: 'Natural texture preservation without artificial plastic smoothing.',
|
||||
description: 'Unlike standard beauty filters that smear your face into plastic, RetouchGAN operates at the dermal level—erasing acne, blemishes, and under-eye redness while reconstructing microscopic skin pore geometry.',
|
||||
toolSlug: 'blemish-remover',
|
||||
appSlug: 'portrait-app',
|
||||
appName: 'Portrait Studio AI',
|
||||
beforeUrl: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80',
|
||||
afterUrl: 'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80',
|
||||
benefits: [
|
||||
'Microscopic skin pore texture retained',
|
||||
'Instant acne, scar & discoloration repair',
|
||||
'Volatile RAM streaming with zero storage',
|
||||
],
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
id: 'enhancer',
|
||||
badge: 'FLAGSHIP NEURAL MODEL 03',
|
||||
model: 'GFPGAN + RealESRGAN Ultra',
|
||||
latency: '< 460ms Stream',
|
||||
title: '4K Super-Resolution & Facial Deblurring',
|
||||
tagline: 'Transform low-resolution snapshots into crystal-clear 4K portraits.',
|
||||
description: 'Deep neural priors restore authentic iris sharpness, eyelash detail, and facial contours on blurry, out-of-focus, or highly compressed photos, yielding gallery-ready clarity with zero guesswork.',
|
||||
toolSlug: 'photo-enhancer',
|
||||
appSlug: 'photo-enhancer-pro',
|
||||
appName: 'Enhance Ultra AI',
|
||||
beforeUrl: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=800&auto=format&fit=crop&q=80',
|
||||
afterUrl: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=800&auto=format&fit=crop&q=80',
|
||||
benefits: [
|
||||
'Iris clarity & sharp eyelash synthesis',
|
||||
'400% lossless resolution upscaling',
|
||||
'Instant 1-click HD browser download',
|
||||
],
|
||||
align: 'left',
|
||||
},
|
||||
];
|
||||
|
||||
export function MajorToolBannersSection() {
|
||||
return (
|
||||
<section id="flagship-models" className="py-24 sm:py-32 bg-[#FAF8F5] border-t border-slate-900/[0.08] relative overflow-hidden">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
|
||||
{/* Section Header */}
|
||||
<div className="text-center max-w-3xl mx-auto mb-16 sm:mb-24 space-y-4">
|
||||
<div className="inline-flex items-center gap-2 px-3.5 py-1.5 rounded-full bg-blue-50 border border-blue-200 text-xs font-mono font-semibold text-blue-700 shadow-sm">
|
||||
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
|
||||
<span>FLAGSHIP NEURAL CAPABILITIES</span>
|
||||
</div>
|
||||
<h2 className="text-3xl sm:text-4xl lg:text-5xl font-display font-black text-slate-900 tracking-tight">
|
||||
Flagship <span className="text-transparent bg-clip-text bg-gradient-to-r from-blue-700 via-indigo-600 to-purple-600">Vision Banners</span>
|
||||
</h2>
|
||||
<p className="text-base sm:text-lg text-slate-600 font-normal">
|
||||
Experience our most powerful commercial AI models in action with continuous auto-scanning comparisons.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Flagship Banners Stack */}
|
||||
<div className="space-y-16 lg:space-y-24 max-w-6xl mx-auto">
|
||||
{flagshipBanners.map((banner, idx) => {
|
||||
const isSliderLeft = banner.align === 'right';
|
||||
|
||||
return (
|
||||
<TiltCard
|
||||
key={banner.id}
|
||||
maxTilt={2.5}
|
||||
scale={1.008}
|
||||
showGlare={true}
|
||||
className="rounded-3xl"
|
||||
>
|
||||
<div className="bg-white rounded-3xl p-8 sm:p-12 lg:p-14 border border-slate-900/[0.08] shadow-cream-md hover:shadow-cream-lg transition-all duration-300">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-12 gap-10 lg:gap-14 items-center">
|
||||
{/* If slider is on left */}
|
||||
{isSliderLeft && (
|
||||
<div className="lg:col-span-6 order-2 lg:order-1">
|
||||
<BeforeAfterSlider
|
||||
beforeUrl={banner.beforeUrl}
|
||||
afterUrl={banner.afterUrl}
|
||||
beforeLabel="Raw Input"
|
||||
afterLabel="CRE AI Output"
|
||||
aspectRatio="aspect-[4/3] sm:aspect-[16/11]"
|
||||
autoSlide={true}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Text Details Column */}
|
||||
<div className={`lg:col-span-6 space-y-6 ${isSliderLeft ? 'order-1 lg:order-2' : ''}`}>
|
||||
<div className="flex flex-wrap items-center gap-2.5">
|
||||
<span className="text-xs font-mono font-bold tracking-widest text-blue-700 bg-blue-50 border border-blue-200 px-3 py-1 rounded-full">
|
||||
{banner.badge}
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5 text-xs font-mono font-semibold text-slate-700 bg-slate-100 border border-slate-200 px-3 py-1 rounded-full">
|
||||
<Cpu className="w-3.5 h-3.5 text-blue-600" />
|
||||
<span>{banner.model}</span>
|
||||
</span>
|
||||
<span className="text-xs font-mono font-semibold text-emerald-800 bg-emerald-50 border border-emerald-200 px-2.5 py-1 rounded-full">
|
||||
{banner.latency}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-2xl sm:text-3xl lg:text-4xl font-display font-black text-slate-900 tracking-tight leading-tight">
|
||||
{banner.title}
|
||||
</h3>
|
||||
<p className="text-sm sm:text-base font-semibold text-blue-700">
|
||||
{banner.tagline}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-slate-600 leading-relaxed font-normal">
|
||||
{banner.description}
|
||||
</p>
|
||||
|
||||
{/* Feature Points */}
|
||||
<div className="space-y-2.5 pt-2">
|
||||
{banner.benefits.map((benefit, bIdx) => (
|
||||
<div key={bIdx} className="flex items-center gap-3 text-xs sm:text-sm text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>{benefit}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="pt-4 flex flex-wrap items-center gap-3.5">
|
||||
<Link
|
||||
href={`/tools/${banner.toolSlug}`}
|
||||
className="inline-flex items-center gap-2 px-6 py-3.5 rounded-full text-xs sm:text-sm font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-sm shadow-blue-500/25 transition-all duration-200 hover:-translate-y-0.5"
|
||||
>
|
||||
<span>Launch Tool Online</span>
|
||||
<ArrowRight className="w-4 h-4" />
|
||||
</Link>
|
||||
|
||||
<Link
|
||||
href={`/apps/${banner.appSlug}`}
|
||||
className="inline-flex items-center gap-2 px-5 py-3.5 rounded-full text-xs sm:text-sm font-bold text-slate-700 bg-slate-100 border border-slate-200 hover:bg-slate-200 transition-colors"
|
||||
>
|
||||
<Smartphone className="w-4 h-4 text-blue-600" />
|
||||
<span>Get in {banner.appName}</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* If slider is on right */}
|
||||
{!isSliderLeft && (
|
||||
<div className="lg:col-span-6">
|
||||
<BeforeAfterSlider
|
||||
beforeUrl={banner.beforeUrl}
|
||||
afterUrl={banner.afterUrl}
|
||||
beforeLabel="Raw Input"
|
||||
afterLabel="CRE AI Output"
|
||||
aspectRatio="aspect-[4/3] sm:aspect-[16/11]"
|
||||
autoSlide={true}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</TiltCard>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import { TransformationReelSection } from './TransformationReelSection';
|
||||
import { VisualUseCasesSection } from './VisualUseCasesSection';
|
||||
import { WorkflowVisualizerSection } from './WorkflowVisualizerSection';
|
||||
import { VerticalToolStackSection } from './VerticalToolStackSection';
|
||||
import { MajorToolBannersSection } from './MajorToolBannersSection';
|
||||
|
||||
interface SectionRendererProps {
|
||||
section: SectionConfig;
|
||||
@@ -69,6 +70,9 @@ export function SectionRenderer({ section, context }: SectionRendererProps) {
|
||||
case 'transformationReel':
|
||||
return <TransformationReelSection />;
|
||||
|
||||
case 'majorToolBanners':
|
||||
return <MajorToolBannersSection />;
|
||||
|
||||
case 'visualUseCases':
|
||||
return <VisualUseCasesSection />;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { resolveLocalised, ToolItem, CategoryItem } from '@/types';
|
||||
import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider';
|
||||
import { TiltCard } from '@/components/ui/TiltCard';
|
||||
|
||||
export interface VerticalToolStackProps {
|
||||
context: {
|
||||
@@ -170,90 +171,95 @@ export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
<TiltCard
|
||||
key={tool.id}
|
||||
className="bg-white rounded-3xl p-7 sm:p-9 border border-slate-900/[0.08] hover:border-blue-400 shadow-cream-sm hover:shadow-cream-md transition-all duration-300 relative group"
|
||||
maxTilt={2.5}
|
||||
scale={1.008}
|
||||
showGlare={true}
|
||||
className="rounded-3xl"
|
||||
>
|
||||
{/* Top Metadata Row */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 mb-6 pb-4 border-b border-slate-100">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{/* Neural Model Tag */}
|
||||
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-700 font-mono text-[11px] font-semibold">
|
||||
<Cpu className="w-3 h-3 text-blue-600" />
|
||||
<span>{badgeInfo.model}</span>
|
||||
</span>
|
||||
{/* Specific Capability Chip */}
|
||||
<span className="px-2.5 py-1 rounded-full bg-slate-100 border border-slate-200 text-slate-700 text-[11px] font-mono font-medium">
|
||||
{badgeInfo.chip}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Latency Metric */}
|
||||
<div className="flex items-center gap-1.5 text-[11px] font-mono text-emerald-700 bg-emerald-50 border border-emerald-200 px-3 py-1 rounded-full font-semibold">
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
|
||||
<span>{badgeInfo.latency} Stream</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Card Content Grid: 2 Symmetric Columns */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-12 gap-8 lg:gap-10 items-center">
|
||||
{/* Left Details Column */}
|
||||
<div className="md:col-span-6 space-y-4">
|
||||
<h4 className="text-2xl sm:text-3xl font-display font-bold text-slate-900 group-hover:text-blue-600 transition-colors">
|
||||
{resolveLocalised(tool.name, locale)}
|
||||
</h4>
|
||||
<p className="text-xs sm:text-sm text-slate-600 leading-relaxed font-normal">
|
||||
{resolveLocalised(tool.summary, locale)}
|
||||
</p>
|
||||
|
||||
{/* Features Checklist */}
|
||||
<div className="space-y-2.5 pt-2">
|
||||
<div className="flex items-center gap-2.5 text-xs text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>Zero photo retention with volatile RAM streaming</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5 text-xs text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>Full HD lossless output with no watermark</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5 text-xs text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>Seamless mobile handoff with 50 bonus credits</span>
|
||||
</div>
|
||||
<div className="bg-white rounded-3xl p-7 sm:p-9 border border-slate-900/[0.08] hover:border-blue-400 shadow-cream-sm hover:shadow-cream-md transition-all duration-300 relative group">
|
||||
{/* Top Metadata Row */}
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 mb-6 pb-4 border-b border-slate-100">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{/* Neural Model Tag */}
|
||||
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-700 font-mono text-[11px] font-semibold">
|
||||
<Cpu className="w-3 h-3 text-blue-600" />
|
||||
<span>{badgeInfo.model}</span>
|
||||
</span>
|
||||
{/* Specific Capability Chip */}
|
||||
<span className="px-2.5 py-1 rounded-full bg-slate-100 border border-slate-200 text-slate-700 text-[11px] font-mono font-medium">
|
||||
{badgeInfo.chip}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="pt-4 flex flex-wrap items-center gap-3">
|
||||
<Link
|
||||
href={`/tools/${tool.slug}`}
|
||||
className="inline-flex items-center gap-2 px-6 py-3 rounded-full text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-sm shadow-blue-500/20 transition-all duration-200 hover:-translate-y-0.5 active:translate-y-0"
|
||||
>
|
||||
<span>Launch Tool Online</span>
|
||||
<ArrowRight className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
|
||||
<Link
|
||||
href={`/apps/${tool.homeApp}`}
|
||||
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" />
|
||||
<span>Native App</span>
|
||||
</Link>
|
||||
{/* Latency Metric */}
|
||||
<div className="flex items-center gap-1.5 text-[11px] font-mono text-emerald-700 bg-emerald-50 border border-emerald-200 px-3 py-1 rounded-full font-semibold">
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse" />
|
||||
<span>{badgeInfo.latency} Stream</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Interactive Before/After Comparison Slider */}
|
||||
<div className="md:col-span-6">
|
||||
<BeforeAfterSlider
|
||||
beforeUrl={example.before}
|
||||
afterUrl={example.after}
|
||||
beforeLabel="Raw Input"
|
||||
afterLabel="CRE Result"
|
||||
aspectRatio="aspect-[4/3]"
|
||||
/>
|
||||
{/* Card Content Grid: 2 Symmetric Columns */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-12 gap-8 lg:gap-10 items-center">
|
||||
{/* Left Details Column */}
|
||||
<div className="md:col-span-6 space-y-4">
|
||||
<h4 className="text-2xl sm:text-3xl font-display font-bold text-slate-900 group-hover:text-blue-600 transition-colors">
|
||||
{resolveLocalised(tool.name, locale)}
|
||||
</h4>
|
||||
<p className="text-xs sm:text-sm text-slate-600 leading-relaxed font-normal">
|
||||
{resolveLocalised(tool.summary, locale)}
|
||||
</p>
|
||||
|
||||
{/* Features Checklist */}
|
||||
<div className="space-y-2.5 pt-2">
|
||||
<div className="flex items-center gap-2.5 text-xs text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>Zero photo retention with volatile RAM streaming</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5 text-xs text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>Full HD lossless output with no watermark</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2.5 text-xs text-slate-700 font-medium">
|
||||
<CheckCircle2 className="w-4 h-4 text-blue-600 shrink-0" />
|
||||
<span>Seamless mobile handoff with 50 bonus credits</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="pt-4 flex flex-wrap items-center gap-3">
|
||||
<Link
|
||||
href={`/tools/${tool.slug}`}
|
||||
className="inline-flex items-center gap-2 px-6 py-3 rounded-full text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-sm shadow-blue-500/20 transition-all duration-200 hover:-translate-y-0.5 active:translate-y-0"
|
||||
>
|
||||
<span>Launch Tool Online</span>
|
||||
<ArrowRight className="w-3.5 h-3.5" />
|
||||
</Link>
|
||||
|
||||
<Link
|
||||
href={`/apps/${tool.homeApp}`}
|
||||
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" />
|
||||
<span>Native App</span>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Interactive Before/After Comparison Slider */}
|
||||
<div className="md:col-span-6">
|
||||
<BeforeAfterSlider
|
||||
beforeUrl={example.before}
|
||||
afterUrl={example.after}
|
||||
beforeLabel="Raw Input"
|
||||
afterLabel="CRE Result"
|
||||
aspectRatio="aspect-[4/3]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TiltCard>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ interface BeforeAfterSliderProps {
|
||||
afterLabel?: string;
|
||||
caption?: string;
|
||||
aspectRatio?: string;
|
||||
autoSlide?: boolean;
|
||||
}
|
||||
|
||||
export function BeforeAfterSlider({
|
||||
@@ -19,10 +20,37 @@ export function BeforeAfterSlider({
|
||||
afterLabel = 'CRE AI Result',
|
||||
caption,
|
||||
aspectRatio = 'aspect-[4/3] sm:aspect-[16/10]',
|
||||
autoSlide = true,
|
||||
}: BeforeAfterSliderProps) {
|
||||
const [sliderPosition, setSliderPosition] = useState(50);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [isUserInteracting, setIsUserInteracting] = useState(false);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const animFrameRef = useRef<number | null>(null);
|
||||
const resumeTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const startTimeRef = useRef<number>(Date.now());
|
||||
|
||||
// Auto-slide animation loop using RAF
|
||||
useEffect(() => {
|
||||
if (!autoSlide || isDragging || isUserInteracting) {
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
return;
|
||||
}
|
||||
|
||||
const animate = () => {
|
||||
const elapsed = Date.now() - startTimeRef.current;
|
||||
// Smooth sine wave between 24% and 76% (period ~4 seconds)
|
||||
const newPos = 50 + 26 * Math.sin(elapsed * 0.0016);
|
||||
setSliderPosition(newPos);
|
||||
animFrameRef.current = requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
animFrameRef.current = requestAnimationFrame(animate);
|
||||
|
||||
return () => {
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
};
|
||||
}, [autoSlide, isDragging, isUserInteracting]);
|
||||
|
||||
const handleMove = useCallback((clientX: number) => {
|
||||
if (!containerRef.current) return;
|
||||
@@ -61,12 +89,33 @@ export function BeforeAfterSlider({
|
||||
};
|
||||
}, [isDragging, handleMouseMove, handleMouseUp, handleTouchMove]);
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
setIsUserInteracting(true);
|
||||
if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current);
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current);
|
||||
resumeTimerRef.current = setTimeout(() => {
|
||||
setIsUserInteracting(false);
|
||||
startTimeRef.current = Date.now();
|
||||
}, 2500);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<div
|
||||
ref={containerRef}
|
||||
onMouseDown={() => setIsDragging(true)}
|
||||
onTouchStart={() => setIsDragging(true)}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
onMouseDown={() => {
|
||||
setIsDragging(true);
|
||||
setIsUserInteracting(true);
|
||||
}}
|
||||
onTouchStart={() => {
|
||||
setIsDragging(true);
|
||||
setIsUserInteracting(true);
|
||||
}}
|
||||
className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden select-none cursor-ew-resize shadow-md border border-slate-900/[0.08] bg-slate-950 group`}
|
||||
style={{ touchAction: 'pan-y' }}
|
||||
>
|
||||
@@ -121,9 +170,19 @@ export function BeforeAfterSlider({
|
||||
<span>{afterLabel}</span>
|
||||
</div>
|
||||
|
||||
{/* Bottom Helper Hint */}
|
||||
<div className="absolute bottom-3 left-1/2 -translate-x-1/2 bg-black/60 backdrop-blur-md px-3 py-1 rounded-full text-[10px] font-mono text-white/90 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
||||
Drag horizontally to inspect pore texture
|
||||
{/* Animated Sliding Status Pill */}
|
||||
<div className="absolute bottom-3 left-1/2 -translate-x-1/2 bg-slate-900/85 backdrop-blur-md px-3.5 py-1 rounded-full text-[10px] font-mono font-semibold text-white pointer-events-none border border-white/10 shadow-sm flex items-center gap-1.5">
|
||||
{autoSlide && !isUserInteracting ? (
|
||||
<>
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-cyan-400 animate-pulse" />
|
||||
<span>Auto-Scanning Difference (Hover to Drag)</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className="w-1.5 h-1.5 rounded-full bg-blue-400" />
|
||||
<span>Interactive Drag Mode</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export function CursorAura() {
|
||||
const [mounted, setMounted] = useState<boolean>(false);
|
||||
const posRef = useRef({ targetX: -500, targetY: -500, currentX: -500, currentY: -500 });
|
||||
const auraRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Only enable on pointer-fine (mouse/trackpad) and when not reduced-motion
|
||||
if (window.matchMedia('(pointer: coarse)').matches) return;
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
|
||||
setMounted(true);
|
||||
|
||||
const onMouseMove = (e: MouseEvent) => {
|
||||
posRef.current.targetX = e.clientX;
|
||||
posRef.current.targetY = e.clientY;
|
||||
};
|
||||
|
||||
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
||||
|
||||
let animId: number;
|
||||
|
||||
const render = () => {
|
||||
const pos = posRef.current;
|
||||
// Damped lerp follower
|
||||
pos.currentX += (pos.targetX - pos.currentX) * 0.08;
|
||||
pos.currentY += (pos.targetY - pos.currentY) * 0.08;
|
||||
|
||||
if (auraRef.current) {
|
||||
auraRef.current.style.transform = `translate3d(${pos.currentX - 250}px, ${pos.currentY - 250}px, 0)`;
|
||||
}
|
||||
|
||||
animId = requestAnimationFrame(render);
|
||||
};
|
||||
|
||||
animId = requestAnimationFrame(render);
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(animId);
|
||||
window.removeEventListener('mousemove', onMouseMove);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!mounted) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none fixed inset-0 z-0 overflow-hidden hidden [@media(hover:hover)]:block"
|
||||
>
|
||||
<div
|
||||
ref={auraRef}
|
||||
className="absolute top-0 left-0 w-[500px] h-[500px] rounded-full will-change-transform opacity-60"
|
||||
style={{
|
||||
background:
|
||||
'radial-gradient(circle, rgba(59, 130, 246, 0.09) 0%, rgba(99, 102, 241, 0.05) 35%, rgba(168, 85, 247, 0.02) 60%, transparent 80%)',
|
||||
filter: 'blur(35px)',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
'use client';
|
||||
|
||||
import React, { useRef, useState, useCallback, MouseEvent } from 'react';
|
||||
|
||||
interface TiltCardProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
maxTilt?: number; // Maximum tilt angle in degrees (default: 8)
|
||||
scale?: number; // Scale on hover (default: 1.015)
|
||||
showGlare?: boolean; // Enable dynamic specular shine reflection (default: true)
|
||||
}
|
||||
|
||||
export function TiltCard({
|
||||
children,
|
||||
className = '',
|
||||
maxTilt = 7,
|
||||
scale = 1.015,
|
||||
showGlare = true,
|
||||
}: TiltCardProps) {
|
||||
const cardRef = useRef<HTMLDivElement>(null);
|
||||
const [transformStyle, setTransformStyle] = useState<string>('');
|
||||
const [glareStyle, setGlareStyle] = useState<{ opacity: number; background: string }>({
|
||||
opacity: 0,
|
||||
background: '',
|
||||
});
|
||||
const [isHovered, setIsHovered] = useState<boolean>(false);
|
||||
|
||||
const handleMouseMove = useCallback(
|
||||
(e: MouseEvent<HTMLDivElement>) => {
|
||||
const card = cardRef.current;
|
||||
if (!card) return;
|
||||
|
||||
const rect = card.getBoundingClientRect();
|
||||
const x = e.clientX - rect.left;
|
||||
const y = e.clientY - rect.top;
|
||||
|
||||
const width = rect.width;
|
||||
const height = rect.height;
|
||||
|
||||
// Normalized coordinates from -1 to 1
|
||||
const normalizedX = (x / width) * 2 - 1;
|
||||
const normalizedY = (y / height) * 2 - 1;
|
||||
|
||||
// Tilt angles (negative Y rotates along X axis)
|
||||
const rotateX = -normalizedY * maxTilt;
|
||||
const rotateY = normalizedX * maxTilt;
|
||||
|
||||
setTransformStyle(
|
||||
`perspective(1000px) rotateX(${rotateX.toFixed(2)}deg) rotateY(${rotateY.toFixed(2)}deg) scale3d(${scale}, ${scale}, ${scale})`
|
||||
);
|
||||
|
||||
if (showGlare) {
|
||||
const glareX = (x / width) * 100;
|
||||
const glareY = (y / height) * 100;
|
||||
|
||||
setGlareStyle({
|
||||
opacity: 0.18,
|
||||
background: `radial-gradient(circle 350px at ${glareX}% ${glareY}%, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.05) 50%, transparent 80%)`,
|
||||
});
|
||||
}
|
||||
},
|
||||
[maxTilt, scale, showGlare]
|
||||
);
|
||||
|
||||
const handleMouseEnter = useCallback(() => {
|
||||
setIsHovered(true);
|
||||
}, []);
|
||||
|
||||
const handleMouseLeave = useCallback(() => {
|
||||
setIsHovered(false);
|
||||
setTransformStyle('perspective(1000px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)');
|
||||
setGlareStyle((prev) => ({ ...prev, opacity: 0 }));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={cardRef}
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
style={{
|
||||
transform: transformStyle || undefined,
|
||||
transformStyle: 'preserve-3d',
|
||||
transition: isHovered
|
||||
? 'transform 0.1s ease-out'
|
||||
: 'transform 0.5s cubic-bezier(0.16, 1, 0.3, 1)',
|
||||
}}
|
||||
className={`relative will-change-transform ${className}`}
|
||||
>
|
||||
{children}
|
||||
|
||||
{/* Dynamic Specular Glare Reflection */}
|
||||
{showGlare && (
|
||||
<div
|
||||
className="absolute inset-0 rounded-[inherit] pointer-events-none transition-opacity duration-300 z-30 overflow-hidden"
|
||||
style={{
|
||||
opacity: glareStyle.opacity,
|
||||
background: glareStyle.background,
|
||||
}}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user