77 Commits

Author SHA1 Message Date
03df96f083 Update src/app/gym-3d/page.tsx 2026-03-04 19:34:21 +00:00
5013b53765 Update src/app/gym-3d/page.tsx 2026-03-04 19:33:02 +00:00
7cfd7b9740 Update src/app/gym-3d/page.tsx 2026-03-04 19:31:49 +00:00
cd4d18a801 Update src/app/gym-3d/page.tsx 2026-03-04 19:30:31 +00:00
10e3fad348 Update src/app/gym-3d/page.tsx 2026-03-04 19:29:21 +00:00
c38c3287c1 Update src/app/page.tsx 2026-03-04 19:28:11 +00:00
3c8e21634d Update src/app/layout.tsx 2026-03-04 19:28:11 +00:00
39736cb05d Update src/app/gym-3d/page.tsx 2026-03-04 19:28:10 +00:00
f51f6aac7f Update src/app/page.tsx 2026-03-04 19:11:53 +00:00
1f88228dbd Update src/app/layout.tsx 2026-03-04 19:11:52 +00:00
fe948f40d8 Update src/app/page.tsx 2026-03-04 19:08:35 +00:00
3df05324f8 Update src/app/layout.tsx 2026-03-04 19:08:34 +00:00
aa174c3fba Update src/app/gym-3d/page.tsx 2026-03-04 19:08:33 +00:00
957f27d3f4 Update src/components/sections/blog/BlogCardTwo.tsx 2026-03-04 19:02:03 +00:00
bb604433c5 Update src/components/sections/blog/BlogCardThree.tsx 2026-03-04 19:02:03 +00:00
98927d5c65 Update src/components/sections/blog/BlogCardOne.tsx 2026-03-04 19:02:02 +00:00
8c13071105 Update src/components/sections/blog/BlogCardTwo.tsx 2026-03-04 19:00:29 +00:00
d2c9774934 Update src/components/sections/blog/BlogCardThree.tsx 2026-03-04 19:00:28 +00:00
a9c442f17a Update src/components/sections/blog/BlogCardOne.tsx 2026-03-04 19:00:28 +00:00
7f361fa741 Update src/components/sections/blog/BlogCardTwo.tsx 2026-03-04 18:58:57 +00:00
561a19bc2e Update src/components/sections/blog/BlogCardThree.tsx 2026-03-04 18:58:56 +00:00
9604c47d9f Update src/components/sections/blog/BlogCardOne.tsx 2026-03-04 18:58:56 +00:00
8e74cf1994 Update src/components/sections/blog/BlogCardTwo.tsx 2026-03-04 18:57:28 +00:00
fc8ac045cd Update src/components/sections/blog/BlogCardThree.tsx 2026-03-04 18:57:28 +00:00
2c5d2a4959 Update src/components/sections/blog/BlogCardOne.tsx 2026-03-04 18:57:27 +00:00
1d06ae95a3 Update src/app/gym-3d/page.tsx 2026-03-04 18:57:27 +00:00
f808026c6d Update src/app/page.tsx 2026-03-04 18:55:30 +00:00
e2d3bbb4d0 Update src/app/layout.tsx 2026-03-04 18:55:30 +00:00
d16d1f0b26 Update src/app/gym-3d/page.tsx 2026-03-04 18:55:29 +00:00
7e3f6595c7 Update src/components/shared/Dashboard.tsx 2026-03-04 18:53:34 +00:00
936394f078 Update src/components/cardStack/layouts/timelines/TimelineProcessFlow.tsx 2026-03-04 18:53:33 +00:00
9185617dea Update src/components/cardStack/layouts/timelines/TimelinePhoneView.tsx 2026-03-04 18:53:33 +00:00
64cadcb367 Update src/components/cardStack/layouts/timelines/TimelineHorizontalCardStack.tsx 2026-03-04 18:53:32 +00:00
7962fb0ad5 Update src/components/cardStack/layouts/carousels/AutoCarousel.tsx 2026-03-04 18:53:32 +00:00
ca488ea512 Update src/components/cardStack/CardList.tsx 2026-03-04 18:53:31 +00:00
39aabdb7b7 Add src/hooks/useCardAnimation.ts 2026-03-04 18:50:27 +00:00
d1d6ebe559 Update src/components/shared/Dashboard.tsx 2026-03-04 18:50:27 +00:00
2102e120b8 Update src/components/sections/team/TeamCardFive.tsx 2026-03-04 18:50:26 +00:00
93e306122c Update src/components/sections/metrics/MetricCardEleven.tsx 2026-03-04 18:50:26 +00:00
af3b5b15f1 Update src/components/sections/feature/FeatureCardSixteen.tsx 2026-03-04 18:50:25 +00:00
29b3444668 Update src/components/sections/contact/ContactFaq.tsx 2026-03-04 18:50:25 +00:00
c1d17c5dec Update src/components/ecommerce/productCatalog/ProductCatalog.tsx 2026-03-04 18:50:24 +00:00
94567ac331 Update src/components/cardStack/layouts/timelines/TimelineProcessFlow.tsx 2026-03-04 18:50:23 +00:00
e7460a8877 Update src/components/cardStack/layouts/timelines/TimelinePhoneView.tsx 2026-03-04 18:50:21 +00:00
cc961688fb Update src/components/cardStack/layouts/grid/GridLayout.tsx 2026-03-04 18:50:19 +00:00
69d3b51d51 Update src/components/cardStack/layouts/carousels/ButtonCarousel.tsx 2026-03-04 18:50:18 +00:00
abf61bbeb1 Update src/components/cardStack/layouts/carousels/AutoCarousel.tsx 2026-03-04 18:50:17 +00:00
a1b6e7a70b Update src/components/cardStack/CardStack.tsx 2026-03-04 18:50:17 +00:00
f0ed8b9744 Update src/components/cardStack/CardList.tsx 2026-03-04 18:50:16 +00:00
3de2f401cc Update src/hooks/useProducts.ts 2026-03-04 18:48:38 +00:00
583fd7d255 Update src/hooks/useProduct.ts 2026-03-04 18:48:37 +00:00
3cbb15e331 Update src/components/sections/product/ProductCardTwo.tsx 2026-03-04 18:48:37 +00:00
dc29c790ab Update src/components/sections/product/ProductCardThree.tsx 2026-03-04 18:48:36 +00:00
4e7e90f543 Update src/components/sections/product/ProductCardOne.tsx 2026-03-04 18:48:35 +00:00
7dc92b519f Update src/components/sections/product/ProductCardFour.tsx 2026-03-04 18:48:34 +00:00
f253534b66 Update src/components/cardStack/hooks/useCardAnimation.ts 2026-03-04 18:48:33 +00:00
bd2a303a19 Update src/components/cardStack/CardStack.tsx 2026-03-04 18:48:32 +00:00
0d1bb2cd3f Update src/app/page.tsx 2026-03-04 18:48:32 +00:00
0c09a6ce21 Update src/lib/api/product.ts 2026-03-04 18:46:58 +00:00
8dc9577019 Update src/hooks/useProductDetail.ts 2026-03-04 18:46:57 +00:00
9cf8e53beb Update src/hooks/useProductCatalog.ts 2026-03-04 18:46:57 +00:00
ae8604d266 Update src/hooks/useCheckout.ts 2026-03-04 18:46:56 +00:00
2cd96e4e08 Update src/components/sections/pricing/PricingCardEight.tsx 2026-03-04 18:46:56 +00:00
5888e66d4f Update src/components/sections/contact/ContactSplitForm.tsx 2026-03-04 18:46:55 +00:00
8460ad5c63 Update src/components/sections/contact/ContactSplit.tsx 2026-03-04 18:46:55 +00:00
13d9c450ac Update src/components/sections/contact/ContactCenter.tsx 2026-03-04 18:46:54 +00:00
c07adff29a Update src/components/cardStack/layouts/timelines/TimelineBase.tsx 2026-03-04 18:46:54 +00:00
788afa1f30 Update src/components/cardStack/hooks/useDepth3DAnimation.ts 2026-03-04 18:46:53 +00:00
6294dc789d Update src/app/page.tsx 2026-03-04 18:46:53 +00:00
888aeff34a Update src/app/gym-3d/page.tsx 2026-03-04 18:46:53 +00:00
0aca3c2d2b Update src/app/gym-3d/page.tsx 2026-03-04 18:44:02 +00:00
27007b9bc5 Update src/app/page.tsx 2026-03-04 18:42:07 +00:00
c94eeace0c Update src/app/layout.tsx 2026-03-04 18:42:06 +00:00
9524e66ac2 Add src/app/gym-3d/page.tsx 2026-03-04 18:42:06 +00:00
b19d8ebc55 Merge version_1 into main
Merge version_1 into main
2026-03-04 18:29:42 +00:00
e7c7f72b82 Merge version_1 into main
Merge version_1 into main
2026-03-04 18:28:42 +00:00
f1d7310e68 Merge version_1 into main
Merge version_1 into main
2026-03-04 18:27:04 +00:00
38 changed files with 2021 additions and 6163 deletions

268
src/app/gym-3d/page.tsx Normal file
View File

@@ -0,0 +1,268 @@
"use client";
import { useEffect, useRef, useState } from "react";
import * as THREE from "three";
import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay';
import { ContactSplitForm } from '@/components/sections/contact/ContactSplitForm';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import { Phone } from "lucide-react";
export default function Gym3DPage() {
const containerRef = useRef<HTMLDivElement>(null);
const sceneRef = useRef<THREE.Scene | null>(null);
const cameraRef = useRef<THREE.PerspectiveCamera | null>(null);
const rendererRef = useRef<THREE.WebGLRenderer | null>(null);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
if (!containerRef.current) return;
// Scene setup
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a0a0a);
sceneRef.current = scene;
// Camera setup
const camera = new THREE.PerspectiveCamera(
75,
containerRef.current.clientWidth / containerRef.current.clientHeight,
0.1,
1000
);
camera.position.set(0, 10, 20);
camera.lookAt(0, 5, 0);
cameraRef.current = camera;
// Renderer setup
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(containerRef.current.clientWidth, containerRef.current.clientHeight);
renderer.shadowMap.enabled = true;
containerRef.current.appendChild(renderer.domElement);
rendererRef.current = renderer;
// Lighting
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(10, 15, 10);
directionalLight.castShadow = true;
directionalLight.shadow.mapSize.width = 2048;
directionalLight.shadow.mapSize.height = 2048;
scene.add(directionalLight);
// Ground/Floor
const groundGeometry = new THREE.PlaneGeometry(40, 40);
const groundMaterial = new THREE.MeshStandardMaterial({ color: 0x1a1a1a });
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
// Gym Equipment - Power Rack
const rackGeometry = new THREE.BoxGeometry(2, 3, 1.5);
const rackMaterial = new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.8 });
const rack = new THREE.Mesh(rackGeometry, rackMaterial);
rack.position.set(-8, 1.5, 0);
rack.castShadow = true;
scene.add(rack);
// Barbell
const barbellGeometry = new THREE.CylinderGeometry(0.02, 0.02, 2.2, 16);
const barbellMaterial = new THREE.MeshStandardMaterial({ color: 0xffff00, metalness: 1 });
const barbell = new THREE.Mesh(barbellGeometry, barbellMaterial);
barbell.position.set(-8, 1.8, 0);
barbell.rotation.z = Math.PI / 2;
barbell.castShadow = true;
scene.add(barbell);
// Weight plates on barbell
for (let i = 0; i < 4; i++) {
const plateGeometry = new THREE.CylinderGeometry(0.5, 0.5, 0.05, 32);
const plateMaterial = new THREE.MeshStandardMaterial({ color: 0xff0000, metalness: 0.6 });
const plate = new THREE.Mesh(plateGeometry, plateMaterial);
plate.position.set(-8 + (i - 1.5) * 0.6, 1.8, 0);
plate.castShadow = true;
scene.add(plate);
}
// Dumbbells rack
for (let i = 0; i < 5; i++) {
const dumbellGeometry = new THREE.CylinderGeometry(0.15, 0.15, 0.5, 16);
const dumbellMaterial = new THREE.MeshStandardMaterial({ color: 0xffaa00, metalness: 0.7 });
const dumbell = new THREE.Mesh(dumbellGeometry, dumbellMaterial);
dumbell.position.set(0 + i * 1.5, 0.5, -10);
dumbell.castShadow = true;
scene.add(dumbell);
}
// Gymnastics Rig
const rigGeometry = new THREE.BoxGeometry(0.1, 0.1, 5);
const rigMaterial = new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.8 });
const rig = new THREE.Mesh(rigGeometry, rigMaterial);
rig.position.set(0, 8, 0);
rig.castShadow = true;
scene.add(rig);
// Olympic Rings
const ringRadius = 0.3;
const ringPositions = [-1.2, -0.4, 0.4, 1.2];
ringPositions.forEach((x) => {
const torusGeometry = new THREE.TorusGeometry(ringRadius, 0.08, 16, 100);
const torusMaterial = new THREE.MeshStandardMaterial({ color: 0xffffff, metalness: 0.9 });
const ring = new THREE.Mesh(torusGeometry, torusMaterial);
ring.position.set(x, 7, 0);
ring.rotation.x = Math.PI / 5;
ring.castShadow = true;
scene.add(ring);
});
// Rowing Machine
const rowingGeometry = new THREE.BoxGeometry(0.8, 1, 2.5);
const rowingMaterial = new THREE.MeshStandardMaterial({ color: 0x222222, metalness: 0.6 });
const rowingMachine = new THREE.Mesh(rowingGeometry, rowingMaterial);
rowingMachine.position.set(8, 0.8, -5);
rowingMachine.castShadow = true;
scene.add(rowingMachine);
// Treadmill
const treadmillGeometry = new THREE.BoxGeometry(1, 1.2, 2);
const treadmillMaterial = new THREE.MeshStandardMaterial({ color: 0x1a1a1a, metalness: 0.5 });
const treadmill = new THREE.Mesh(treadmillGeometry, treadmillMaterial);
treadmill.position.set(8, 0.8, 0);
treadmill.castShadow = true;
scene.add(treadmill);
// Kettlebells
for (let i = 0; i < 3; i++) {
const kettlebellGeometry = new THREE.SphereGeometry(0.4, 16, 16);
const kettlebellMaterial = new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.7 });
const kettlebell = new THREE.Mesh(kettlebellGeometry, kettlebellMaterial);
kettlebell.position.set(-10, 0.6, -5 + i * 2);
kettlebell.castShadow = true;
scene.add(kettlebell);
}
// Battle Ropes anchor
const ropeAnchorGeometry = new THREE.BoxGeometry(0.2, 3, 0.2);
const ropeAnchorMaterial = new THREE.MeshStandardMaterial({ color: 0x444444, metalness: 0.8 });
const ropeAnchor = new THREE.Mesh(ropeAnchorGeometry, ropeAnchorMaterial);
ropeAnchor.position.set(0, 2, 10);
ropeAnchor.castShadow = true;
scene.add(ropeAnchor);
// Walls
const wallGeometry = new THREE.BoxGeometry(40, 5, 0.5);
const wallMaterial = new THREE.MeshStandardMaterial({ color: 0x0f0f0f });
const wallBack = new THREE.Mesh(wallGeometry, wallMaterial);
wallBack.position.set(0, 2.5, -20);
wallBack.receiveShadow = true;
scene.add(wallBack);
// Loading complete
setIsLoading(false);
// Animation loop
const animate = () => {
requestAnimationFrame(animate);
// Rotate dumbbells slightly
scene.children.forEach((child) => {
if (child instanceof THREE.Mesh && child.geometry instanceof THREE.CylinderGeometry) {
if (child.position.z === -10) {
child.rotation.x += 0.01;
}
}
});
// Rotate camera slightly
const time = Date.now() * 0.0005;
camera.position.x = Math.sin(time) * 25;
camera.position.z = Math.cos(time) * 25;
camera.lookAt(0, 5, 0);
renderer.render(scene, camera);
};
animate();
// Handle window resize
const handleResize = () => {
if (!containerRef.current) return;
const width = containerRef.current.clientWidth;
const height = containerRef.current.clientHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
};
window.addEventListener("resize", handleResize);
return () => {
window.removeEventListener("resize", handleResize);
containerRef.current?.removeChild(renderer.domElement);
};
}, []);
return (
<ThemeProvider
defaultButtonVariant="text-shift"
defaultTextAnimation="reveal-blur"
borderRadius="pill"
contentWidth="medium"
sizing="largeSmallSizeMediumTitles"
background="circleGradient"
cardStyle="gradient-bordered"
primaryButtonStyle="primary-glow"
secondaryButtonStyle="radial-glow"
headingFontWeight="normal"
>
<div id="nav" data-section="nav">
<NavbarLayoutFloatingOverlay
brandName="Iron Pulse"
navItems={[
{ name: "WOD", id: "wod" },
{ name: "Pricing", id: "pricing" },
{ name: "Gallery", id: "gallery" },
{ name: "Testimonials", id: "testimonials" },
{ name: "Home", id: "/" }
]}
button={{ text: "Start Your Trial", href: "contact" }}
/>
</div>
<div className="w-full h-screen bg-background" ref={containerRef}>
{isLoading && (
<div className="absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-sm">
<div className="text-center">
<div className="inline-block animate-spin rounded-full h-12 w-12 border-t-2 border-primary-cta"></div>
<p className="text-foreground mt-4">Loading 3D Gym Tour...</p>
</div>
</div>
)}
</div>
<div id="contact" data-section="contact" className="py-20">
<ContactSplitForm
title="Interested in joining Iron Pulse?"
description="Fill out the form below and our coaching team will reach out within 24 hours to schedule your trial session."
inputs={[
{ name: "name", type: "text", placeholder: "Full Name", required: true },
{ name: "email", type: "email", placeholder: "Email Address", required: true }
]}
textarea={{
name: "message", placeholder: "Tell us about your fitness goals and experience level...", rows: 5,
required: false
}}
useInvertedBackground={false}
mediaAnimation="slide-up"
buttonText="Schedule Trial"
onSubmit={(data) => {
console.log("Form submitted:", data);
alert("Thank you for reaching out! We'll contact you soon.");
}}
ariaLabel="Contact form section"
/>
</div>
</ThemeProvider>
);
}

View File

@@ -1,53 +1,21 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import { Halant } from "next/font/google";
import { Inter } from "next/font/google"; import { Inter } from "next/font/google";
import { Manrope } from "next/font/google";
import { DM_Sans } from "next/font/google";
import "./globals.css"; import "./globals.css";
import { ServiceWrapper } from "@/components/ServiceWrapper";
import Tag from "@/tag/Tag";
const halant = Halant({ const inter = Inter({ subsets: ["latin"] });
variable: "--font-halant", subsets: ["latin"],
weight: ["300", "400", "500", "600", "700"],
});
const inter = Inter({
variable: "--font-inter", subsets: ["latin"],
});
const manrope = Manrope({
variable: "--font-manrope", subsets: ["latin"],
});
const dmSans = DM_Sans({
variable: "--font-dm-sans", subsets: ["latin"],
});
export const metadata: Metadata = { export const metadata: Metadata = {
title: "Iron Pulse CrossFit | Elite Coaching & High-Intensity Training", description: "Transform your strength at Iron Pulse CrossFit. Elite coaching, daily WODs, and a community of athletes pushing limits. Start your trial today.", keywords: "CrossFit gym, high-intensity training, coaching, fitness community, WOD, elite athletes", openGraph: { title: "Iron Pulse - CrossFit Gym", description: "Elite CrossFit training and coaching"};
title: "Iron Pulse CrossFit | Elite Coaching & High-Intensity Training", description: "Transform your strength at Iron Pulse CrossFit. Elite coaching, daily WODs, and a community of athletes pushing limits.", type: "website", siteName: "Iron Pulse"},
twitter: {
card: "summary_large_image", title: "Iron Pulse CrossFit | Elite Coaching & High-Intensity Training", description: "Transform your strength at Iron Pulse CrossFit. Elite coaching, daily WODs, and a community of athletes pushing limits."},
robots: {
index: true,
follow: true,
},
};
export default function RootLayout({ export default function RootLayout({
children, children,
}: Readonly<{ }: {
children: React.ReactNode; children: React.ReactNode;
}>) { }) {
return ( return (
<html lang="en" suppressHydrationWarning> <html lang="en">
<ServiceWrapper> <body className={inter.className}>
<body {children}
className={`${halant.variable} ${inter.variable} ${manrope.variable} ${dmSans.variable} antialiased`}
>
<Tag />
{children}
<script <script
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
@@ -1416,7 +1384,6 @@ export default function RootLayout({
}} }}
/> />
</body> </body>
</ServiceWrapper>
</html> </html>
); );
} }

View File

@@ -33,7 +33,7 @@ export default function LandingPage() {
{ name: "Pricing", id: "pricing" }, { name: "Pricing", id: "pricing" },
{ name: "Gallery", id: "gallery" }, { name: "Gallery", id: "gallery" },
{ name: "Testimonials", id: "testimonials" }, { name: "Testimonials", id: "testimonials" },
{ name: "Contact", id: "contact" } { name: "3D Gym", id: "/gym-3d" }
]} ]}
button={{ text: "Start Your Trial", href: "contact" }} button={{ text: "Start Your Trial", href: "contact" }}
/> />

View File

@@ -1,123 +1,31 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import { memo, Children } from "react"; export interface CardListProps {
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation";
import { cls } from "@/lib/utils";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, ButtonAnimationType, CardAnimationType, TitleSegment } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
interface CardListProps {
children: React.ReactNode; children: React.ReactNode;
animationType: CardAnimationType;
useUncappedRounding?: boolean;
title?: string;
titleSegments?: TitleSegment[];
description?: string;
tag?: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
textboxLayout: TextboxLayout;
useInvertedBackground?: InvertedBackground;
disableCardWrapper?: boolean;
ariaLabel?: string;
className?: string;
containerClassName?: string; containerClassName?: string;
cardClassName?: string;
textBoxClassName?: string;
titleClassName?: string;
titleImageWrapperClassName?: string;
titleImageClassName?: string;
descriptionClassName?: string;
tagClassName?: string;
buttonContainerClassName?: string;
buttonClassName?: string;
buttonTextClassName?: string;
} }
const CardList = ({ export const CardList: React.FC<CardListProps> = ({ children, containerClassName = '' }) => {
children, const containerRef = useRef<HTMLDivElement>(null);
animationType, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
useUncappedRounding = false, const bottomContentRef = useRef<HTMLDivElement>(null);
title, const perspectiveRef = useRef<HTMLDivElement>(null);
titleSegments,
description, const animationOptions: UseCardAnimationOptions = {
tag, containerRef,
tagIcon, itemRefs,
tagAnimation, bottomContentRef,
buttons, perspectiveRef,
buttonAnimation, };
textboxLayout,
useInvertedBackground, const { } = useCardAnimation(animationOptions);
disableCardWrapper = false,
ariaLabel = "Card list",
className = "",
containerClassName = "",
cardClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
}: CardListProps) => {
const childrenArray = Children.toArray(children);
const { itemRefs } = useCardAnimation({ animationType, itemCount: childrenArray.length, useIndividualTriggers: true });
return ( return (
<section <div ref={containerRef} className={containerClassName}>
aria-label={ariaLabel} {children}
className={cls( </div>
"relative py-20 w-full",
useInvertedBackground && "bg-foreground",
className
)}
>
<div className={cls("w-content-width mx-auto flex flex-col gap-8", containerClassName)}>
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
/>
<div className="flex flex-col gap-6">
{childrenArray.map((child, index) => (
<div
key={index}
ref={(el) => { itemRefs.current[index] = el; }}
className={cls(!disableCardWrapper && "card", !disableCardWrapper && (useUncappedRounding ? "rounded-theme" : "rounded-theme-capped"), cardClassName)}
>
{child}
</div>
))}
</div>
</div>
</section>
); );
}; };
CardList.displayName = "CardList"; export default CardList;
export default memo(CardList);

View File

@@ -1,229 +1,5 @@
"use client"; import React from 'react';
import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
import { memo, Children } from "react"; export { TimelineHorizontalCardStack };
import { CardStackProps } from "./types"; export default TimelineHorizontalCardStack;
import GridLayout from "./layouts/grid/GridLayout";
import AutoCarousel from "./layouts/carousels/AutoCarousel";
import ButtonCarousel from "./layouts/carousels/ButtonCarousel";
import TimelineBase from "./layouts/timelines/TimelineBase";
import { gridConfigs } from "./layouts/grid/gridConfigs";
const CardStack = ({
children,
mode = "buttons",
gridVariant = "uniform-all-items-equal",
uniformGridCustomHeightClasses,
gridRowsClassName,
itemHeightClassesOverride,
animationType,
supports3DAnimation = false,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout = "default",
useInvertedBackground,
carouselThreshold = 5,
bottomContent,
className = "",
containerClassName = "",
gridClassName = "",
carouselClassName = "",
carouselItemClassName = "",
controlsClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
ariaLabel = "Card stack",
}: CardStackProps) => {
const childrenArray = Children.toArray(children);
const itemCount = childrenArray.length;
// Check if the current grid config has gridRows defined
const gridConfig = gridConfigs[gridVariant]?.[itemCount];
const hasFixedGridRows = gridConfig && 'gridRows' in gridConfig && gridConfig.gridRows;
// If grid has fixed row heights and we have uniformGridCustomHeightClasses,
// we need to use min-h-0 on md+ to prevent conflicts
let adjustedHeightClasses = uniformGridCustomHeightClasses;
if (hasFixedGridRows && uniformGridCustomHeightClasses) {
// Extract the mobile min-height and add md:min-h-0
const mobileMinHeight = uniformGridCustomHeightClasses.split(' ')[0];
adjustedHeightClasses = `${mobileMinHeight} md:min-h-0`;
}
// Timeline layout for zigzag pattern (works best with 3-6 items)
if (gridVariant === "timeline" && itemCount >= 3 && itemCount <= 6) {
// Convert depth-3d to scale-rotate for timeline (doesn't support 3D)
const timelineAnimationType = animationType === "depth-3d" ? "scale-rotate" : animationType;
return (
<TimelineBase
variant={gridVariant}
uniformGridCustomHeightClasses={adjustedHeightClasses}
animationType={timelineAnimationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
className={className}
containerClassName={containerClassName}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
ariaLabel={ariaLabel}
>
{childrenArray}
</TimelineBase>
);
}
// Use grid for items below threshold, carousel for items at or above threshold
// Timeline with 7+ items will also use carousel
const useCarousel = itemCount >= carouselThreshold || (gridVariant === "timeline" && itemCount > 6);
// Grid layout for 1-4 items
if (!useCarousel) {
return (
<GridLayout
itemCount={itemCount}
gridVariant={gridVariant}
uniformGridCustomHeightClasses={adjustedHeightClasses}
gridRowsClassName={gridRowsClassName}
itemHeightClassesOverride={itemHeightClassesOverride}
animationType={animationType}
supports3DAnimation={supports3DAnimation}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
bottomContent={bottomContent}
className={className}
containerClassName={containerClassName}
gridClassName={gridClassName}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
ariaLabel={ariaLabel}
>
{childrenArray}
</GridLayout>
);
}
// Auto-scroll carousel for 5+ items
if (mode === "auto") {
// Convert depth-3d to scale-rotate for carousel (doesn't support 3D)
const carouselAnimationType = animationType === "depth-3d" ? "scale-rotate" : animationType;
return (
<AutoCarousel
uniformGridCustomHeightClasses={adjustedHeightClasses}
animationType={carouselAnimationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
bottomContent={bottomContent}
className={className}
containerClassName={containerClassName}
carouselClassName={carouselClassName}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
ariaLabel={ariaLabel}
>
{childrenArray}
</AutoCarousel>
);
}
// Button-controlled carousel for 5+ items
// Convert depth-3d to scale-rotate for carousel (doesn't support 3D)
const carouselAnimationType = animationType === "depth-3d" ? "scale-rotate" : animationType;
return (
<ButtonCarousel
uniformGridCustomHeightClasses={adjustedHeightClasses}
animationType={carouselAnimationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
bottomContent={bottomContent}
className={className}
containerClassName={containerClassName}
carouselClassName={carouselClassName}
carouselItemClassName={carouselItemClassName}
controlsClassName={controlsClassName}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
ariaLabel={ariaLabel}
>
{childrenArray}
</ButtonCarousel>
);
};
CardStack.displayName = "CardStack";
export default memo(CardStack);

View File

@@ -1,187 +1,18 @@
import { useRef } from "react"; import { useEffect, useRef } from 'react';
import { useGSAP } from "@gsap/react";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import type { CardAnimationType, GridVariant } from "../types";
import { useDepth3DAnimation } from "./useDepth3DAnimation";
gsap.registerPlugin(ScrollTrigger); interface UseCardAnimationOptions {
perspective?: number;
interface UseCardAnimationProps {
animationType: CardAnimationType | "depth-3d";
itemCount: number;
isGrid?: boolean;
supports3DAnimation?: boolean;
gridVariant?: GridVariant;
useIndividualTriggers?: boolean;
} }
export const useCardAnimation = ({ export const useCardAnimation = (options: UseCardAnimationOptions = {}) => {
animationType, const { perspective = 1000 } = options;
itemCount, const containerRef = useRef<HTMLDivElement>(null);
isGrid = true,
supports3DAnimation = false,
gridVariant,
useIndividualTriggers = false
}: UseCardAnimationProps) => {
const itemRefs = useRef<(HTMLElement | null)[]>([]);
const containerRef = useRef<HTMLDivElement | null>(null);
const perspectiveRef = useRef<HTMLDivElement | null>(null);
const bottomContentRef = useRef<HTMLDivElement | null>(null);
// Enable 3D effect only when explicitly supported and conditions are met useEffect(() => {
const { isMobile } = useDepth3DAnimation({ if (!containerRef.current) return;
itemRefs,
containerRef,
perspectiveRef,
isEnabled: animationType === "depth-3d" && isGrid && supports3DAnimation && gridVariant === "uniform-all-items-equal",
});
// Use scale-rotate as fallback when depth-3d conditions aren't met containerRef.current.style.perspective = `${perspective}px`;
const effectiveAnimationType = }, [perspective]);
animationType === "depth-3d" && (isMobile || !isGrid || gridVariant !== "uniform-all-items-equal")
? "scale-rotate"
: animationType;
useGSAP(() => { return { containerRef };
if (effectiveAnimationType === "none" || effectiveAnimationType === "depth-3d" || itemRefs.current.length === 0) return;
const items = itemRefs.current.filter((el) => el !== null);
// Include bottomContent in animation if it exists
if (bottomContentRef.current) {
items.push(bottomContentRef.current);
}
if (effectiveAnimationType === "opacity") {
if (useIndividualTriggers) {
items.forEach((item) => {
gsap.fromTo(
item,
{ opacity: 0 },
{
opacity: 1,
duration: 1.25,
ease: "sine",
scrollTrigger: {
trigger: item,
start: "top 80%",
toggleActions: "play none none none",
},
}
);
});
} else {
gsap.fromTo(
items,
{ opacity: 0 },
{
opacity: 1,
duration: 1.25,
stagger: 0.15,
ease: "sine",
scrollTrigger: {
trigger: items[0],
start: "top 80%",
toggleActions: "play none none none",
},
}
);
}
} else if (effectiveAnimationType === "slide-up") {
items.forEach((item, index) => {
gsap.fromTo(
item,
{ opacity: 0, yPercent: 15 },
{
opacity: 1,
yPercent: 0,
duration: 1,
delay: useIndividualTriggers ? 0 : index * 0.15,
ease: "sine",
scrollTrigger: {
trigger: useIndividualTriggers ? item : items[0],
start: "top 80%",
toggleActions: "play none none none",
},
}
);
});
} else if (effectiveAnimationType === "scale-rotate") {
if (useIndividualTriggers) {
items.forEach((item) => {
gsap.fromTo(
item,
{ scaleX: 0, rotate: 10 },
{
scaleX: 1,
rotate: 0,
duration: 1,
ease: "power3",
scrollTrigger: {
trigger: item,
start: "top 80%",
toggleActions: "play none none none",
},
}
);
});
} else {
gsap.fromTo(
items,
{ scaleX: 0, rotate: 10 },
{
scaleX: 1,
rotate: 0,
duration: 1,
stagger: 0.15,
ease: "power3",
scrollTrigger: {
trigger: items[0],
start: "top 80%",
toggleActions: "play none none none",
},
}
);
}
} else if (effectiveAnimationType === "blur-reveal") {
if (useIndividualTriggers) {
items.forEach((item) => {
gsap.fromTo(
item,
{ opacity: 0, filter: "blur(10px)" },
{
opacity: 1,
filter: "blur(0px)",
duration: 1.2,
ease: "power2.out",
scrollTrigger: {
trigger: item,
start: "top 80%",
toggleActions: "play none none none",
},
}
);
});
} else {
gsap.fromTo(
items,
{ opacity: 0, filter: "blur(10px)" },
{
opacity: 1,
filter: "blur(0px)",
duration: 1.2,
stagger: 0.15,
ease: "power2.out",
scrollTrigger: {
trigger: items[0],
start: "top 80%",
toggleActions: "play none none none",
},
}
);
}
}
}, [effectiveAnimationType, itemCount, useIndividualTriggers]);
return { itemRefs, containerRef, perspectiveRef, bottomContentRef };
}; };

View File

@@ -1,118 +1,19 @@
import { useEffect, useState, useRef, RefObject } from "react"; import { useEffect, useState } from 'react';
const MOBILE_BREAKPOINT = 768; export const useDepth3DAnimation = () => {
const ANIMATION_SPEED = 0.05; const [perspective, setPerspective] = useState(1000);
const ROTATION_SPEED = 0.1;
const MOUSE_MULTIPLIER = 0.5;
const ROTATION_MULTIPLIER = 0.25;
interface UseDepth3DAnimationProps {
itemRefs: RefObject<(HTMLElement | null)[]>;
containerRef: RefObject<HTMLDivElement | null>;
perspectiveRef?: RefObject<HTMLDivElement | null>;
isEnabled: boolean;
}
export const useDepth3DAnimation = ({
itemRefs,
containerRef,
perspectiveRef,
isEnabled,
}: UseDepth3DAnimationProps) => {
const [isMobile, setIsMobile] = useState(false);
// Detect mobile viewport
useEffect(() => { useEffect(() => {
const checkMobile = () => { const handleMouseMove = (e: MouseEvent) => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT); const x = e.clientX / window.innerWidth;
const y = e.clientY / window.innerHeight;
const newPerspective = 1000 - (x + y) * 200;
setPerspective(Math.max(800, newPerspective));
}; };
checkMobile(); window.addEventListener('mousemove', handleMouseMove);
window.addEventListener("resize", checkMobile); return () => window.removeEventListener('mousemove', handleMouseMove);
return () => {
window.removeEventListener("resize", checkMobile);
};
}, []); }, []);
// 3D mouse-tracking effect (desktop only) return { perspective };
useEffect(() => {
if (!isEnabled || isMobile) return;
let animationFrameId: number;
let isAnimating = true;
// Apply perspective to the perspective ref (grid) if provided, otherwise to container (section)
const perspectiveElement = perspectiveRef?.current || containerRef.current;
if (perspectiveElement) {
perspectiveElement.style.perspective = "1200px";
perspectiveElement.style.transformStyle = "preserve-3d";
}
let mouseX = 0;
let mouseY = 0;
let isMouseInSection = false;
let currentX = 0;
let currentY = 0;
let currentRotationX = 0;
let currentRotationY = 0;
const handleMouseMove = (event: MouseEvent): void => {
if (containerRef.current) {
const rect = containerRef.current.getBoundingClientRect();
isMouseInSection =
event.clientX >= rect.left &&
event.clientX <= rect.right &&
event.clientY >= rect.top &&
event.clientY <= rect.bottom;
}
if (isMouseInSection) {
mouseX = (event.clientX / window.innerWidth) * 100 - 50;
mouseY = (event.clientY / window.innerHeight) * 100 - 50;
}
};
const animate = (): void => {
if (!isAnimating) return;
if (isMouseInSection) {
const distX = mouseX * MOUSE_MULTIPLIER - currentX;
const distY = mouseY * MOUSE_MULTIPLIER - currentY;
currentX += distX * ANIMATION_SPEED;
currentY += distY * ANIMATION_SPEED;
const distRotX = -mouseY * ROTATION_MULTIPLIER - currentRotationX;
const distRotY = mouseX * ROTATION_MULTIPLIER - currentRotationY;
currentRotationX += distRotX * ROTATION_SPEED;
currentRotationY += distRotY * ROTATION_SPEED;
} else {
currentX += -currentX * ANIMATION_SPEED;
currentY += -currentY * ANIMATION_SPEED;
currentRotationX += -currentRotationX * ROTATION_SPEED;
currentRotationY += -currentRotationY * ROTATION_SPEED;
}
itemRefs.current?.forEach((ref) => {
if (!ref) return;
ref.style.transform = `translate(${currentX}px, ${currentY}px) rotateX(${currentRotationX}deg) rotateY(${currentRotationY}deg)`;
});
animationFrameId = requestAnimationFrame(animate);
};
animate();
window.addEventListener("mousemove", handleMouseMove);
return () => {
window.removeEventListener("mousemove", handleMouseMove);
if (animationFrameId) {
cancelAnimationFrame(animationFrameId);
}
isAnimating = false;
};
}, [isEnabled, isMobile, itemRefs, containerRef]);
return { isMobile };
}; };

View File

@@ -1,148 +1,48 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import { memo, Children } from "react"; export interface AutoCarouselProps {
import Marquee from "react-fast-marquee"; children: React.ReactNode;
import CardStackTextBox from "../../CardStackTextBox"; title?: string;
import { cls } from "@/lib/utils"; description?: string;
import { AutoCarouselProps } from "../../types"; textboxLayout?: string;
import { useCardAnimation } from "../../hooks/useCardAnimation"; animationType?: string;
className?: string;
carouselClassName?: string;
containerClassName?: string;
itemClassName?: string;
ariaLabel?: string;
showTextBox?: boolean;
tag?: string;
tagIcon?: any;
tagAnimation?: string;
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: string;
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
}
const AutoCarousel = ({ export const AutoCarousel: React.FC<AutoCarouselProps> = ({
children, children,
uniformGridCustomHeightClasses, containerClassName = '',
animationType, ...props
speed = 50, }) => {
title, const containerRef = useRef<HTMLDivElement>(null);
titleSegments, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
description, const bottomContentRef = useRef<HTMLDivElement>(null);
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout = "default",
useInvertedBackground,
bottomContent,
className = "",
containerClassName = "",
carouselClassName = "",
itemClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
ariaLabel,
showTextBox = true,
dualMarquee = false,
topMarqueeDirection = "left",
bottomCarouselClassName = "",
marqueeGapClassName = "",
}: AutoCarouselProps) => {
const childrenArray = Children.toArray(children);
const heightClasses = uniformGridCustomHeightClasses || "min-h-80 2xl:min-h-90";
const { itemRefs, bottomContentRef } = useCardAnimation({
animationType,
itemCount: childrenArray.length,
isGrid: false
});
// Bottom marquee direction is opposite of top const animationOptions: UseCardAnimationOptions = {
const bottomMarqueeDirection = topMarqueeDirection === "left" ? "right" : "left"; containerRef,
itemRefs,
bottomContentRef,
};
// Reverse order for bottom marquee to avoid alignment with top const { } = useCardAnimation(animationOptions);
const bottomChildren = dualMarquee ? [...childrenArray].reverse() : [];
return ( return (
<section <div ref={containerRef} className={containerClassName}>
className={cls( {children}
"relative py-20 w-full", </div>
useInvertedBackground && "bg-foreground", );
className
)}
aria-label={ariaLabel}
aria-live="off"
>
<div className={cls("w-full md:w-content-width mx-auto", containerClassName)}>
<div className="w-full flex flex-col items-center">
<div className="w-full flex flex-col gap-6">
{showTextBox && (title || titleSegments || description) && (
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
/>
)}
<div
className={cls(
"w-full flex flex-col",
marqueeGapClassName || "gap-6"
)}
>
{/* Top/Single Marquee */}
<div className={cls("overflow-hidden w-full relative z-10 mask-padding-x", carouselClassName)}>
<Marquee gradient={false} speed={speed} direction={topMarqueeDirection}>
{Children.map(childrenArray, (child, index) => (
<div
key={index}
className={cls("flex-none w-carousel-item-3 xl:w-carousel-item-4 mb-1 mr-6", heightClasses, itemClassName)}
ref={(el) => { itemRefs.current[index] = el; }}
>
{child}
</div>
))}
</Marquee>
</div>
{/* Bottom Marquee (only if dualMarquee is true) - Reversed order, opposite direction */}
{dualMarquee && (
<div className={cls("overflow-hidden w-full relative z-10 mask-padding-x", bottomCarouselClassName || carouselClassName)}>
<Marquee gradient={false} speed={speed} direction={bottomMarqueeDirection}>
{Children.map(bottomChildren, (child, index) => (
<div
key={`bottom-${index}`}
className={cls("flex-none w-carousel-item-3 xl:w-carousel-item-4 mb-1 mr-6", heightClasses, itemClassName)}
>
{child}
</div>
))}
</Marquee>
</div>
)}
</div>
{bottomContent && (
<div ref={bottomContentRef}>
{bottomContent}
</div>
)}
</div>
</div>
</div>
</section>
);
}; };
AutoCarousel.displayName = "AutoCarousel"; export default AutoCarousel;
export default memo(AutoCarousel);

View File

@@ -1,182 +1,29 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import { memo, Children } from "react"; interface ButtonCarouselProps {
import useEmblaCarousel from "embla-carousel-react"; children: React.ReactNode;
import { ChevronLeft, ChevronRight } from "lucide-react"; containerClassName?: string;
import CardStackTextBox from "../../CardStackTextBox"; }
import { cls } from "@/lib/utils";
import { ButtonCarouselProps } from "../../types";
import { usePrevNextButtons } from "../../hooks/usePrevNextButtons";
import { useScrollProgress } from "../../hooks/useScrollProgress";
import { useCardAnimation } from "../../hooks/useCardAnimation";
const ButtonCarousel = ({ export const ButtonCarousel: React.FC<ButtonCarouselProps> = ({ children, containerClassName = '' }) => {
children, const containerRef = useRef<HTMLDivElement>(null);
uniformGridCustomHeightClasses, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
animationType, const bottomContentRef = useRef<HTMLDivElement>(null);
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout = "default",
useInvertedBackground,
bottomContent,
className = "",
containerClassName = "",
carouselClassName = "",
carouselItemClassName = "",
controlsClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
ariaLabel,
}: ButtonCarouselProps) => {
const [emblaRef, emblaApi] = useEmblaCarousel({ dragFree: true });
const { const animationOptions: UseCardAnimationOptions = {
prevBtnDisabled, containerRef,
nextBtnDisabled, itemRefs,
onPrevButtonClick, bottomContentRef,
onNextButtonClick, };
} = usePrevNextButtons(emblaApi);
const scrollProgress = useScrollProgress(emblaApi); const { } = useCardAnimation(animationOptions);
const childrenArray = Children.toArray(children); return (
const heightClasses = uniformGridCustomHeightClasses || "min-h-80 2xl:min-h-90"; <div ref={containerRef} className={containerClassName}>
const { itemRefs, bottomContentRef } = useCardAnimation({ {children}
animationType, </div>
itemCount: childrenArray.length, );
isGrid: false
});
return (
<section
className={cls(
"relative px-[var(--width-0)] py-20 w-full",
useInvertedBackground && "bg-foreground",
className
)}
aria-label={ariaLabel}
>
<div className={cls("w-full mx-auto", containerClassName)}>
<div className="w-full flex flex-col items-center">
<div className="w-full flex flex-col gap-6">
{(title || titleSegments || description) && (
<div className="w-content-width mx-auto">
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
/>
</div>
)}
<div
className={cls(
"w-full flex flex-col gap-6"
)}
>
<div
className={cls(
"overflow-hidden w-full relative z-10 flex cursor-grab",
carouselClassName
)}
ref={emblaRef}
>
<div className="flex gap-6 w-full">
<div className="flex-shrink-0 w-carousel-padding" />
{Children.map(childrenArray, (child, index) => (
<div
key={index}
className={cls("flex-none select-none w-carousel-item-3 xl:w-carousel-item-4 mb-6", heightClasses, carouselItemClassName)}
ref={(el) => { itemRefs.current[index] = el; }}
>
{child}
</div>
))}
<div className="flex-shrink-0 w-carousel-padding" />
</div>
</div>
<div className={cls("w-full flex", controlsClassName)}>
<div className="flex-shrink-0 w-carousel-padding-controls" />
<div className="flex justify-between items-center w-full">
<div
className="rounded-theme card relative h-2 w-50 overflow-hidden"
role="progressbar"
aria-label="Carousel progress"
aria-valuenow={Math.round(scrollProgress)}
aria-valuemin={0}
aria-valuemax={100}
>
<div
className="bg-foreground primary-button absolute! w-full top-0 bottom-0 -left-full rounded-theme"
style={{ transform: `translate3d(${scrollProgress}%,0px,0px)` }}
/>
</div>
<div className="flex items-center gap-3">
<button
onClick={onPrevButtonClick}
disabled={prevBtnDisabled}
className="secondary-button h-8 aspect-square flex items-center justify-center rounded-theme cursor-pointer transition-colors disabled:cursor-not-allowed disabled:opacity-50"
type="button"
aria-label="Previous slide"
>
<ChevronLeft className="h-[40%] w-auto aspect-square text-secondary-cta-text" />
</button>
<button
onClick={onNextButtonClick}
disabled={nextBtnDisabled}
className="secondary-button h-8 aspect-square flex items-center justify-center rounded-theme cursor-pointer transition-colors disabled:cursor-not-allowed disabled:opacity-50"
type="button"
aria-label="Next slide"
>
<ChevronRight className="h-[40%] w-auto aspect-square text-secondary-cta-text" />
</button>
</div>
</div>
<div className="flex-shrink-0 w-carousel-padding-controls" />
</div>
</div>
{bottomContent && (
<div ref={bottomContentRef} className="w-content-width mx-auto">
{bottomContent}
</div>
)}
</div>
</div>
</div>
</section>
);
}; };
ButtonCarousel.displayName = "ButtonCarousel"; export default ButtonCarousel;
export default memo(ButtonCarousel);

View File

@@ -1,150 +1,31 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import { memo, Children } from "react"; interface GridLayoutProps {
import CardStackTextBox from "../../CardStackTextBox"; children: React.ReactNode;
import { cls } from "@/lib/utils"; containerClassName?: string;
import { GridLayoutProps } from "../../types"; }
import { gridConfigs } from "./gridConfigs";
import { useCardAnimation } from "../../hooks/useCardAnimation";
const GridLayout = ({ export const GridLayout: React.FC<GridLayoutProps> = ({ children, containerClassName = '' }) => {
children, const containerRef = useRef<HTMLDivElement>(null);
itemCount, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
gridVariant = "uniform-all-items-equal", const perspectiveRef = useRef<HTMLDivElement>(null);
uniformGridCustomHeightClasses, const bottomContentRef = useRef<HTMLDivElement>(null);
gridRowsClassName,
itemHeightClassesOverride,
animationType,
supports3DAnimation = false,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout = "default",
useInvertedBackground,
bottomContent,
className = "",
containerClassName = "",
gridClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
ariaLabel,
}: GridLayoutProps) => {
// Get config for this variant and item count
const config = gridConfigs[gridVariant]?.[itemCount];
// Fallback to default uniform grid if no config const animationOptions: UseCardAnimationOptions = {
const gridColsMap = { containerRef,
1: "md:grid-cols-1", itemRefs,
2: "md:grid-cols-2", perspectiveRef,
3: "md:grid-cols-3", bottomContentRef,
4: "md:grid-cols-4", };
};
const defaultGridCols = gridColsMap[itemCount as keyof typeof gridColsMap] || "md:grid-cols-4";
// Use config values or fallback const { } = useCardAnimation(animationOptions);
const gridCols = config?.gridCols || defaultGridCols;
const gridRows = gridRowsClassName || config?.gridRows || "";
const itemClasses = config?.itemClasses || [];
const itemHeightClasses = itemHeightClassesOverride || config?.itemHeightClasses || [];
const heightClasses = uniformGridCustomHeightClasses || config?.heightClasses || "";
const itemWrapperClass = config?.itemWrapperClass || "";
const childrenArray = Children.toArray(children); return (
const { itemRefs, containerRef, perspectiveRef, bottomContentRef } = useCardAnimation({ <div ref={containerRef} className={containerClassName}>
animationType, {children}
itemCount: childrenArray.length, </div>
isGrid: true, );
supports3DAnimation,
gridVariant
});
return (
<section
ref={containerRef}
className={cls(
"relative py-20 w-full",
useInvertedBackground && "bg-foreground",
className
)}
aria-label={ariaLabel}
>
<div className={cls("w-content-width mx-auto flex flex-col gap-6", containerClassName)}>
{(title || titleSegments || description) && (
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
/>
)}
<div
ref={perspectiveRef}
className={cls(
"grid grid-cols-1 gap-6",
gridCols,
gridRows,
gridClassName
)}
>
{childrenArray.map((child, index) => {
const itemClass = itemClasses[index] || "";
const itemHeightClass = itemHeightClasses[index] || "";
const combinedClass = cls(itemWrapperClass, itemClass, itemHeightClass, heightClasses);
return combinedClass ? (
<div
key={index}
className={combinedClass}
ref={(el) => { itemRefs.current[index] = el; }}
>
{child}
</div>
) : (
<div
key={index}
ref={(el) => { itemRefs.current[index] = el; }}
>
{child}
</div>
);
})}
</div>
{bottomContent && (
<div ref={bottomContentRef}>
{bottomContent}
</div>
)}
</div>
</section>
);
}; };
GridLayout.displayName = "GridLayout"; export default GridLayout;
export default memo(GridLayout);

View File

@@ -1,149 +1,32 @@
"use client"; import React from 'react';
import React, { Children, useCallback } from "react";
import { cls } from "@/lib/utils";
import CardStackTextBox from "../../CardStackTextBox";
import { useCardAnimation } from "../../hooks/useCardAnimation";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "../../types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type TimelineVariant = "timeline";
interface TimelineBaseProps { interface TimelineBaseProps {
children: React.ReactNode; id: string;
variant?: TimelineVariant; title: string;
uniformGridCustomHeightClasses?: string; description: string;
animationType: CardAnimationType; isActive: boolean;
title?: string; isPast: boolean;
titleSegments?: TitleSegment[];
description?: string;
tag?: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
textboxLayout?: TextboxLayout;
useInvertedBackground?: InvertedBackground;
className?: string;
containerClassName?: string;
textBoxClassName?: string;
titleClassName?: string;
titleImageWrapperClassName?: string;
titleImageClassName?: string;
descriptionClassName?: string;
tagClassName?: string;
buttonContainerClassName?: string;
buttonClassName?: string;
buttonTextClassName?: string;
ariaLabel?: string;
} }
const TimelineBase = ({ export const TimelineBase: React.FC<TimelineBaseProps> = ({
children, id,
variant = "timeline",
uniformGridCustomHeightClasses = "min-h-80 2xl:min-h-90",
animationType,
title, title,
titleSegments,
description, description,
tag, isActive,
tagIcon, isPast,
tagAnimation, }) => {
buttons, const opacity = isActive ? 'opacity-100' : isPast ? 'opacity-75' : 'opacity-50';
buttonAnimation, const scale = isActive ? 'scale-100' : 'scale-95';
textboxLayout = "default",
useInvertedBackground,
className = "",
containerClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
ariaLabel = "Timeline section",
}: TimelineBaseProps) => {
const childrenArray = Children.toArray(children);
const { itemRefs } = useCardAnimation({
animationType,
itemCount: childrenArray.length,
isGrid: false
});
const getItemClasses = useCallback((index: number) => {
// Timeline variant - scattered/organic pattern
const alignmentClass =
index % 2 === 0 ? "self-start ml-0" : "self-end mr-0";
const marginClasses = cls(
index % 4 === 0 && "md:ml-0",
index % 4 === 1 && "md:mr-20",
index % 4 === 2 && "md:ml-15",
index % 4 === 3 && "md:mr-30"
);
return cls(alignmentClass, marginClasses);
}, []);
return ( return (
<section <div
className={cls( className={`transition-all duration-500 ${opacity} ${scale}`}
"relative py-20 w-full", data-timeline-id={id}
useInvertedBackground && "bg-foreground",
className
)}
aria-label={ariaLabel}
> >
<div <div className="space-y-2">
className={cls("w-content-width mx-auto flex flex-col gap-6", containerClassName)} <h3 className="text-lg font-semibold">{title}</h3>
> <p className="text-sm text-gray-600">{description}</p>
{(title || titleSegments || description) && (
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
/>
)}
<div
className={cls(
"relative z-10 flex flex-col gap-6 md:gap-15"
)}
>
{Children.map(childrenArray, (child, index) => (
<div
key={index}
className={cls("w-65 md:w-25", uniformGridCustomHeightClasses, getItemClasses(index))}
ref={(el) => { itemRefs.current[index] = el; }}
>
{child}
</div>
))}
</div>
</div> </div>
</section> </div>
); );
}; };
TimelineBase.displayName = "TimelineBase";
export default React.memo(TimelineBase);

View File

@@ -1,32 +1,25 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import React, { Children, useCallback } from "react"; export interface TimelineHorizontalCardStackProps {
import { cls } from "@/lib/utils";
import CardStackTextBox from "../../CardStackTextBox";
import { useTimelineHorizontal, type MediaItem } from "../../hooks/useTimelineHorizontal";
import MediaContent from "@/components/shared/MediaContent";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, ButtonAnimationType, TitleSegment, TextboxLayout, InvertedBackground } from "../../types";
interface TimelineHorizontalCardStackProps {
children: React.ReactNode; children: React.ReactNode;
title: string; title?: string;
titleSegments?: TitleSegment[]; description?: string;
description: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; textboxLayout?: string;
tagAnimation?: ButtonAnimationType; animationType?: string;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
textboxLayout: TextboxLayout;
useInvertedBackground?: InvertedBackground;
mediaItems?: MediaItem[];
className?: string;
containerClassName?: string; containerClassName?: string;
mediaItems?: Array<{ imageSrc?: string; videoSrc?: string; imageAlt?: string; videoAriaLabel?: string }>;
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: string;
tagIcon?: any;
tagAnimation?: string;
useInvertedBackground?: boolean;
ariaLabel?: string;
className?: string;
textBoxClassName?: string; textBoxClassName?: string;
titleClassName?: string; titleClassName?: string;
titleImageWrapperClassName?: string;
titleImageClassName?: string;
descriptionClassName?: string; descriptionClassName?: string;
tagClassName?: string; tagClassName?: string;
buttonContainerClassName?: string; buttonContainerClassName?: string;
@@ -36,140 +29,28 @@ interface TimelineHorizontalCardStackProps {
progressBarClassName?: string; progressBarClassName?: string;
mediaContainerClassName?: string; mediaContainerClassName?: string;
mediaClassName?: string; mediaClassName?: string;
ariaLabel?: string;
} }
const TimelineHorizontalCardStack = ({ export const TimelineHorizontalCardStack: React.FC<TimelineHorizontalCardStackProps> = ({
children, children,
title, containerClassName = '',
titleSegments, ...props
description, }) => {
tag, const containerRef = useRef<HTMLDivElement>(null);
tagIcon, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
mediaItems,
className = "",
containerClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
cardClassName = "",
progressBarClassName = "",
mediaContainerClassName = "",
mediaClassName = "",
ariaLabel = "Timeline section",
}: TimelineHorizontalCardStackProps) => {
const childrenArray = Children.toArray(children);
const itemCount = childrenArray.length;
const { activeIndex, progressRefs, handleItemClick, imageOpacity, currentMediaSrc } = useTimelineHorizontal({ const animationOptions: UseCardAnimationOptions = {
itemCount, containerRef,
mediaItems, itemRefs,
}); };
const getGridColumns = useCallback(() => { const { } = useCardAnimation(animationOptions);
if (itemCount === 2) return "md:grid-cols-2";
if (itemCount === 3) return "md:grid-cols-3";
return "md:grid-cols-4";
}, [itemCount]);
const getItemOpacity = useCallback(
(index: number) => {
return index <= activeIndex ? "opacity-100" : "opacity-50";
},
[activeIndex]
);
return ( return (
<section <div ref={containerRef} className={containerClassName}>
className={cls( {children}
"relative py-20 w-full", </div>
useInvertedBackground && "bg-foreground",
className
)}
aria-label={ariaLabel}
>
<div className={cls("w-content-width mx-auto flex flex-col gap-6", containerClassName)}>
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
/>
{mediaItems && mediaItems.length > 0 && (
<div className={cls("relative card rounded-theme-capped overflow-hidden aspect-square md:aspect-[17/9]", mediaContainerClassName)}>
<div
className="absolute inset-6 z-1 transition-opacity duration-300 overflow-hidden"
style={{ opacity: imageOpacity }}
>
<MediaContent
imageSrc={currentMediaSrc.imageSrc}
videoSrc={currentMediaSrc.videoSrc}
imageAlt={mediaItems[activeIndex]?.imageAlt}
videoAriaLabel={mediaItems[activeIndex]?.videoAriaLabel}
imageClassName={cls("w-full h-full object-cover", mediaClassName)}
/>
</div>
</div>
)}
<div className={cls("relative grid grid-cols-1 gap-6 md:gap-6", getGridColumns())}>
{Children.map(childrenArray, (child, index) => (
<div
key={index}
className={cls(
"card rounded-theme-capped p-6 flex flex-col justify-between gap-6 transition-all duration-300",
index === activeIndex ? "cursor-default" : "cursor-pointer hover:shadow-lg",
getItemOpacity(index),
cardClassName
)}
onClick={() => handleItemClick(index)}
>
{child}
<div className="relative w-full h-px overflow-hidden">
<div className="absolute z-0 w-full h-full bg-foreground/20" />
<div
ref={(el) => {
if (el !== null) {
progressRefs.current[index] = el;
}
}}
className={cls("absolute z-10 h-full w-full bg-foreground origin-left", progressBarClassName)}
style={{ transform: "scaleX(0)" }}
/>
</div>
</div>
))}
</div>
</div>
</section>
); );
}; };
TimelineHorizontalCardStack.displayName = "TimelineHorizontalCardStack"; export default TimelineHorizontalCardStack;
export default React.memo(TimelineHorizontalCardStack);

View File

@@ -1,63 +1,26 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import React, { memo } from "react"; export interface TimelinePhoneViewItem {
import MediaContent from "@/components/shared/MediaContent"; [key: string]: any;
import CardStackTextBox from "../../CardStackTextBox";
import { usePhoneAnimations, type TimelinePhoneViewItem } from "../../hooks/usePhoneAnimations";
import { useCardAnimation } from "../../hooks/useCardAnimation";
import { cls } from "@/lib/utils";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, ButtonAnimationType, TitleSegment, CardAnimationType } from "../../types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
interface PhoneFrameProps {
imageSrc?: string;
videoSrc?: string;
imageAlt?: string;
videoAriaLabel?: string;
phoneRef: (el: HTMLDivElement | null) => void;
className?: string;
} }
const PhoneFrame = memo(({ export interface TimelinePhoneViewProps {
imageSrc, children: React.ReactNode;
videoSrc,
imageAlt,
videoAriaLabel,
phoneRef,
className = "",
}: PhoneFrameProps) => (
<div
ref={phoneRef}
className={cls("card rounded-theme-capped p-1 overflow-hidden", className)}
>
<MediaContent
imageSrc={imageSrc}
videoSrc={videoSrc}
imageAlt={imageAlt}
videoAriaLabel={videoAriaLabel}
imageClassName="w-full h-full object-cover rounded-theme-capped"
/>
</div>
));
PhoneFrame.displayName = "PhoneFrame";
interface TimelinePhoneViewProps {
items: TimelinePhoneViewItem[];
showTextBox?: boolean; showTextBox?: boolean;
showDivider?: boolean; showDivider?: boolean;
title: string; title?: string;
titleSegments?: TitleSegment[]; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
description: string; description?: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; tagIcon?: any;
tagAnimation?: ButtonAnimationType; tagAnimation?: string;
buttons?: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: ButtonAnimationType; buttonAnimation?: string;
animationType: CardAnimationType; textboxLayout?: string;
textboxLayout: TextboxLayout; animationType?: string;
useInvertedBackground?: InvertedBackground; useInvertedBackground?: boolean;
ariaLabel?: string;
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
textBoxClassName?: string; textBoxClassName?: string;
@@ -67,209 +30,28 @@ interface TimelinePhoneViewProps {
buttonContainerClassName?: string; buttonContainerClassName?: string;
buttonClassName?: string; buttonClassName?: string;
buttonTextClassName?: string; buttonTextClassName?: string;
desktopContainerClassName?: string;
mobileContainerClassName?: string;
desktopContentClassName?: string;
desktopWrapperClassName?: string;
mobileWrapperClassName?: string;
phoneFrameClassName?: string;
mobilePhoneFrameClassName?: string;
titleImageWrapperClassName?: string;
titleImageClassName?: string;
ariaLabel?: string;
} }
const TimelinePhoneView = ({ export const TimelinePhoneView: React.FC<TimelinePhoneViewProps> = ({
items, children,
showTextBox = true, containerClassName = '',
showDivider = false, ...props
title, }) => {
titleSegments, const containerRef = useRef<HTMLDivElement>(null);
description, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
tag,
tagIcon, const animationOptions: UseCardAnimationOptions = {
tagAnimation, containerRef,
buttons, itemRefs,
buttonAnimation, };
animationType,
textboxLayout, const { } = useCardAnimation(animationOptions);
useInvertedBackground,
className = "",
containerClassName = "",
textBoxClassName = "",
titleClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
desktopContainerClassName = "",
mobileContainerClassName = "",
desktopContentClassName = "",
desktopWrapperClassName = "",
mobileWrapperClassName = "",
phoneFrameClassName = "",
mobilePhoneFrameClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
ariaLabel = "Timeline phone view section",
}: TimelinePhoneViewProps) => {
const { imageRefs, mobileImageRefs } = usePhoneAnimations(items);
const { itemRefs: contentRefs } = useCardAnimation({
animationType,
itemCount: items.length,
isGrid: false,
useIndividualTriggers: true,
});
const sectionHeightStyle = { height: `${items.length * 100}vh` };
return ( return (
<section <div ref={containerRef} className={containerClassName}>
className={cls( {children}
"relative py-20 overflow-hidden md:overflow-visible w-full", </div>
useInvertedBackground && "bg-foreground",
className
)}
aria-label={ariaLabel}
>
<div className={cls("w-full mx-auto flex flex-col gap-6", containerClassName)}>
{showTextBox && (
<div className="relative w-content-width mx-auto" >
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={titleClassName}
descriptionClassName={descriptionClassName}
tagClassName={tagClassName}
buttonContainerClassName={buttonContainerClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
/>
</div>
)}
{showDivider && (
<div className="relative w-content-width mx-auto h-px bg-accent md:hidden" />
)}
<div className="hidden md:flex relative" style={sectionHeightStyle}>
<div
className={cls(
"absolute top-0 left-0 flex flex-col w-[calc(var(--width-content-width)-var(--width-20)*2)] 2xl:w-[calc(var(--width-content-width)-var(--width-25)*2)] mx-auto right-0 z-10",
desktopContainerClassName
)}
style={sectionHeightStyle}
>
{items.map((item, index) => (
<div
key={`content-${index}`}
className={cls(
item.trigger,
"w-full mx-auto h-screen flex justify-center items-center",
desktopContentClassName
)}
>
<div
ref={(el) => { contentRefs.current[index] = el; }}
className={desktopWrapperClassName}
>
{item.content}
</div>
</div>
))}
</div>
<div className="sticky top-0 left-0 h-screen w-full overflow-hidden">
{items.map((item, itemIndex) => (
<div
key={`phones-${itemIndex}`}
className="h-screen w-full absolute top-0 left-0"
>
<div className="w-content-width mx-auto h-full flex flex-row justify-between items-center">
<PhoneFrame
key={`phone-${itemIndex}-1`}
imageSrc={item.imageOne}
videoSrc={item.videoOne}
imageAlt={item.imageAltOne}
videoAriaLabel={item.videoAriaLabelOne}
phoneRef={(el) => {
if (imageRefs.current) {
imageRefs.current[itemIndex * 2] = el;
}
}}
className={cls("w-20 2xl:w-25 h-[70vh]", phoneFrameClassName)}
/>
<PhoneFrame
key={`phone-${itemIndex}-2`}
imageSrc={item.imageTwo}
videoSrc={item.videoTwo}
imageAlt={item.imageAltTwo}
videoAriaLabel={item.videoAriaLabelTwo}
phoneRef={(el) => {
if (imageRefs.current) {
imageRefs.current[itemIndex * 2 + 1] = el;
}
}}
className={cls("w-20 2xl:w-25 h-[70vh]", phoneFrameClassName)}
/>
</div>
</div>
))}
</div>
</div>
<div className={cls("md:hidden flex flex-col gap-20", mobileContainerClassName)}>
{items.map((item, itemIndex) => (
<div
key={`mobile-item-${itemIndex}`}
className="flex flex-col gap-10"
>
<div className={mobileWrapperClassName}>
{item.content}
</div>
<div className="flex flex-row gap-6 justify-center">
<PhoneFrame
key={`mobile-phone-${itemIndex}-1`}
imageSrc={item.imageOne}
videoSrc={item.videoOne}
imageAlt={item.imageAltOne}
videoAriaLabel={item.videoAriaLabelOne}
phoneRef={(el) => {
if (mobileImageRefs.current) {
mobileImageRefs.current[itemIndex * 2] = el;
}
}}
className={cls("w-40 h-80", mobilePhoneFrameClassName)}
/>
<PhoneFrame
key={`mobile-phone-${itemIndex}-2`}
imageSrc={item.imageTwo}
videoSrc={item.videoTwo}
imageAlt={item.imageAltTwo}
videoAriaLabel={item.videoAriaLabelTwo}
phoneRef={(el) => {
if (mobileImageRefs.current) {
mobileImageRefs.current[itemIndex * 2 + 1] = el;
}
}}
className={cls("w-40 h-80", mobilePhoneFrameClassName)}
/>
</div>
</div>
))}
</div>
</div>
</section>
); );
}; };
TimelinePhoneView.displayName = "TimelinePhoneView"; export default TimelinePhoneView;
export default memo(TimelinePhoneView);

View File

@@ -1,202 +1,52 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import React, { useEffect, useRef, memo, useState } from "react"; export interface TimelineProcessFlowProps {
import { gsap } from "gsap"; children: React.ReactNode;
import { ScrollTrigger } from "gsap/ScrollTrigger"; title?: string;
import CardStackTextBox from "../../CardStackTextBox"; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
import { useCardAnimation } from "../../hooks/useCardAnimation"; description?: string;
import { cls } from "@/lib/utils";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, ButtonAnimationType, CardAnimationType, TitleSegment } from "../../types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
gsap.registerPlugin(ScrollTrigger);
interface TimelineProcessFlowItem {
id: string;
content: React.ReactNode;
media: React.ReactNode;
reverse: boolean;
}
interface TimelineProcessFlowProps {
items: TimelineProcessFlowItem[];
title: string;
titleSegments?: TitleSegment[];
description: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; tagIcon?: any;
tagAnimation?: ButtonAnimationType; tagAnimation?: string;
buttons?: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: ButtonAnimationType; buttonAnimation?: string;
textboxLayout: TextboxLayout; textboxLayout?: string;
animationType: CardAnimationType; animationType?: string;
useInvertedBackground?: InvertedBackground; useInvertedBackground?: boolean;
ariaLabel?: string; ariaLabel?: string;
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
textBoxClassName?: string; textBoxClassName?: string;
textBoxTitleClassName?: string; titleClassName?: string;
textBoxDescriptionClassName?: string; descriptionClassName?: string;
textBoxTagClassName?: string; tagClassName?: string;
textBoxButtonContainerClassName?: string; buttonContainerClassName?: string;
textBoxButtonClassName?: string; buttonClassName?: string;
textBoxButtonTextClassName?: string; buttonTextClassName?: string;
itemClassName?: string;
mediaWrapperClassName?: string;
numberClassName?: string;
contentWrapperClassName?: string;
gapClassName?: string; gapClassName?: string;
titleImageWrapperClassName?: string;
titleImageClassName?: string;
} }
const TimelineProcessFlow = ({ export const TimelineProcessFlow: React.FC<TimelineProcessFlowProps> = ({
items, children,
title, containerClassName = '',
titleSegments, ...props
description, }) => {
tag, const containerRef = useRef<HTMLDivElement>(null);
tagIcon, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
animationType,
useInvertedBackground,
ariaLabel = "Timeline process flow section",
className = "",
containerClassName = "",
textBoxClassName = "",
textBoxTitleClassName = "",
textBoxDescriptionClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
itemClassName = "",
mediaWrapperClassName = "",
numberClassName = "",
contentWrapperClassName = "",
gapClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
}: TimelineProcessFlowProps) => {
const processLineRef = useRef<HTMLDivElement>(null);
const { itemRefs } = useCardAnimation({ animationType, itemCount: items.length, useIndividualTriggers: true });
const [isMdScreen, setIsMdScreen] = useState(false);
useEffect(() => { const animationOptions: UseCardAnimationOptions = {
const checkScreenSize = () => { containerRef,
setIsMdScreen(window.innerWidth >= 768); itemRefs,
}; };
checkScreenSize(); const { } = useCardAnimation(animationOptions);
window.addEventListener('resize', checkScreenSize);
return () => window.removeEventListener('resize', checkScreenSize);
}, []);
useEffect(() => {
if (!processLineRef.current) return;
gsap.fromTo(
processLineRef.current,
{ yPercent: -100 },
{
yPercent: 0,
ease: "none",
scrollTrigger: {
trigger: ".timeline-line",
start: "top center",
end: "bottom center",
scrub: true,
},
}
);
return () => {
ScrollTrigger.getAll().forEach((trigger) => trigger.kill());
};
}, []);
return ( return (
<section <div ref={containerRef} className={containerClassName}>
className={cls( {children}
"relative py-20 w-full", </div>
useInvertedBackground && "bg-foreground",
className
)}
aria-label={ariaLabel}
>
<div className={cls("w-full flex flex-col gap-6", containerClassName)}>
<div className="relative w-content-width mx-auto">
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
/>
</div>
<div className="relative w-full">
<div className="pointer-events-none absolute top-0 right-[var(--width-10)] md:right-auto md:left-1/2 md:-translate-x-1/2 w-px h-full z-10 overflow-hidden md:py-6" >
<div className="relative timeline-line h-full bg-foreground overflow-hidden">
<div className="w-full h-full bg-accent" ref={processLineRef} />
</div>
</div>
<ol className={cls("relative w-content-width mx-auto flex flex-col gap-10 md:gap-20 md:p-6", isMdScreen && "card", "md:rounded-theme-capped", gapClassName)}>
{items.map((item, index) => (
<li
key={item.id}
ref={(el) => {
itemRefs.current[index] = el;
}}
className={cls(
"relative z-10 w-full flex flex-col gap-6 md:gap-0 md:flex-row justify-between",
item.reverse && "flex-col md:flex-row-reverse",
itemClassName
)}
>
<div
className={cls("relative w-70 md:w-30", mediaWrapperClassName)}
>
{item.media}
</div>
<div
className={cls(
"absolute! top-1/2 right-[calc(var(--height-8)/-2)] md:right-auto md:left-1/2 md:-translate-x-1/2 -translate-y-1/2 h-8 aspect-square rounded-theme flex items-center justify-center z-10 primary-button",
numberClassName
)}
>
<p className="text-sm text-primary-cta-text">{item.id}</p>
</div>
<div className={cls("relative w-70 md:w-30", contentWrapperClassName)}>
{item.content}
</div>
</li>
))}
</ol>
</div>
</div>
</section>
); );
}; };
TimelineProcessFlow.displayName = "TimelineProcessFlow"; export default TimelineProcessFlow;
export default memo(TimelineProcessFlow);

View File

@@ -1,156 +1,48 @@
"use client"; import React, { useState, useEffect } from 'react';
import { memo, useMemo, useCallback } from "react"; interface Product {
import { useRouter } from "next/navigation"; id: string;
import Input from "@/components/form/Input"; name: string;
import ProductDetailVariantSelect from "@/components/ecommerce/productDetail/ProductDetailVariantSelect"; price: string;
import type { ProductVariant } from "@/components/ecommerce/productDetail/ProductDetailCard"; imageSrc: string;
import { cls } from "@/lib/utils";
import { useProducts } from "@/hooks/useProducts";
import ProductCatalogItem from "./ProductCatalogItem";
import type { CatalogProduct } from "./ProductCatalogItem";
interface ProductCatalogProps {
layout: "page" | "section";
products?: CatalogProduct[];
searchValue?: string;
onSearchChange?: (value: string) => void;
searchPlaceholder?: string;
filters?: ProductVariant[];
emptyMessage?: string;
className?: string;
gridClassName?: string;
cardClassName?: string;
imageClassName?: string;
searchClassName?: string;
filterClassName?: string;
toolbarClassName?: string;
} }
const ProductCatalog = ({ interface ProductCatalogState {
layout, products: Product[];
products: productsProp, loading: boolean;
searchValue = "", error: any;
onSearchChange, }
searchPlaceholder = "Search products...",
filters,
emptyMessage = "No products found",
className = "",
gridClassName = "",
cardClassName = "",
imageClassName = "",
searchClassName = "",
filterClassName = "",
toolbarClassName = "",
}: ProductCatalogProps) => {
const router = useRouter();
const { products: fetchedProducts, isLoading } = useProducts();
const handleProductClick = useCallback((productId: string) => { interface ProductCatalogProps {
router.push(`/shop/${productId}`); onProductsLoaded?: (products: Product[]) => void;
}, [router]); }
const products: CatalogProduct[] = useMemo(() => { export const ProductCatalog: React.FC<ProductCatalogProps> = ({ onProductsLoaded }) => {
if (productsProp && productsProp.length > 0) { const [state, setState] = useState<ProductCatalogState>({
return productsProp; products: [],
} loading: false,
error: null,
});
if (fetchedProducts.length === 0) { useEffect(() => {
return []; // Initialize or fetch products
} setState(prev => ({ ...prev, loading: false }));
}, []);
return fetchedProducts.map((product) => ({ return (
id: product.id, <div className="product-catalog">
name: product.name, {state.loading && <div>Loading...</div>}
price: product.price, {state.error && <div>Error: {state.error}</div>}
imageSrc: product.imageSrc, <div className="products">
imageAlt: product.imageAlt || product.name, {state.products.map(product => (
rating: product.rating || 0, <div key={product.id} className="product-item">
reviewCount: product.reviewCount, <h3>{product.name}</h3>
category: product.brand, <p>{product.price}</p>
onProductClick: () => handleProductClick(product.id), </div>
})); ))}
}, [productsProp, fetchedProducts, handleProductClick]); </div>
</div>
if (isLoading && (!productsProp || productsProp.length === 0)) { );
return (
<section
className={cls(
"relative w-content-width mx-auto",
layout === "page" ? "pt-hero-page-padding pb-20" : "py-20",
className
)}
>
<p className="text-sm text-foreground/50 text-center py-20">
Loading products...
</p>
</section>
);
}
return (
<section
className={cls(
"relative w-content-width mx-auto",
layout === "page" ? "pt-hero-page-padding pb-20" : "py-20",
className
)}
>
{(onSearchChange || (filters && filters.length > 0)) && (
<div
className={cls(
"flex flex-col md:flex-row gap-4 md:items-end mb-6",
toolbarClassName
)}
>
{onSearchChange && (
<Input
value={searchValue}
onChange={onSearchChange}
placeholder={searchPlaceholder}
ariaLabel={searchPlaceholder}
className={cls("flex-1 w-full h-9 text-sm", searchClassName)}
/>
)}
{filters && filters.length > 0 && (
<div className="flex gap-4 items-end">
{filters.map((filter) => (
<ProductDetailVariantSelect
key={filter.label}
variant={filter}
selectClassName={filterClassName}
/>
))}
</div>
)}
</div>
)}
{products.length === 0 ? (
<p className="text-sm text-foreground/50 text-center py-20">
{emptyMessage}
</p>
) : (
<div
className={cls(
"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",
gridClassName
)}
>
{products.map((product) => (
<ProductCatalogItem
key={product.id}
product={product}
className={cardClassName}
imageClassName={imageClassName}
/>
))}
</div>
)}
</section>
);
}; };
ProductCatalog.displayName = "ProductCatalog"; export default ProductCatalog;
export default memo(ProductCatalog);

View File

@@ -1,244 +1,216 @@
"use client"; "use client";
import { memo } from "react"; import React, { useEffect, useRef } from 'react';
import Image from "next/image"; import gsap from 'gsap';
import CardStack from "@/components/cardStack/CardStack"; import { ScrollTrigger } from 'gsap/ScrollTrigger';
import Badge from "@/components/shared/Badge"; import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
import OverlayArrowButton from "@/components/shared/OverlayArrowButton";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { BlogPost } from "@/lib/api/blog";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type BlogCard = BlogPost; gsap.registerPlugin(ScrollTrigger);
interface BlogCardOneProps { interface BlogCardOneProps {
blogs: BlogCard[]; blogs: Array<{
carouselMode?: "auto" | "buttons"; id: string;
uniformGridCustomHeightClasses?: string; category: string;
animationType: CardAnimationType;
title: string; title: string;
titleSegments?: TitleSegment[]; excerpt: string;
description: string; imageSrc: string;
tag?: string; imageAlt?: string;
tagIcon?: LucideIcon; authorName: string;
tagAnimation?: ButtonAnimationType; authorAvatar: string;
buttons?: ButtonConfig[]; date: string;
buttonAnimation?: ButtonAnimationType; onBlogClick?: () => void;
textboxLayout: TextboxLayout; }>;
useInvertedBackground: InvertedBackground; carouselMode?: 'auto' | 'buttons';
ariaLabel?: string; uniformGridCustomHeightClasses?: string;
className?: string; animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
containerClassName?: string; title: string;
cardClassName?: string; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
imageWrapperClassName?: string; description: string;
imageClassName?: string; tag?: string;
categoryClassName?: string; tagIcon?: React.ComponentType<any>;
cardTitleClassName?: string; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
excerptClassName?: string; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
authorContainerClassName?: string; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
authorAvatarClassName?: string; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
authorNameClassName?: string; useInvertedBackground: boolean;
dateClassName?: string; ariaLabel?: string;
textBoxTitleClassName?: string; className?: string;
textBoxTitleImageWrapperClassName?: string; containerClassName?: string;
textBoxTitleImageClassName?: string; cardClassName?: string;
textBoxDescriptionClassName?: string; imageWrapperClassName?: string;
gridClassName?: string; imageClassName?: string;
carouselClassName?: string; categoryClassName?: string;
controlsClassName?: string; cardTitleClassName?: string;
textBoxClassName?: string; excerptClassName?: string;
textBoxTagClassName?: string; authorContainerClassName?: string;
textBoxButtonContainerClassName?: string; authorAvatarClassName?: string;
textBoxButtonClassName?: string; authorNameClassName?: string;
textBoxButtonTextClassName?: string; dateClassName?: string;
textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string;
gridClassName?: string;
carouselClassName?: string;
controlsClassName?: string;
textBoxClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
} }
interface BlogCardItemProps { const BlogCardOne: React.FC<BlogCardOneProps> = ({
blog: BlogCard; blogs,
shouldUseLightText: boolean; carouselMode = 'buttons',
cardClassName?: string; uniformGridCustomHeightClasses = 'min-h-95 2xl:min-h-105',
imageWrapperClassName?: string; animationType,
imageClassName?: string; title,
categoryClassName?: string; titleSegments,
cardTitleClassName?: string; description,
excerptClassName?: string; tag,
authorContainerClassName?: string; tagIcon: TagIcon,
authorAvatarClassName?: string; tagAnimation,
authorNameClassName?: string; buttons,
dateClassName?: string; buttonAnimation,
} textboxLayout,
useInvertedBackground,
ariaLabel = 'Blog section',
className = '',
containerClassName = '',
cardClassName = '',
imageWrapperClassName = '',
imageClassName = '',
categoryClassName = '',
cardTitleClassName = '',
excerptClassName = '',
authorContainerClassName = '',
authorAvatarClassName = '',
authorNameClassName = '',
dateClassName = '',
textBoxTitleImageClassName = '',
textBoxDescriptionClassName = '',
gridClassName = '',
carouselClassName = '',
controlsClassName = '',
textBoxClassName = '',
textBoxTagClassName = '',
textBoxButtonContainerClassName = '',
textBoxButtonClassName = '',
textBoxButtonTextClassName = '',
}) => {
const sectionRef = useRef<HTMLDivElement>(null);
const cardsRef = useRef<(HTMLDivElement | null)[]>([]);
const BlogCardItem = memo(({ useEffect(() => {
blog, if (animationType === 'none' || !sectionRef.current) return;
shouldUseLightText,
cardClassName = "",
imageWrapperClassName = "",
imageClassName = "",
categoryClassName = "",
cardTitleClassName = "",
excerptClassName = "",
authorContainerClassName = "",
authorAvatarClassName = "",
authorNameClassName = "",
dateClassName = "",
}: BlogCardItemProps) => {
return (
<article
className={cls("relative h-full card group flex flex-col gap-4 cursor-pointer p-4 rounded-theme-capped", cardClassName)}
onClick={blog.onBlogClick}
role="article"
aria-label={`${blog.title} by ${blog.authorName}`}
>
<div className={cls("relative z-1 w-full aspect-[4/3] overflow-hidden rounded-theme-capped", imageWrapperClassName)}>
<Image
src={blog.imageSrc}
alt={blog.imageAlt || blog.title}
fill
className={cls("w-full h-full object-cover transition-transform duration-500 ease-in-out group-hover:scale-105", imageClassName)}
unoptimized={blog.imageSrc.startsWith('http') || blog.imageSrc.startsWith('//')}
/>
<OverlayArrowButton ariaLabel={`Read ${blog.title}`} />
</div>
<div className="relative z-1 flex flex-col justify-between gap-6 flex-1"> const cards = cardsRef.current.filter((card): card is HTMLDivElement => card !== null);
<div className="flex flex-col gap-2"> if (cards.length === 0) return;
<Badge text={blog.category} variant="primary" className={categoryClassName} />
<h3 className={cls("text-2xl font-medium leading-[1.25] mt-1", shouldUseLightText ? "text-background" : "text-foreground", cardTitleClassName)}> cards.forEach((card, index) => {
{blog.title} gsap.set(card, { opacity: 0, y: 20 });
</h3>
<p className={cls("text-base leading-[1.25]", shouldUseLightText ? "text-background" : "text-foreground", excerptClassName)}> ScrollTrigger.create({
{blog.excerpt} trigger: card,
</p> onEnter: () => {
</div> gsap.to(card, {
opacity: 1,
y: 0,
duration: 0.6,
delay: index * 0.1,
ease: 'power2.out',
});
},
});
});
<div className={cls("flex items-center gap-3", authorContainerClassName)}> return () => {
<Image cards.forEach(() => ScrollTrigger.getAll().forEach(trigger => trigger.kill()));
src={blog.authorAvatar} };
alt={blog.authorName} }, [animationType]);
width={40}
height={40}
className={cls("h-9 w-auto aspect-square rounded-theme object-cover", authorAvatarClassName)}
unoptimized={blog.authorAvatar.startsWith('http') || blog.authorAvatar.startsWith('//')}
/>
<div className="flex flex-col">
<p className={cls("text-sm font-medium", shouldUseLightText ? "text-background" : "text-foreground", authorNameClassName)}>
{blog.authorName}
</p>
<p className={cls("text-xs", shouldUseLightText ? "text-background/75" : "text-foreground/75", dateClassName)}>
{blog.date}
</p>
</div>
</div>
</div>
</article>
);
});
BlogCardItem.displayName = "BlogCardItem"; const gridVariant = blogs.length <= 4 ? 'uniform-all-items-equal' : 'uniform-all-items-equal';
const mode = blogs.length >= 5 ? 'auto' : carouselMode;
const BlogCardOne = ({ const blogChildren = blogs.map((blog, index) => (
blogs = [], <div
carouselMode = "buttons", key={blog.id}
uniformGridCustomHeightClasses, ref={el => {
animationType, cardsRef.current[index] = el;
title, }}
titleSegments, className={`cursor-pointer group ${cardClassName}`}
description, onClick={blog.onBlogClick}
tag, >
tagIcon, {/* Image wrapper with overlay arrow */}
tagAnimation, <div className={`relative overflow-hidden rounded-lg ${imageWrapperClassName}`}>
buttons, <img
buttonAnimation, src={blog.imageSrc}
textboxLayout, alt={blog.imageAlt || blog.title}
useInvertedBackground, className={`w-full h-full object-cover transition-transform duration-300 group-hover:scale-110 ${imageClassName}`}
ariaLabel = "Blog section", />
className = "", <div className="absolute inset-0 bg-black/20 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
containerClassName = "", <div className="text-white text-3xl"></div>
cardClassName = "", </div>
imageWrapperClassName = "", </div>
imageClassName = "",
categoryClassName = "",
cardTitleClassName = "",
excerptClassName = "",
authorContainerClassName = "",
authorAvatarClassName = "",
authorNameClassName = "",
dateClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: BlogCardOneProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
return ( {/* Category badge */}
<CardStack <div className={`mt-4 inline-block px-3 py-1 rounded-full bg-blue-500/20 text-blue-400 text-sm font-semibold ${categoryClassName}`}>
mode={carouselMode} {blog.category}
gridVariant="uniform-all-items-equal" </div>
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title} {/* Title */}
titleSegments={titleSegments} <h3 className={`mt-3 text-xl font-bold text-gray-900 dark:text-white line-clamp-2 ${cardTitleClassName}`}>
description={description} {blog.title}
tag={tag} </h3>
tagIcon={tagIcon}
tagAnimation={tagAnimation} {/* Excerpt */}
buttons={buttons} <p className={`mt-2 text-gray-600 dark:text-gray-300 text-sm line-clamp-2 ${excerptClassName}`}>
buttonAnimation={buttonAnimation} {blog.excerpt}
textboxLayout={textboxLayout} </p>
useInvertedBackground={useInvertedBackground}
ariaLabel={ariaLabel} {/* Author info */}
className={className} <div className={`mt-4 flex items-center gap-3 ${authorContainerClassName}`}>
containerClassName={containerClassName} <img
gridClassName={gridClassName} src={blog.authorAvatar}
carouselClassName={carouselClassName} alt={blog.authorName}
controlsClassName={controlsClassName} className={`w-8 h-8 rounded-full object-cover ${authorAvatarClassName}`}
textBoxClassName={textBoxClassName} />
titleClassName={textBoxTitleClassName} <div className="flex-1 min-w-0">
titleImageWrapperClassName={textBoxTitleImageWrapperClassName} <p className={`text-sm font-semibold text-gray-900 dark:text-white truncate ${authorNameClassName}`}>
titleImageClassName={textBoxTitleImageClassName} {blog.authorName}
descriptionClassName={textBoxDescriptionClassName} </p>
tagClassName={textBoxTagClassName} <p className={`text-xs text-gray-500 dark:text-gray-400 ${dateClassName}`}>{blog.date}</p>
buttonContainerClassName={textBoxButtonContainerClassName} </div>
buttonClassName={textBoxButtonClassName} </div>
buttonTextClassName={textBoxButtonTextClassName} </div>
> ));
{blogs.map((blog) => (
<BlogCardItem return (
key={blog.id} <section ref={sectionRef} className={`py-12 md:py-20 ${className}`} aria-label={ariaLabel}>
blog={blog} <TimelineHorizontalCardStack
shouldUseLightText={shouldUseLightText} children={blogChildren}
cardClassName={cardClassName} title={title}
imageWrapperClassName={imageWrapperClassName} titleSegments={titleSegments}
imageClassName={imageClassName} description={description}
categoryClassName={categoryClassName} tag={tag}
cardTitleClassName={cardTitleClassName} tagIcon={TagIcon}
excerptClassName={excerptClassName} tagAnimation={tagAnimation}
authorContainerClassName={authorContainerClassName} buttons={buttons}
authorAvatarClassName={authorAvatarClassName} buttonAnimation={buttonAnimation}
authorNameClassName={authorNameClassName} textboxLayout={textboxLayout}
dateClassName={dateClassName} useInvertedBackground={useInvertedBackground}
/> ariaLabel={ariaLabel}
))} className={className}
</CardStack> containerClassName={containerClassName}
); textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
/>
</section>
);
}; };
BlogCardOne.displayName = "BlogCardOne";
export default BlogCardOne; export default BlogCardOne;

View File

@@ -1,288 +1,216 @@
"use client"; "use client";
import { memo } from "react"; import React, { useEffect, useRef } from 'react';
import Image from "next/image"; import gsap from 'gsap';
import CardStack from "@/components/cardStack/CardStack"; import { ScrollTrigger } from 'gsap/ScrollTrigger';
import Tag from "@/components/shared/Tag"; import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
import MediaContent from "@/components/shared/MediaContent";
import OverlayArrowButton from "@/components/shared/OverlayArrowButton";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { BlogPost } from "@/lib/api/blog";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type BlogCard = BlogPost; gsap.registerPlugin(ScrollTrigger);
interface BlogCardThreeProps { interface BlogCardThreeProps {
blogs: BlogCard[]; blogs: Array<{
carouselMode?: "auto" | "buttons"; id: string;
uniformGridCustomHeightClasses?: string; category: string;
animationType: CardAnimationType;
title: string; title: string;
titleSegments?: TitleSegment[]; excerpt: string;
description: string; imageSrc: string;
tag?: string; imageAlt?: string;
tagIcon?: LucideIcon; authorName: string;
tagAnimation?: ButtonAnimationType; authorAvatar: string;
buttons?: ButtonConfig[]; date: string;
buttonAnimation?: ButtonAnimationType; onBlogClick?: () => void;
textboxLayout: TextboxLayout; }>;
useInvertedBackground: InvertedBackground; carouselMode?: 'auto' | 'buttons';
ariaLabel?: string; uniformGridCustomHeightClasses?: string;
className?: string; animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
containerClassName?: string; title: string;
cardClassName?: string; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
cardContentClassName?: string; description: string;
categoryTagClassName?: string; tag?: string;
cardTitleClassName?: string; tagIcon?: React.ComponentType<any>;
excerptClassName?: string; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
authorContainerClassName?: string; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
authorAvatarClassName?: string; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
authorNameClassName?: string; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
dateClassName?: string; useInvertedBackground: boolean;
mediaWrapperClassName?: string; ariaLabel?: string;
mediaClassName?: string; className?: string;
textBoxTitleClassName?: string; containerClassName?: string;
textBoxTitleImageWrapperClassName?: string; cardClassName?: string;
textBoxTitleImageClassName?: string; imageWrapperClassName?: string;
textBoxDescriptionClassName?: string; imageClassName?: string;
gridClassName?: string; categoryClassName?: string;
carouselClassName?: string; cardTitleClassName?: string;
controlsClassName?: string; excerptClassName?: string;
textBoxClassName?: string; authorContainerClassName?: string;
textBoxTagClassName?: string; authorAvatarClassName?: string;
textBoxButtonContainerClassName?: string; authorNameClassName?: string;
textBoxButtonClassName?: string; dateClassName?: string;
textBoxButtonTextClassName?: string; textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string;
gridClassName?: string;
carouselClassName?: string;
controlsClassName?: string;
textBoxClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
} }
interface BlogCardItemProps { const BlogCardThree: React.FC<BlogCardThreeProps> = ({
blog: BlogCard; blogs,
useInvertedBackground: boolean; carouselMode = 'buttons',
cardClassName?: string; uniformGridCustomHeightClasses = 'min-h-95 2xl:min-h-105',
cardContentClassName?: string; animationType,
categoryTagClassName?: string; title,
cardTitleClassName?: string; titleSegments,
excerptClassName?: string; description,
authorContainerClassName?: string; tag,
authorAvatarClassName?: string; tagIcon: TagIcon,
authorNameClassName?: string; tagAnimation,
dateClassName?: string; buttons,
mediaWrapperClassName?: string; buttonAnimation,
mediaClassName?: string; textboxLayout,
} useInvertedBackground,
ariaLabel = 'Blog section',
className = '',
containerClassName = '',
cardClassName = '',
imageWrapperClassName = '',
imageClassName = '',
categoryClassName = '',
cardTitleClassName = '',
excerptClassName = '',
authorContainerClassName = '',
authorAvatarClassName = '',
authorNameClassName = '',
dateClassName = '',
textBoxTitleImageClassName = '',
textBoxDescriptionClassName = '',
gridClassName = '',
carouselClassName = '',
controlsClassName = '',
textBoxClassName = '',
textBoxTagClassName = '',
textBoxButtonContainerClassName = '',
textBoxButtonClassName = '',
textBoxButtonTextClassName = '',
}) => {
const sectionRef = useRef<HTMLDivElement>(null);
const cardsRef = useRef<(HTMLDivElement | null)[]>([]);
const BlogCardItem = memo(({ useEffect(() => {
blog, if (animationType === 'none' || !sectionRef.current) return;
useInvertedBackground,
cardClassName = "",
cardContentClassName = "",
categoryTagClassName = "",
cardTitleClassName = "",
excerptClassName = "",
authorContainerClassName = "",
authorAvatarClassName = "",
authorNameClassName = "",
dateClassName = "",
mediaWrapperClassName = "",
mediaClassName = "",
}: BlogCardItemProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
return ( const cards = cardsRef.current.filter((card): card is HTMLDivElement => card !== null);
<article if (cards.length === 0) return;
className={cls(
"relative h-full card group flex flex-col justify-between gap-6 p-6 cursor-pointer rounded-theme-capped overflow-hidden",
cardClassName
)}
onClick={blog.onBlogClick}
role="article"
aria-label={blog.title}
>
<div className={cls("relative z-1 flex flex-col gap-3", cardContentClassName)}>
<Tag
text={blog.category}
useInvertedBackground={useInvertedBackground}
className={categoryTagClassName}
/>
<h3 className={cls( cards.forEach((card, index) => {
"text-3xl md:text-4xl font-medium leading-tight line-clamp-2", gsap.set(card, { opacity: 0, y: 20 });
shouldUseLightText ? "text-background" : "text-foreground",
cardTitleClassName
)}>
{blog.title}
</h3>
<p className={cls( ScrollTrigger.create({
"text-base leading-tight line-clamp-2", trigger: card,
shouldUseLightText ? "text-background/75" : "text-foreground/75", onEnter: () => {
excerptClassName gsap.to(card, {
)}> opacity: 1,
{blog.excerpt} y: 0,
</p> duration: 0.6,
delay: index * 0.1,
ease: 'power2.out',
});
},
});
});
{(blog.authorName || blog.date) && ( return () => {
<div className={cls( cards.forEach(() => ScrollTrigger.getAll().forEach(trigger => trigger.kill()));
"flex", };
blog.authorAvatar ? "items-center gap-3" : "flex-row justify-between items-center", }, [animationType]);
authorContainerClassName
)}>
{blog.authorAvatar && (
<Image
src={blog.authorAvatar}
alt={blog.authorName || "Author"}
width={40}
height={40}
className={cls("h-9 w-auto aspect-square rounded-theme object-cover", authorAvatarClassName)}
unoptimized={blog.authorAvatar.startsWith('http') || blog.authorAvatar.startsWith('//')}
/>
)}
{blog.authorAvatar ? (
<div className="flex flex-col">
{blog.authorName && (
<p className={cls("text-sm font-medium", shouldUseLightText ? "text-background" : "text-foreground", authorNameClassName)}>
{blog.authorName}
</p>
)}
{blog.date && (
<p className={cls("text-xs", shouldUseLightText ? "text-background/75" : "text-foreground/75", dateClassName)}>
{blog.date}
</p>
)}
</div>
) : (
<>
{blog.authorName && (
<p className={cls("text-sm font-medium", shouldUseLightText ? "text-background" : "text-foreground", authorNameClassName)}>
{blog.authorName}
</p>
)}
{blog.date && (
<p className={cls("text-xs", shouldUseLightText ? "text-background/75" : "text-foreground/75", dateClassName)}>
{blog.date}
</p>
)}
</>
)}
</div>
)}
</div>
<div className={cls("relative z-1 w-full aspect-square", mediaWrapperClassName)}> const gridVariant = blogs.length <= 4 ? 'uniform-all-items-equal' : 'uniform-all-items-equal';
<MediaContent const mode = blogs.length >= 5 ? 'auto' : carouselMode;
imageSrc={blog.imageSrc}
imageAlt={blog.imageAlt || blog.title}
imageClassName={cls("absolute inset-0 w-full h-full object-cover", mediaClassName)}
/>
<OverlayArrowButton ariaLabel={`Read ${blog.title}`} />
</div>
</article>
);
});
BlogCardItem.displayName = "BlogCardItem"; const blogChildren = blogs.map((blog, index) => (
<div
key={blog.id}
ref={el => {
cardsRef.current[index] = el;
}}
className={`cursor-pointer group ${cardClassName}`}
onClick={blog.onBlogClick}
>
{/* Image wrapper with overlay arrow */}
<div className={`relative overflow-hidden rounded-lg ${imageWrapperClassName}`}>
<img
src={blog.imageSrc}
alt={blog.imageAlt || blog.title}
className={`w-full h-full object-cover transition-transform duration-300 group-hover:scale-110 ${imageClassName}`}
/>
<div className="absolute inset-0 bg-black/20 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
<div className="text-white text-3xl"></div>
</div>
</div>
const BlogCardThree = ({ {/* Category badge */}
blogs = [], <div className={`mt-4 inline-block px-3 py-1 rounded-full bg-blue-500/20 text-blue-400 text-sm font-semibold ${categoryClassName}`}>
carouselMode = "buttons", {blog.category}
uniformGridCustomHeightClasses = "min-h-none", </div>
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Blog section",
className = "",
containerClassName = "",
cardClassName = "",
cardContentClassName = "",
categoryTagClassName = "",
cardTitleClassName = "",
excerptClassName = "",
authorContainerClassName = "",
authorAvatarClassName = "",
authorNameClassName = "",
dateClassName = "",
mediaWrapperClassName = "",
mediaClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: BlogCardThreeProps) => {
return (
<CardStack
mode={carouselMode}
gridVariant="uniform-all-items-equal"
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title} {/* Title */}
titleSegments={titleSegments} <h3 className={`mt-3 text-xl font-bold text-gray-900 dark:text-white line-clamp-2 ${cardTitleClassName}`}>
description={description} {blog.title}
tag={tag} </h3>
tagIcon={tagIcon}
tagAnimation={tagAnimation} {/* Excerpt */}
buttons={buttons} <p className={`mt-2 text-gray-600 dark:text-gray-300 text-sm line-clamp-2 ${excerptClassName}`}>
buttonAnimation={buttonAnimation} {blog.excerpt}
textboxLayout={textboxLayout} </p>
useInvertedBackground={useInvertedBackground}
ariaLabel={ariaLabel} {/* Author info */}
className={className} <div className={`mt-4 flex items-center gap-3 ${authorContainerClassName}`}>
containerClassName={containerClassName} <img
gridClassName={gridClassName} src={blog.authorAvatar}
carouselClassName={carouselClassName} alt={blog.authorName}
controlsClassName={controlsClassName} className={`w-8 h-8 rounded-full object-cover ${authorAvatarClassName}`}
textBoxClassName={textBoxClassName} />
titleClassName={textBoxTitleClassName} <div className="flex-1 min-w-0">
titleImageWrapperClassName={textBoxTitleImageWrapperClassName} <p className={`text-sm font-semibold text-gray-900 dark:text-white truncate ${authorNameClassName}`}>
titleImageClassName={textBoxTitleImageClassName} {blog.authorName}
descriptionClassName={textBoxDescriptionClassName} </p>
tagClassName={textBoxTagClassName} <p className={`text-xs text-gray-500 dark:text-gray-400 ${dateClassName}`}>{blog.date}</p>
buttonContainerClassName={textBoxButtonContainerClassName} </div>
buttonClassName={textBoxButtonClassName} </div>
buttonTextClassName={textBoxButtonTextClassName} </div>
> ));
{blogs.map((blog) => (
<BlogCardItem return (
key={blog.id} <section ref={sectionRef} className={`py-12 md:py-20 ${className}`} aria-label={ariaLabel}>
blog={blog} <TimelineHorizontalCardStack
useInvertedBackground={useInvertedBackground} children={blogChildren}
cardClassName={cardClassName} title={title}
cardContentClassName={cardContentClassName} titleSegments={titleSegments}
categoryTagClassName={categoryTagClassName} description={description}
cardTitleClassName={cardTitleClassName} tag={tag}
excerptClassName={excerptClassName} tagIcon={TagIcon}
authorContainerClassName={authorContainerClassName} tagAnimation={tagAnimation}
authorAvatarClassName={authorAvatarClassName} buttons={buttons}
authorNameClassName={authorNameClassName} buttonAnimation={buttonAnimation}
dateClassName={dateClassName} textboxLayout={textboxLayout}
mediaWrapperClassName={mediaWrapperClassName} useInvertedBackground={useInvertedBackground}
mediaClassName={mediaClassName} ariaLabel={ariaLabel}
/> className={className}
))} containerClassName={containerClassName}
</CardStack> textBoxClassName={textBoxClassName}
); titleClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
/>
</section>
);
}; };
BlogCardThree.displayName = "BlogCardThree";
export default BlogCardThree; export default BlogCardThree;

View File

@@ -1,241 +1,216 @@
"use client"; "use client";
import { memo } from "react"; import React, { useEffect, useRef } from 'react';
import Image from "next/image"; import gsap from 'gsap';
import CardStack from "@/components/cardStack/CardStack"; import { ScrollTrigger } from 'gsap/ScrollTrigger';
import Badge from "@/components/shared/Badge"; import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
import OverlayArrowButton from "@/components/shared/OverlayArrowButton";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { BlogPost } from "@/lib/api/blog";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type BlogCard = Omit<BlogPost, 'category'> & { gsap.registerPlugin(ScrollTrigger);
category: string | string[];
};
interface BlogCardTwoProps { interface BlogCardTwoProps {
blogs: BlogCard[]; blogs: Array<{
carouselMode?: "auto" | "buttons"; id: string;
uniformGridCustomHeightClasses?: string; category: string;
animationType: CardAnimationType;
title: string; title: string;
titleSegments?: TitleSegment[]; excerpt: string;
description: string; imageSrc: string;
tag?: string; imageAlt?: string;
tagIcon?: LucideIcon; authorName: string;
tagAnimation?: ButtonAnimationType; authorAvatar: string;
buttons?: ButtonConfig[]; date: string;
buttonAnimation?: ButtonAnimationType; onBlogClick?: () => void;
textboxLayout: TextboxLayout; }>;
useInvertedBackground: InvertedBackground; carouselMode?: 'auto' | 'buttons';
ariaLabel?: string; uniformGridCustomHeightClasses?: string;
className?: string; animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
containerClassName?: string; title: string;
cardClassName?: string; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
imageWrapperClassName?: string; description: string;
imageClassName?: string; tag?: string;
authorAvatarClassName?: string; tagIcon?: React.ComponentType<any>;
authorDateClassName?: string; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
cardTitleClassName?: string; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
excerptClassName?: string; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
categoryClassName?: string; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
textBoxTitleClassName?: string; useInvertedBackground: boolean;
textBoxTitleImageWrapperClassName?: string; ariaLabel?: string;
textBoxTitleImageClassName?: string; className?: string;
textBoxDescriptionClassName?: string; containerClassName?: string;
gridClassName?: string; cardClassName?: string;
carouselClassName?: string; imageWrapperClassName?: string;
controlsClassName?: string; imageClassName?: string;
textBoxClassName?: string; categoryClassName?: string;
textBoxTagClassName?: string; cardTitleClassName?: string;
textBoxButtonContainerClassName?: string; excerptClassName?: string;
textBoxButtonClassName?: string; authorContainerClassName?: string;
textBoxButtonTextClassName?: string; authorAvatarClassName?: string;
authorNameClassName?: string;
dateClassName?: string;
textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string;
gridClassName?: string;
carouselClassName?: string;
controlsClassName?: string;
textBoxClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
} }
interface BlogCardItemProps { const BlogCardTwo: React.FC<BlogCardTwoProps> = ({
blog: BlogCard; blogs,
shouldUseLightText: boolean; carouselMode = 'buttons',
cardClassName?: string; uniformGridCustomHeightClasses = 'min-h-95 2xl:min-h-105',
imageWrapperClassName?: string; animationType,
imageClassName?: string; title,
authorAvatarClassName?: string; titleSegments,
authorDateClassName?: string; description,
cardTitleClassName?: string; tag,
excerptClassName?: string; tagIcon: TagIcon,
categoryClassName?: string; tagAnimation,
} buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = 'Blog section',
className = '',
containerClassName = '',
cardClassName = '',
imageWrapperClassName = '',
imageClassName = '',
categoryClassName = '',
cardTitleClassName = '',
excerptClassName = '',
authorContainerClassName = '',
authorAvatarClassName = '',
authorNameClassName = '',
dateClassName = '',
textBoxTitleImageClassName = '',
textBoxDescriptionClassName = '',
gridClassName = '',
carouselClassName = '',
controlsClassName = '',
textBoxClassName = '',
textBoxTagClassName = '',
textBoxButtonContainerClassName = '',
textBoxButtonClassName = '',
textBoxButtonTextClassName = '',
}) => {
const sectionRef = useRef<HTMLDivElement>(null);
const cardsRef = useRef<(HTMLDivElement | null)[]>([]);
const BlogCardItem = memo(({ useEffect(() => {
blog, if (animationType === 'none' || !sectionRef.current) return;
shouldUseLightText,
cardClassName = "",
imageWrapperClassName = "",
imageClassName = "",
authorAvatarClassName = "",
authorDateClassName = "",
cardTitleClassName = "",
excerptClassName = "",
categoryClassName = "",
}: BlogCardItemProps) => {
return (
<article
className={cls("relative h-full card group flex flex-col gap-4 cursor-pointer p-4 rounded-theme-capped", cardClassName)}
onClick={blog.onBlogClick}
role="article"
aria-label={`${blog.title} by ${blog.authorName}`}
>
<div className={cls("relative z-1 w-full aspect-[4/3] overflow-hidden rounded-theme-capped", imageWrapperClassName)}>
<Image
src={blog.imageSrc}
alt={blog.imageAlt || blog.title}
fill
className={cls("w-full h-full object-cover transition-transform duration-500 ease-in-out group-hover:scale-105", imageClassName)}
unoptimized={blog.imageSrc.startsWith('http') || blog.imageSrc.startsWith('//')}
/>
<OverlayArrowButton ariaLabel={`Read ${blog.title}`} />
</div>
<div className="relative z-1 flex flex-col justify-between gap-6 flex-1"> const cards = cardsRef.current.filter((card): card is HTMLDivElement => card !== null);
<div className="flex flex-col gap-2"> if (cards.length === 0) return;
<div className="flex items-center gap-2">
{blog.authorAvatar && (
<Image
src={blog.authorAvatar}
alt={blog.authorName}
width={24}
height={24}
className={cls("h-[var(--text-xs)] w-auto aspect-square rounded-theme object-cover bg-background-accent", authorAvatarClassName)}
unoptimized={blog.authorAvatar.startsWith('http') || blog.authorAvatar.startsWith('//')}
/>
)}
<p className={cls("text-xs", shouldUseLightText ? "text-background" : "text-foreground", authorDateClassName)}>
{blog.authorName} {blog.date}
</p>
</div>
<h3 className={cls("text-2xl font-medium leading-[1.25]", shouldUseLightText ? "text-background" : "text-foreground", cardTitleClassName)}> cards.forEach((card, index) => {
{blog.title} gsap.set(card, { opacity: 0, y: 20 });
</h3>
<p className={cls("text-base leading-[1.25]", shouldUseLightText ? "text-background" : "text-foreground", excerptClassName)}> ScrollTrigger.create({
{blog.excerpt} trigger: card,
</p> onEnter: () => {
</div> gsap.to(card, {
opacity: 1,
y: 0,
duration: 0.6,
delay: index * 0.1,
ease: 'power2.out',
});
},
});
});
<div className="flex flex-wrap gap-2"> return () => {
{Array.isArray(blog.category) ? ( cards.forEach(() => ScrollTrigger.getAll().forEach(trigger => trigger.kill()));
blog.category.map((cat, index) => ( };
<Badge key={`${cat}-${index}`} text={cat} variant="primary" className={categoryClassName} /> }, [animationType]);
))
) : (
<Badge text={blog.category} variant="primary" className={categoryClassName} />
)}
</div>
</div>
</article>
);
});
BlogCardItem.displayName = "BlogCardItem"; const gridVariant = blogs.length <= 4 ? 'uniform-all-items-equal' : 'uniform-all-items-equal';
const mode = blogs.length >= 5 ? 'auto' : carouselMode;
const BlogCardTwo = ({ const blogChildren = blogs.map((blog, index) => (
blogs = [], <div
carouselMode = "buttons", key={blog.id}
uniformGridCustomHeightClasses, ref={el => {
animationType, cardsRef.current[index] = el;
title, }}
titleSegments, className={`cursor-pointer group ${cardClassName}`}
description, onClick={blog.onBlogClick}
tag, >
tagIcon, {/* Image wrapper with overlay arrow */}
tagAnimation, <div className={`relative overflow-hidden rounded-lg ${imageWrapperClassName}`}>
buttons, <img
buttonAnimation, src={blog.imageSrc}
textboxLayout, alt={blog.imageAlt || blog.title}
useInvertedBackground, className={`w-full h-full object-cover transition-transform duration-300 group-hover:scale-110 ${imageClassName}`}
ariaLabel = "Blog section", />
className = "", <div className="absolute inset-0 bg-black/20 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
containerClassName = "", <div className="text-white text-3xl"></div>
cardClassName = "", </div>
imageWrapperClassName = "", </div>
imageClassName = "",
authorAvatarClassName = "",
authorDateClassName = "",
cardTitleClassName = "",
excerptClassName = "",
categoryClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: BlogCardTwoProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
return ( {/* Category badge */}
<CardStack <div className={`mt-4 inline-block px-3 py-1 rounded-full bg-blue-500/20 text-blue-400 text-sm font-semibold ${categoryClassName}`}>
mode={carouselMode} {blog.category}
gridVariant="uniform-all-items-equal" </div>
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title} {/* Title */}
titleSegments={titleSegments} <h3 className={`mt-3 text-xl font-bold text-gray-900 dark:text-white line-clamp-2 ${cardTitleClassName}`}>
description={description} {blog.title}
tag={tag} </h3>
tagIcon={tagIcon}
tagAnimation={tagAnimation} {/* Excerpt */}
buttons={buttons} <p className={`mt-2 text-gray-600 dark:text-gray-300 text-sm line-clamp-2 ${excerptClassName}`}>
buttonAnimation={buttonAnimation} {blog.excerpt}
textboxLayout={textboxLayout} </p>
useInvertedBackground={useInvertedBackground}
ariaLabel={ariaLabel} {/* Author info */}
className={className} <div className={`mt-4 flex items-center gap-3 ${authorContainerClassName}`}>
containerClassName={containerClassName} <img
gridClassName={gridClassName} src={blog.authorAvatar}
carouselClassName={carouselClassName} alt={blog.authorName}
controlsClassName={controlsClassName} className={`w-8 h-8 rounded-full object-cover ${authorAvatarClassName}`}
textBoxClassName={textBoxClassName} />
titleClassName={textBoxTitleClassName} <div className="flex-1 min-w-0">
titleImageWrapperClassName={textBoxTitleImageWrapperClassName} <p className={`text-sm font-semibold text-gray-900 dark:text-white truncate ${authorNameClassName}`}>
titleImageClassName={textBoxTitleImageClassName} {blog.authorName}
descriptionClassName={textBoxDescriptionClassName} </p>
tagClassName={textBoxTagClassName} <p className={`text-xs text-gray-500 dark:text-gray-400 ${dateClassName}`}>{blog.date}</p>
buttonContainerClassName={textBoxButtonContainerClassName} </div>
buttonClassName={textBoxButtonClassName} </div>
buttonTextClassName={textBoxButtonTextClassName} </div>
> ));
{blogs.map((blog) => (
<BlogCardItem return (
key={blog.id} <section ref={sectionRef} className={`py-12 md:py-20 ${className}`} aria-label={ariaLabel}>
blog={blog} <TimelineHorizontalCardStack
shouldUseLightText={shouldUseLightText} children={blogChildren}
cardClassName={cardClassName} title={title}
imageWrapperClassName={imageWrapperClassName} titleSegments={titleSegments}
imageClassName={imageClassName} description={description}
authorAvatarClassName={authorAvatarClassName} tag={tag}
authorDateClassName={authorDateClassName} tagIcon={TagIcon}
cardTitleClassName={cardTitleClassName} tagAnimation={tagAnimation}
excerptClassName={excerptClassName} buttons={buttons}
categoryClassName={categoryClassName} buttonAnimation={buttonAnimation}
/> textboxLayout={textboxLayout}
))} useInvertedBackground={useInvertedBackground}
</CardStack> ariaLabel={ariaLabel}
); className={className}
containerClassName={containerClassName}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
/>
</section>
);
}; };
BlogCardTwo.displayName = "BlogCardTwo";
export default BlogCardTwo; export default BlogCardTwo;

View File

@@ -1,131 +1,102 @@
"use client"; "use client";
import ContactForm from "@/components/form/ContactForm"; import React, { useState } from 'react';
import HeroBackgrounds, { type HeroBackgroundVariantProps } from "@/components/background/HeroBackgrounds"; import { Mail, Phone, MapPin } from 'lucide-react';
import { cls } from "@/lib/utils";
import { LucideIcon } from "lucide-react";
import { sendContactEmail } from "@/utils/sendContactEmail";
import type { ButtonAnimationType } from "@/types/button";
type ContactCenterBackgroundProps = Extract< interface ContactFormData {
HeroBackgroundVariantProps, name: string;
| { variant: "plain" } email: string;
| { variant: "animated-grid" } message: string;
| { variant: "canvas-reveal" }
| { variant: "cell-wave" }
| { variant: "downward-rays-animated" }
| { variant: "downward-rays-animated-grid" }
| { variant: "downward-rays-static" }
| { variant: "downward-rays-static-grid" }
| { variant: "gradient-bars" }
| { variant: "radial-gradient" }
| { variant: "rotated-rays-animated" }
| { variant: "rotated-rays-animated-grid" }
| { variant: "rotated-rays-static" }
| { variant: "rotated-rays-static-grid" }
| { variant: "sparkles-gradient" }
>;
interface ContactCenterProps {
title: string;
description: string;
tag: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
background: ContactCenterBackgroundProps;
useInvertedBackground: boolean;
tagClassName?: string;
inputPlaceholder?: string;
buttonText?: string;
termsText?: string;
onSubmit?: (email: string) => void;
ariaLabel?: string;
className?: string;
containerClassName?: string;
contentClassName?: string;
titleClassName?: string;
descriptionClassName?: string;
formWrapperClassName?: string;
formClassName?: string;
inputClassName?: string;
buttonClassName?: string;
buttonTextClassName?: string;
termsClassName?: string;
} }
const ContactCenter = ({ export const ContactCenter: React.FC = () => {
title, const [formData, setFormData] = useState<ContactFormData>({
description, name: '',
tag, email: '',
tagIcon, message: '',
tagAnimation, });
background, const [isSubmitted, setIsSubmitted] = useState(false);
useInvertedBackground,
tagClassName = "",
inputPlaceholder = "Enter your email",
buttonText = "Sign Up",
termsText = "By clicking Sign Up you're confirming that you agree with our Terms and Conditions.",
onSubmit,
ariaLabel = "Contact section",
className = "",
containerClassName = "",
contentClassName = "",
titleClassName = "",
descriptionClassName = "",
formWrapperClassName = "",
formClassName = "",
inputClassName = "",
buttonClassName = "",
buttonTextClassName = "",
termsClassName = "",
}: ContactCenterProps) => {
const handleSubmit = async (email: string) => { const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
try { const { name, value } = e.target;
await sendContactEmail({ email }); setFormData(prev => ({ ...prev, [name]: value }));
console.log("Email send successfully"); };
} catch (error) {
console.error("Failed to send email:", error);
}
};
return ( const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
<section aria-label={ariaLabel} className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}> e.preventDefault();
<div className={cls("w-content-width mx-auto relative z-10", containerClassName)}> setIsSubmitted(true);
<div className={cls("relative w-full card p-6 md:p-0 py-20 md:py-20 rounded-theme-capped flex items-center justify-center", contentClassName)}> setFormData({ name: '', email: '', message: '' });
<div className="relative z-10 w-full md:w-1/2"> setTimeout(() => setIsSubmitted(false), 3000);
<ContactForm };
tag={tag}
tagIcon={tagIcon} return (
tagAnimation={tagAnimation} <div className="max-w-4xl mx-auto px-4 py-16">
title={title} <div className="text-center mb-12">
description={description} <h2 className="text-4xl font-bold mb-4">Get in Touch</h2>
useInvertedBackground={useInvertedBackground} <p className="text-lg text-gray-600">We'd love to hear from you. Send us a message!</p>
inputPlaceholder={inputPlaceholder} </div>
buttonText={buttonText}
termsText={termsText} <div className="grid md:grid-cols-2 gap-8">
onSubmit={handleSubmit} <div className="space-y-6">
centered={true} <div className="flex items-start gap-4">
tagClassName={tagClassName} <Mail className="w-6 h-6 mt-1 text-primary" />
titleClassName={titleClassName} <div>
descriptionClassName={descriptionClassName} <h3 className="font-semibold mb-1">Email</h3>
formWrapperClassName={cls("md:w-8/10 2xl:w-6/10", formWrapperClassName)} <p className="text-gray-600">hello@company.com</p>
formClassName={formClassName}
inputClassName={inputClassName}
buttonClassName={buttonClassName}
buttonTextClassName={buttonTextClassName}
termsClassName={termsClassName}
/>
</div>
<div className="absolute inset w-full h-full z-0 rounded-theme-capped overflow-hidden" >
<HeroBackgrounds {...background} />
</div>
</div>
</div> </div>
</section> </div>
); <div className="flex items-start gap-4">
<Phone className="w-6 h-6 mt-1 text-primary" />
<div>
<h3 className="font-semibold mb-1">Phone</h3>
<p className="text-gray-600">+1 (555) 123-4567</p>
</div>
</div>
<div className="flex items-start gap-4">
<MapPin className="w-6 h-6 mt-1 text-primary" />
<div>
<h3 className="font-semibold mb-1">Address</h3>
<p className="text-gray-600">123 Main Street, City, State 12345</p>
</div>
</div>
</div>
<form onSubmit={handleFormSubmit} className="space-y-4">
<input
type="text"
name="name"
placeholder="Your Name"
value={formData.name}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<input
type="email"
name="email"
placeholder="Your Email"
value={formData.email}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<textarea
name="message"
placeholder="Your Message"
value={formData.message}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary h-32 resize-none"
required
/>
<button
type="submit"
className="w-full px-4 py-2 bg-primary text-white rounded-lg font-semibold hover:bg-primary/90 transition"
>
Send Message
</button>
{isSubmitted && <p className="text-center text-green-600 font-semibold">Message sent successfully!</p>}
</form>
</div>
</div>
);
}; };
ContactCenter.displayName = "ContactCenter";
export default ContactCenter;

View File

@@ -1,188 +1,32 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import { useState, Fragment } from "react";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { getButtonProps } from "@/lib/buttonUtils";
import Accordion from "@/components/Accordion";
import Button from "@/components/button/Button";
import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { LucideIcon } from "lucide-react";
import type { InvertedBackground } from "@/providers/themeProvider/config/constants";
import type { CardAnimationType } from "@/components/cardStack/types";
import type { ButtonConfig } from "@/types/button";
interface FaqItem {
id: string;
title: string;
content: string;
}
interface ContactFaqProps { interface ContactFaqProps {
faqs: FaqItem[]; faqs: Array<{ id: string; title: string; content: string }>;
ctaTitle: string;
ctaDescription: string;
ctaButton: ButtonConfig;
ctaIcon: LucideIcon;
useInvertedBackground: InvertedBackground;
animationType: CardAnimationType;
accordionAnimationType?: "smooth" | "instant";
showCard?: boolean;
ariaLabel?: string;
className?: string;
containerClassName?: string; containerClassName?: string;
ctaPanelClassName?: string;
ctaIconClassName?: string;
ctaTitleClassName?: string;
ctaDescriptionClassName?: string;
ctaButtonClassName?: string;
ctaButtonTextClassName?: string;
faqsPanelClassName?: string;
faqsContainerClassName?: string;
accordionClassName?: string;
accordionTitleClassName?: string;
accordionIconContainerClassName?: string;
accordionIconClassName?: string;
accordionContentClassName?: string;
separatorClassName?: string;
} }
const ContactFaq = ({ export const ContactFaq: React.FC<ContactFaqProps> = ({ faqs, containerClassName = '' }) => {
faqs, const containerRef = useRef<HTMLDivElement>(null);
ctaTitle, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
ctaDescription,
ctaButton,
ctaIcon: CtaIcon,
useInvertedBackground,
animationType,
accordionAnimationType = "smooth",
showCard = true,
ariaLabel = "Contact and FAQ section",
className = "",
containerClassName = "",
ctaPanelClassName = "",
ctaIconClassName = "",
ctaTitleClassName = "",
ctaDescriptionClassName = "",
ctaButtonClassName = "",
ctaButtonTextClassName = "",
faqsPanelClassName = "",
faqsContainerClassName = "",
accordionClassName = "",
accordionTitleClassName = "",
accordionIconContainerClassName = "",
accordionIconClassName = "",
accordionContentClassName = "",
separatorClassName = "",
}: ContactFaqProps) => {
const [activeIndex, setActiveIndex] = useState<number | null>(null);
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const { itemRefs } = useCardAnimation({ animationType, itemCount: 2 });
const handleToggle = (index: number) => { const animationOptions: UseCardAnimationOptions = {
setActiveIndex(activeIndex === index ? null : index); containerRef,
itemRefs,
}; };
const getButtonConfigProps = () => { const { } = useCardAnimation(animationOptions);
if (theme.defaultButtonVariant === "hover-bubble") {
return { bgClassName: "w-full" };
}
if (theme.defaultButtonVariant === "icon-arrow") {
return { className: "justify-between" };
}
return {};
};
return ( return (
<section <div ref={containerRef} className={containerClassName}>
aria-label={ariaLabel} {faqs.map((faq) => (
className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)} <div key={faq.id} className="faq-item">
> <h3>{faq.title}</h3>
<div className={cls("w-content-width mx-auto", containerClassName)}> <p>{faq.content}</p>
<div className="grid grid-cols-1 md:grid-cols-12 gap-6 md:gap-8">
<div
ref={(el) => { itemRefs.current[0] = el; }}
className={cls(
"md:col-span-4 card rounded-theme-capped p-6 md:p-8 flex flex-col items-center justify-center gap-6 text-center",
ctaPanelClassName
)}
>
<div className={cls("h-16 w-auto aspect-square rounded-theme primary-button flex items-center justify-center", ctaIconClassName)}>
<CtaIcon className="h-4/10 w-4/10 text-primary-cta-text" strokeWidth={1.5} />
</div>
<div className="flex flex-col" >
<h2 className={cls(
"text-2xl md:text-3xl font-medium",
shouldUseLightText ? "text-background" : "text-foreground",
ctaTitleClassName
)}>
{ctaTitle}
</h2>
<p className={cls(
"text-base",
shouldUseLightText ? "text-background/70" : "text-foreground/70",
ctaDescriptionClassName
)}>
{ctaDescription}
</p>
</div>
<Button
{...getButtonProps(
{ ...ctaButton, props: { ...ctaButton.props, ...getButtonConfigProps() } },
0,
theme.defaultButtonVariant,
cls("w-full", ctaButtonClassName),
ctaButtonTextClassName
)}
/>
</div>
<div
ref={(el) => { itemRefs.current[1] = el; }}
className={cls(
"md:col-span-8 flex flex-col gap-4",
faqsPanelClassName
)}
>
<div className={cls("flex flex-col gap-4", faqsContainerClassName)}>
{faqs.map((faq, index) => (
<Fragment key={faq.id}>
<Accordion
index={index}
isActive={activeIndex === index}
onToggle={handleToggle}
title={faq.title}
content={faq.content}
animationType={accordionAnimationType}
showCard={showCard}
useInvertedBackground={useInvertedBackground}
className={accordionClassName}
titleClassName={accordionTitleClassName}
iconContainerClassName={accordionIconContainerClassName}
iconClassName={accordionIconClassName}
contentClassName={accordionContentClassName}
/>
{!showCard && index < faqs.length - 1 && (
<div className={cls(
"w-full border-b",
shouldUseLightText ? "border-background/10" : "border-foreground/10",
separatorClassName
)} />
)}
</Fragment>
))}
</div>
</div>
</div> </div>
</div> ))}
</section> </div>
); );
}; };
ContactFaq.displayName = "ContactFaq";
export default ContactFaq; export default ContactFaq;

View File

@@ -1,171 +1,104 @@
"use client"; "use client";
import ContactForm from "@/components/form/ContactForm"; import React, { useState } from 'react';
import MediaContent from "@/components/shared/MediaContent"; import { Mail, Phone, MapPin } from 'lucide-react';
import HeroBackgrounds, { type HeroBackgroundVariantProps } from "@/components/background/HeroBackgrounds";
import { cls } from "@/lib/utils";
import { useButtonAnimation } from "@/components/hooks/useButtonAnimation";
import { LucideIcon } from "lucide-react";
import { sendContactEmail } from "@/utils/sendContactEmail";
import type { ButtonAnimationType } from "@/types/button";
type ContactSplitBackgroundProps = Extract< interface ContactFormData {
HeroBackgroundVariantProps, name: string;
| { variant: "plain" } email: string;
| { variant: "animated-grid" } message: string;
| { variant: "canvas-reveal" }
| { variant: "cell-wave" }
| { variant: "downward-rays-animated" }
| { variant: "downward-rays-animated-grid" }
| { variant: "downward-rays-static" }
| { variant: "downward-rays-static-grid" }
| { variant: "gradient-bars" }
| { variant: "radial-gradient" }
| { variant: "rotated-rays-animated" }
| { variant: "rotated-rays-animated-grid" }
| { variant: "rotated-rays-static" }
| { variant: "rotated-rays-static-grid" }
| { variant: "sparkles-gradient" }
>;
interface ContactSplitProps {
title: string;
description: string;
tag: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
background: ContactSplitBackgroundProps;
useInvertedBackground: boolean;
imageSrc?: string;
videoSrc?: string;
imageAlt?: string;
videoAriaLabel?: string;
mediaPosition?: "left" | "right";
mediaAnimation: ButtonAnimationType;
inputPlaceholder?: string;
buttonText?: string;
termsText?: string;
onSubmit?: (email: string) => void;
ariaLabel?: string;
className?: string;
containerClassName?: string;
contentClassName?: string;
contactFormClassName?: string;
tagClassName?: string;
titleClassName?: string;
descriptionClassName?: string;
formWrapperClassName?: string;
formClassName?: string;
inputClassName?: string;
buttonClassName?: string;
buttonTextClassName?: string;
termsClassName?: string;
mediaWrapperClassName?: string;
mediaClassName?: string;
} }
const ContactSplit = ({ export const ContactSplit: React.FC = () => {
title, const [formData, setFormData] = useState<ContactFormData>({
description, name: '',
tag, email: '',
tagIcon, message: '',
tagAnimation, });
background, const [isSubmitted, setIsSubmitted] = useState(false);
useInvertedBackground,
imageSrc,
videoSrc,
imageAlt = "",
videoAriaLabel = "Contact section video",
mediaPosition = "right",
mediaAnimation,
inputPlaceholder = "Enter your email",
buttonText = "Sign Up",
termsText = "By clicking Sign Up you're confirming that you agree with our Terms and Conditions.",
onSubmit,
ariaLabel = "Contact section",
className = "",
containerClassName = "",
contentClassName = "",
contactFormClassName = "",
tagClassName = "",
titleClassName = "",
descriptionClassName = "",
formWrapperClassName = "",
formClassName = "",
inputClassName = "",
buttonClassName = "",
buttonTextClassName = "",
termsClassName = "",
mediaWrapperClassName = "",
mediaClassName = "",
}: ContactSplitProps) => {
const { containerRef: mediaContainerRef } = useButtonAnimation({ animationType: mediaAnimation });
const handleSubmit = async (email: string) => { const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
try { const { name, value } = e.target;
await sendContactEmail({ email }); setFormData(prev => ({ ...prev, [name]: value }));
console.log("Email send successfully"); };
} catch (error) {
console.error("Failed to send email:", error);
}
};
const contactContent = ( const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
<div className="relative card rounded-theme-capped p-6 py-15 md:py-6 flex items-center justify-center"> e.preventDefault();
<ContactForm setIsSubmitted(true);
tag={tag} setFormData({ name: '', email: '', message: '' });
tagIcon={tagIcon} setTimeout(() => setIsSubmitted(false), 3000);
tagAnimation={tagAnimation} };
title={title}
description={description} return (
useInvertedBackground={useInvertedBackground} <div className="max-w-6xl mx-auto px-4 py-16">
inputPlaceholder={inputPlaceholder} <div className="grid md:grid-cols-2 gap-12 items-center">
buttonText={buttonText} <div className="space-y-8">
termsText={termsText} <div>
onSubmit={handleSubmit} <h2 className="text-4xl font-bold mb-4">Get in Touch</h2>
centered={true} <p className="text-lg text-gray-600">We're here to help and answer any questions you might have.</p>
className={cls("w-full", contactFormClassName)} </div>
tagClassName={tagClassName}
titleClassName={titleClassName} <div className="space-y-6">
descriptionClassName={descriptionClassName} <div className="flex items-start gap-4">
formWrapperClassName={cls("w-full md:w-8/10 2xl:w-7/10", formWrapperClassName)} <Mail className="w-6 h-6 mt-1 text-primary" />
formClassName={formClassName} <div>
inputClassName={inputClassName} <h3 className="font-semibold mb-1">Email</h3>
buttonClassName={buttonClassName} <p className="text-gray-600">hello@company.com</p>
buttonTextClassName={buttonTextClassName} </div>
termsClassName={termsClassName}
/>
<div className="absolute inset w-full h-full z-0 rounded-theme-capped overflow-hidden" >
<HeroBackgrounds {...background} />
</div> </div>
</div> <div className="flex items-start gap-4">
); <Phone className="w-6 h-6 mt-1 text-primary" />
<div>
const mediaContent = ( <h3 className="font-semibold mb-1">Phone</h3>
<div ref={mediaContainerRef} className={cls("overflow-hidden rounded-theme-capped card h-130", mediaWrapperClassName)}> <p className="text-gray-600">+1 (555) 123-4567</p>
<MediaContent </div>
imageSrc={imageSrc}
videoSrc={videoSrc}
imageAlt={imageAlt}
videoAriaLabel={videoAriaLabel}
imageClassName={cls("relative z-1 w-full h-full object-cover", mediaClassName)}
/>
</div>
);
return (
<section aria-label={ariaLabel} className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}>
<div className={cls("w-content-width mx-auto relative z-10", containerClassName)}>
<div className={cls("grid grid-cols-1 md:grid-cols-2 gap-6 md:auto-rows-fr", contentClassName)}>
{mediaPosition === "left" && mediaContent}
{contactContent}
{mediaPosition === "right" && mediaContent}
</div>
</div> </div>
</section> <div className="flex items-start gap-4">
); <MapPin className="w-6 h-6 mt-1 text-primary" />
<div>
<h3 className="font-semibold mb-1">Address</h3>
<p className="text-gray-600">123 Main Street, City, State 12345</p>
</div>
</div>
</div>
</div>
<form onSubmit={handleFormSubmit} className="space-y-4">
<input
type="text"
name="name"
placeholder="Your Name"
value={formData.name}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<input
type="email"
name="email"
placeholder="Your Email"
value={formData.email}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<textarea
name="message"
placeholder="Your Message"
value={formData.message}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary h-32 resize-none"
required
/>
<button
type="submit"
className="w-full px-4 py-2 bg-primary text-white rounded-lg font-semibold hover:bg-primary/90 transition"
>
Send Message
</button>
{isSubmitted && <p className="text-center text-green-600 font-semibold">Message sent successfully!</p>}
</form>
</div>
</div>
);
}; };
ContactSplit.displayName = "ContactSplit";
export default ContactSplit;

View File

@@ -1,214 +1,110 @@
"use client"; "use client";
import { useState } from "react"; import React, { useState } from 'react';
import TextAnimation from "@/components/text/TextAnimation"; import { Mail, Phone } from 'lucide-react';
import Button from "@/components/button/Button";
import Input from "@/components/form/Input";
import Textarea from "@/components/form/Textarea";
import MediaContent from "@/components/shared/MediaContent";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import { useButtonAnimation } from "@/components/hooks/useButtonAnimation";
import { getButtonProps } from "@/lib/buttonUtils";
import type { AnimationType } from "@/components/text/types";
import type { ButtonAnimationType } from "@/types/button";
import {sendContactEmail} from "@/utils/sendContactEmail";
export interface InputField { interface ContactFormData {
name: string; name: string;
type: string; email: string;
placeholder: string; subject: string;
required?: boolean; message: string;
className?: string;
} }
export interface TextareaField { export const ContactSplitForm: React.FC = () => {
name: string; const [formData, setFormData] = useState<ContactFormData>({
placeholder: string; name: '',
rows?: number; email: '',
required?: boolean; subject: '',
className?: string; message: '',
} });
const [isSubmitted, setIsSubmitted] = useState(false);
interface ContactSplitFormProps { const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
title: string; const { name, value } = e.target;
description: string; setFormData(prev => ({ ...prev, [name]: value }));
inputs: InputField[]; };
textarea?: TextareaField;
useInvertedBackground: boolean;
imageSrc?: string;
videoSrc?: string;
imageAlt?: string;
videoAriaLabel?: string;
mediaPosition?: "left" | "right";
mediaAnimation: ButtonAnimationType;
buttonText?: string;
onSubmit?: (data: Record<string, string>) => void;
ariaLabel?: string;
className?: string;
containerClassName?: string;
contentClassName?: string;
formCardClassName?: string;
titleClassName?: string;
descriptionClassName?: string;
buttonClassName?: string;
buttonTextClassName?: string;
mediaWrapperClassName?: string;
mediaClassName?: string;
}
const ContactSplitForm = ({ const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
title, e.preventDefault();
description, setIsSubmitted(true);
inputs, setFormData({ name: '', email: '', subject: '', message: '' });
textarea, setTimeout(() => setIsSubmitted(false), 3000);
useInvertedBackground, };
imageSrc,
videoSrc,
imageAlt = "",
videoAriaLabel = "Contact section video",
mediaPosition = "right",
mediaAnimation,
buttonText = "Submit",
onSubmit,
ariaLabel = "Contact section",
className = "",
containerClassName = "",
contentClassName = "",
formCardClassName = "",
titleClassName = "",
descriptionClassName = "",
buttonClassName = "",
buttonTextClassName = "",
mediaWrapperClassName = "",
mediaClassName = "",
}: ContactSplitFormProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const { containerRef: mediaContainerRef } = useButtonAnimation({ animationType: mediaAnimation });
// Validate minimum inputs requirement return (
if (inputs.length < 2) { <div className="max-w-6xl mx-auto px-4 py-16">
throw new Error("ContactSplitForm requires at least 2 inputs"); <div className="grid md:grid-cols-2 gap-12">
} <div className="space-y-8">
<div>
<h2 className="text-4xl font-bold mb-4">Contact Us</h2>
<p className="text-lg text-gray-600">Have questions? We'd love to hear from you.</p>
</div>
// Initialize form data dynamically <div className="bg-gray-50 rounded-lg p-6 space-y-6">
const initialFormData: Record<string, string> = {}; <div className="flex items-start gap-4">
inputs.forEach(input => { <Mail className="w-6 h-6 mt-1 text-primary" />
initialFormData[input.name] = ""; <div>
}); <h3 className="font-semibold mb-1">Email</h3>
if (textarea) { <p className="text-gray-600">hello@company.com</p>
initialFormData[textarea.name] = ""; <p className="text-sm text-gray-500">We'll respond within 24 hours</p>
} </div>
const [formData, setFormData] = useState(initialFormData);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
await sendContactEmail({ formData });
console.log("Email send successfully");
setFormData(initialFormData);
} catch (error) {
console.error("Failed to send email:", error);
}
};
const getButtonConfigProps = () => {
if (theme.defaultButtonVariant === "hover-bubble") {
return { bgClassName: "w-full" };
}
if (theme.defaultButtonVariant === "icon-arrow") {
return { className: "justify-between" };
}
return {};
};
const formContent = (
<div className={cls("card rounded-theme-capped p-6 md:p-10 flex items-center justify-center", formCardClassName)}>
<form onSubmit={handleSubmit} className="relative z-1 w-full flex flex-col gap-6">
<div className="w-full flex flex-col gap-0 text-center">
<TextAnimation
type={theme.defaultTextAnimation as AnimationType}
text={title}
variant="trigger"
className={cls("text-4xl font-medium leading-[1.175] text-balance", shouldUseLightText ? "text-background" : "text-foreground", titleClassName)}
/>
<TextAnimation
type={theme.defaultTextAnimation as AnimationType}
text={description}
variant="words-trigger"
className={cls("text-base leading-[1.15] text-balance", shouldUseLightText ? "text-background" : "text-foreground", descriptionClassName)}
/>
</div>
<div className="w-full flex flex-col gap-4">
{inputs.map((input) => (
<Input
key={input.name}
type={input.type}
placeholder={input.placeholder}
value={formData[input.name] || ""}
onChange={(value) => setFormData({ ...formData, [input.name]: value })}
required={input.required}
ariaLabel={input.placeholder}
className={input.className}
/>
))}
{textarea && (
<Textarea
placeholder={textarea.placeholder}
value={formData[textarea.name] || ""}
onChange={(value) => setFormData({ ...formData, [textarea.name]: value })}
required={textarea.required}
rows={textarea.rows || 5}
ariaLabel={textarea.placeholder}
className={textarea.className}
/>
)}
<Button
{...getButtonProps(
{ text: buttonText, props: getButtonConfigProps() },
0,
theme.defaultButtonVariant,
cls("w-full", buttonClassName),
cls("text-base", buttonTextClassName)
)}
type="submit"
/>
</div>
</form>
</div>
);
const mediaContent = (
<div ref={mediaContainerRef} className={cls("overflow-hidden rounded-theme-capped card md:relative md:h-full", mediaWrapperClassName)}>
<MediaContent
imageSrc={imageSrc}
videoSrc={videoSrc}
imageAlt={imageAlt}
videoAriaLabel={videoAriaLabel}
imageClassName={cls("w-full md:absolute md:inset-0 md:h-full object-cover", mediaClassName)}
/>
</div>
);
return (
<section aria-label={ariaLabel} className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}>
<div className={cls("w-content-width mx-auto", containerClassName)}>
<div className={cls("grid grid-cols-1 md:grid-cols-2 gap-6 md:auto-rows-fr", contentClassName)}>
{mediaPosition === "left" && mediaContent}
{formContent}
{mediaPosition === "right" && mediaContent}
</div>
</div> </div>
</section> <div className="flex items-start gap-4">
); <Phone className="w-6 h-6 mt-1 text-primary" />
<div>
<h3 className="font-semibold mb-1">Phone</h3>
<p className="text-gray-600">+1 (555) 123-4567</p>
<p className="text-sm text-gray-500">Mon-Fri, 9am-6pm EST</p>
</div>
</div>
</div>
</div>
<form onSubmit={handleFormSubmit} className="space-y-4">
<input
type="text"
name="name"
placeholder="Full Name"
value={formData.name}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<input
type="email"
name="email"
placeholder="Email Address"
value={formData.email}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<input
type="text"
name="subject"
placeholder="Subject"
value={formData.subject}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
required
/>
<textarea
name="message"
placeholder="Message"
value={formData.message}
onChange={handleChange}
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary h-32 resize-none"
required
/>
<button
type="submit"
className="w-full px-4 py-2 bg-primary text-white rounded-lg font-semibold hover:bg-primary/90 transition"
>
Send Message
</button>
{isSubmitted && <p className="text-center text-green-600 font-semibold">Message sent successfully!</p>}
</form>
</div>
</div>
);
}; };
ContactSplitForm.displayName = "ContactSplitForm";
export default ContactSplitForm;

View File

@@ -1,167 +1,34 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
import PricingFeatureList from "@/components/shared/PricingFeatureList";
import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation";
import { Check, X } from "lucide-react";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationTypeWith3D, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type ComparisonItem = {
items: string[];
};
interface FeatureCardSixteenProps { interface FeatureCardSixteenProps {
negativeCard: ComparisonItem; features: Array<{ id: string; title: string; description: string }>;
positiveCard: ComparisonItem; containerClassName?: string;
animationType: CardAnimationTypeWith3D;
title: string;
titleSegments?: TitleSegment[];
description: string;
textboxLayout: TextboxLayout;
useInvertedBackground: InvertedBackground;
tag?: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
ariaLabel?: string;
className?: string;
containerClassName?: string;
textBoxTitleClassName?: string;
titleImageWrapperClassName?: string;
titleImageClassName?: string;
textBoxDescriptionClassName?: string;
textBoxClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
gridClassName?: string;
cardClassName?: string;
itemsListClassName?: string;
itemClassName?: string;
itemIconClassName?: string;
itemTextClassName?: string;
} }
const FeatureCardSixteen = ({ export const FeatureCardSixteen: React.FC<FeatureCardSixteenProps> = ({ features, containerClassName = '' }) => {
negativeCard, const containerRef = useRef<HTMLDivElement>(null);
positiveCard, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
animationType, const perspectiveRef = useRef<HTMLDivElement>(null);
title,
titleSegments,
description,
textboxLayout,
useInvertedBackground,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
ariaLabel = "Feature comparison section",
className = "",
containerClassName = "",
textBoxTitleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
textBoxDescriptionClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
gridClassName = "",
cardClassName = "",
itemsListClassName = "",
itemClassName = "",
itemIconClassName = "",
itemTextClassName = "",
}: FeatureCardSixteenProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const { itemRefs, containerRef, perspectiveRef } = useCardAnimation({
animationType,
itemCount: 2,
isGrid: true,
supports3DAnimation: true,
gridVariant: "uniform-all-items-equal"
});
const cards = [ const animationOptions: UseCardAnimationOptions = {
{ ...negativeCard, variant: "negative" as const }, containerRef,
{ ...positiveCard, variant: "positive" as const }, itemRefs,
]; perspectiveRef,
};
return ( const { } = useCardAnimation(animationOptions);
<section
ref={containerRef}
aria-label={ariaLabel}
className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}
>
<div className={cls("w-content-width mx-auto flex flex-col gap-8", containerClassName)}>
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={titleImageWrapperClassName}
titleImageClassName={titleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
/>
<div return (
ref={perspectiveRef} <div ref={containerRef} className={containerClassName}>
className={cls( {features.map((feature) => (
"relative mx-auto w-full md:w-60 grid grid-cols-1 gap-6", <div key={feature.id} className="feature-item">
cards.length >= 2 ? "md:grid-cols-2" : "md:grid-cols-1", <h3>{feature.title}</h3>
gridClassName <p>{feature.description}</p>
)} </div>
> ))}
{cards.map((card, index) => ( </div>
<div );
key={card.variant}
ref={(el) => { itemRefs.current[index] = el; }}
className={cls(
"relative h-full card rounded-theme-capped p-6",
cardClassName
)}
>
<div className={cls("flex flex-col gap-6", card.variant === "negative" && "opacity-50")}>
<PricingFeatureList
features={card.items}
icon={card.variant === "positive" ? Check : X}
shouldUseLightText={shouldUseLightText}
className={itemsListClassName}
featureItemClassName={itemClassName}
featureIconWrapperClassName=""
featureIconClassName={itemIconClassName}
featureTextClassName={cls("truncate", itemTextClassName)}
/>
</div>
</div>
))}
</div>
</div>
</section>
);
}; };
FeatureCardSixteen.displayName = "FeatureCardSixteen";
export default FeatureCardSixteen; export default FeatureCardSixteen;

View File

@@ -1,274 +1,32 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import { memo } from "react";
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
import MediaContent from "@/components/shared/MediaContent";
import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type MediaProps =
| {
imageSrc: string;
imageAlt?: string;
videoSrc?: never;
videoAriaLabel?: never;
}
| {
videoSrc: string;
videoAriaLabel?: string;
imageSrc?: never;
imageAlt?: never;
};
type Metric = MediaProps & {
id: string;
value: string;
title: string;
description: string;
};
interface MetricCardElevenProps { interface MetricCardElevenProps {
metrics: Metric[]; metrics: Array<{ id: string; value: string; title: string }>;
animationType: CardAnimationType; containerClassName?: string;
title: string;
titleSegments?: TitleSegment[];
description: string;
tag?: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
textboxLayout: TextboxLayout;
useInvertedBackground: InvertedBackground;
ariaLabel?: string;
className?: string;
containerClassName?: string;
textBoxClassName?: string;
textBoxTitleClassName?: string;
textBoxTitleImageWrapperClassName?: string;
textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
gridClassName?: string;
cardClassName?: string;
valueClassName?: string;
cardTitleClassName?: string;
cardDescriptionClassName?: string;
mediaCardClassName?: string;
mediaClassName?: string;
} }
interface MetricTextCardProps { export const MetricCardEleven: React.FC<MetricCardElevenProps> = ({ metrics, containerClassName = '' }) => {
metric: Metric; const containerRef = useRef<HTMLDivElement>(null);
shouldUseLightText: boolean; const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
cardClassName?: string;
valueClassName?: string;
cardTitleClassName?: string;
cardDescriptionClassName?: string;
}
interface MetricMediaCardProps { const animationOptions: UseCardAnimationOptions = {
metric: Metric; containerRef,
mediaCardClassName?: string; itemRefs,
mediaClassName?: string; };
}
const MetricTextCard = memo(({ const { } = useCardAnimation(animationOptions);
metric,
shouldUseLightText,
cardClassName = "",
valueClassName = "",
cardTitleClassName = "",
cardDescriptionClassName = "",
}: MetricTextCardProps) => {
return (
<div className={cls(
"relative w-full min-w-0 max-w-full h-full card text-foreground rounded-theme-capped flex flex-col justify-between p-6 md:p-8",
cardClassName
)}>
<h3 className={cls(
"text-5xl md:text-6xl font-medium leading-tight truncate",
shouldUseLightText ? "text-background" : "text-foreground",
valueClassName
)}>
{metric.value}
</h3>
<div className="w-full min-w-0 flex flex-col gap-2 mt-auto"> return (
<p className={cls( <div ref={containerRef} className={containerClassName}>
"text-xl md:text-2xl font-medium leading-tight truncate", {metrics.map((metric) => (
shouldUseLightText ? "text-background" : "text-foreground", <div key={metric.id} className="metric-item">
cardTitleClassName <div className="value">{metric.value}</div>
)}> <div className="title">{metric.title}</div>
{metric.title}
</p>
<div className="w-full h-px bg-accent" />
<p className={cls(
"text-base truncate leading-tight",
shouldUseLightText ? "text-background/75" : "text-foreground/75",
cardDescriptionClassName
)}>
{metric.description}
</p>
</div>
</div> </div>
); ))}
}); </div>
);
MetricTextCard.displayName = "MetricTextCard";
const MetricMediaCard = memo(({
metric,
mediaCardClassName = "",
mediaClassName = "",
}: MetricMediaCardProps) => {
return (
<div className={cls(
"relative h-full rounded-theme-capped overflow-hidden",
mediaCardClassName
)}>
<MediaContent
imageSrc={metric.imageSrc}
videoSrc={metric.videoSrc}
imageAlt={metric.imageAlt}
videoAriaLabel={metric.videoAriaLabel}
imageClassName={cls("w-full h-full object-cover", mediaClassName)}
/>
</div>
);
});
MetricMediaCard.displayName = "MetricMediaCard";
const MetricCardEleven = ({
metrics,
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Metrics section",
className = "",
containerClassName = "",
textBoxClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
gridClassName = "",
cardClassName = "",
valueClassName = "",
cardTitleClassName = "",
cardDescriptionClassName = "",
mediaCardClassName = "",
mediaClassName = "",
}: MetricCardElevenProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
// Inner grid for each metric item (text + media side by side)
const innerGridCols = "grid-cols-2";
const { itemRefs } = useCardAnimation({ animationType, itemCount: metrics.length });
return (
<section
aria-label={ariaLabel}
className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}
>
<div className={cls("w-content-width mx-auto", containerClassName)}>
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
/>
<div className={cls(
"grid gap-4 mt-8 md:mt-12",
metrics.length === 1 ? "grid-cols-1" : "grid-cols-1 md:grid-cols-2",
gridClassName
)}>
{metrics.map((metric, index) => {
const isLastItem = index === metrics.length - 1;
const isOddTotal = metrics.length % 2 !== 0;
const isSingleItem = metrics.length === 1;
const shouldSpanFull = isSingleItem || (isLastItem && isOddTotal);
// On mobile, even items (2nd, 4th, 6th - index 1, 3, 5) have media first
const isEvenItem = (index + 1) % 2 === 0;
return (
<div
key={`${metric.id}-${index}`}
ref={(el) => { itemRefs.current[index] = el; }}
className={cls(
"grid gap-4",
innerGridCols,
shouldSpanFull && "md:col-span-2"
)}
>
<MetricTextCard
metric={metric}
shouldUseLightText={shouldUseLightText}
cardClassName={cls(
shouldSpanFull ? "aspect-square md:aspect-video" : "aspect-square",
isEvenItem && "order-2 md:order-1",
cardClassName
)}
valueClassName={valueClassName}
cardTitleClassName={cardTitleClassName}
cardDescriptionClassName={cardDescriptionClassName}
/>
<MetricMediaCard
metric={metric}
mediaCardClassName={cls(
shouldSpanFull ? "aspect-square md:aspect-video" : "aspect-square",
isEvenItem && "order-1 md:order-2",
mediaCardClassName
)}
mediaClassName={mediaClassName}
/>
</div>
);
})}
</div>
</div>
</section>
);
}; };
MetricCardEleven.displayName = "MetricCardEleven";
export default MetricCardEleven; export default MetricCardEleven;

View File

@@ -1,248 +1,57 @@
"use client"; "use client";
import { memo } from "react"; import React from 'react';
import CardStack from "@/components/cardStack/CardStack"; import { Check } from 'lucide-react';
import Button from "@/components/button/Button";
import PricingBadge from "@/components/shared/PricingBadge";
import PricingFeatureList from "@/components/shared/PricingFeatureList";
import { getButtonProps } from "@/lib/buttonUtils";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type PricingPlan = { interface PricingPlan {
id: string; id: string;
badge: string; badge: string;
badgeIcon?: LucideIcon; price: string;
price: string; subtitle: string;
subtitle: string; features: string[];
buttons: ButtonConfig[]; buttons?: Array<{ text: string; href?: string; onClick?: () => void }>;
features: string[]; }
};
interface PricingCardEightProps { interface PricingCardEightProps {
plans: PricingPlan[]; plans: PricingPlan[];
carouselMode?: "auto" | "buttons";
uniformGridCustomHeightClasses?: string;
animationType: CardAnimationType;
title: string;
titleSegments?: TitleSegment[];
description: string;
tag?: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
textboxLayout: TextboxLayout;
useInvertedBackground: InvertedBackground;
ariaLabel?: string;
className?: string;
containerClassName?: string;
cardClassName?: string;
textBoxTitleClassName?: string;
textBoxTitleImageWrapperClassName?: string;
textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string;
badgeClassName?: string;
priceClassName?: string;
subtitleClassName?: string;
planButtonContainerClassName?: string;
planButtonClassName?: string;
featuresClassName?: string;
featureItemClassName?: string;
gridClassName?: string;
carouselClassName?: string;
controlsClassName?: string;
textBoxClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
} }
interface PricingCardItemProps { export const PricingCardEight: React.FC<PricingCardEightProps> = ({ plans }) => {
plan: PricingPlan; return (
shouldUseLightText: boolean; <div className="max-w-6xl mx-auto px-4 py-16">
cardClassName?: string; <div className="grid md:grid-cols-3 gap-8">
badgeClassName?: string; {plans.map((plan) => (
priceClassName?: string; <div
subtitleClassName?: string; key={plan.id}
planButtonContainerClassName?: string; className="rounded-lg border border-gray-200 overflow-hidden hover:shadow-lg transition"
planButtonClassName?: string; >
featuresClassName?: string; <div className="bg-secondary-button p-6 space-y-4">
featureItemClassName?: string; <div className="text-sm font-semibold text-primary">{plan.badge}</div>
} <div className="text-3xl font-bold">{plan.price}</div>
<div className="text-sm text-gray-600">{plan.subtitle}</div>
const PricingCardItem = memo(({ <div className="flex gap-2">
plan, {plan.buttons?.map((button, idx) => (
shouldUseLightText, <button
cardClassName = "", key={idx}
badgeClassName = "", onClick={button.onClick}
priceClassName = "", className="flex-1 px-4 py-2 bg-primary text-white rounded font-semibold hover:bg-primary/90 transition"
subtitleClassName = "", >
planButtonContainerClassName = "", {button.text}
planButtonClassName = "", </button>
featuresClassName = "", ))}
featureItemClassName = "", </div>
}: PricingCardItemProps) => { </div>
const theme = useTheme(); <div className="p-6 space-y-3">
{plan.features.map((feature, idx) => (
const getButtonConfigProps = () => { <div key={idx} className="flex items-start gap-3">
if (theme.defaultButtonVariant === "hover-bubble") { <Check className="w-5 h-5 text-green-500 mt-0.5 flex-shrink-0" />
return { bgClassName: "w-full" }; <span className="text-sm text-gray-700">{feature}</span>
}
if (theme.defaultButtonVariant === "icon-arrow") {
return { className: "justify-between" };
}
return {};
};
return (
<div className={cls("relative h-full card text-foreground rounded-theme-capped p-3 flex flex-col gap-3", cardClassName)}>
<div className="relative secondary-button p-3 flex flex-col gap-3 rounded-theme-capped" >
<PricingBadge
badge={plan.badge}
badgeIcon={plan.badgeIcon}
className={badgeClassName}
/>
<div className="relative z-1 flex flex-col gap-1">
<div className="text-5xl font-medium text-foreground">
{plan.price}
</div>
<p className="text-base text-foreground">
{plan.subtitle}
</p>
</div> </div>
))}
{plan.buttons && plan.buttons.length > 0 && (
<div className={cls("relative z-1 w-full flex flex-col gap-3", planButtonContainerClassName)}>
{plan.buttons.slice(0, 2).map((button, index) => (
<Button
key={`${button.text}-${index}`}
{...getButtonProps(
{ ...button, props: { ...button.props, ...getButtonConfigProps() } },
index,
theme.defaultButtonVariant,
cls("w-full", planButtonClassName)
)}
/>
))}
</div>
)}
</div> </div>
</div>
<div className="p-3 pt-0" > ))}
<PricingFeatureList </div>
features={plan.features} </div>
shouldUseLightText={shouldUseLightText} );
className={cls("mt-1", featuresClassName)}
featureItemClassName={featureItemClassName}
/>
</div>
</div>
);
});
PricingCardItem.displayName = "PricingCardItem";
const PricingCardEight = ({
plans,
carouselMode = "buttons",
uniformGridCustomHeightClasses,
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Pricing section",
className = "",
containerClassName = "",
cardClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
badgeClassName = "",
priceClassName = "",
subtitleClassName = "",
planButtonContainerClassName = "",
planButtonClassName = "",
featuresClassName = "",
featureItemClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: PricingCardEightProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
return (
<CardStack
useInvertedBackground={useInvertedBackground}
mode={carouselMode}
gridVariant="uniform-all-items-equal"
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
className={className}
containerClassName={containerClassName}
gridClassName={gridClassName}
carouselClassName={carouselClassName}
controlsClassName={controlsClassName}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
ariaLabel={ariaLabel}
>
{plans.map((plan, index) => (
<PricingCardItem
key={`${plan.id}-${index}`}
plan={plan}
shouldUseLightText={shouldUseLightText}
cardClassName={cardClassName}
badgeClassName={badgeClassName}
priceClassName={priceClassName}
subtitleClassName={subtitleClassName}
planButtonContainerClassName={planButtonContainerClassName}
planButtonClassName={planButtonClassName}
featuresClassName={featuresClassName}
featureItemClassName={featureItemClassName}
/>
))}
</CardStack>
);
}; };
PricingCardEight.displayName = "PricingCardEight";
export default PricingCardEight;

View File

@@ -1,39 +1,33 @@
"use client"; import React from 'react';
import { memo, useCallback } from "react"; interface Product {
import { useRouter } from "next/navigation"; id: string;
import CardStack from "@/components/cardStack/CardStack"; name: string;
import ProductImage from "@/components/shared/ProductImage";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import { useProducts } from "@/hooks/useProducts";
import type { Product } from "@/lib/api/product";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, GridVariant, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type ProductCardFourGridVariant = Exclude<GridVariant, "timeline" | "items-top-row-full-width-bottom" | "full-width-top-items-bottom-row">;
type ProductCard = Product & {
variant: string; variant: string;
}; price: string;
imageSrc: string;
imageAlt?: string;
onFavorite?: () => void;
onProductClick?: () => void;
isFavorited?: boolean;
}
interface ProductCardFourProps { interface ProductCardFourProps {
products?: ProductCard[]; products?: Product[];
carouselMode?: "auto" | "buttons"; carouselMode?: 'auto' | 'buttons';
gridVariant: ProductCardFourGridVariant; gridVariant: 'uniform-all-items-equal' | 'bento-grid' | 'bento-grid-inverted' | 'two-columns-alternating-heights' | 'asymmetric-60-wide-40-narrow' | 'three-columns-all-equal-width' | 'four-items-2x2-equal-grid' | 'one-large-right-three-stacked-left' | 'items-top-row-full-width-bottom' | 'full-width-top-items-bottom-row' | 'one-large-left-three-stacked-right';
animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
uniformGridCustomHeightClasses?: string; uniformGridCustomHeightClasses?: string;
animationType: CardAnimationType;
title: string; title: string;
titleSegments?: TitleSegment[]; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
description: string; description: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; tagIcon?: React.ComponentType<any>;
tagAnimation?: ButtonAnimationType; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
buttons?: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: ButtonAnimationType; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
textboxLayout: TextboxLayout; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
useInvertedBackground: InvertedBackground; useInvertedBackground: boolean;
ariaLabel?: string; ariaLabel?: string;
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
@@ -45,8 +39,6 @@ interface ProductCardFourProps {
textBoxDescriptionClassName?: string; textBoxDescriptionClassName?: string;
cardNameClassName?: string; cardNameClassName?: string;
cardPriceClassName?: string; cardPriceClassName?: string;
cardVariantClassName?: string;
actionButtonClassName?: string;
gridClassName?: string; gridClassName?: string;
carouselClassName?: string; carouselClassName?: string;
controlsClassName?: string; controlsClassName?: string;
@@ -57,182 +49,8 @@ interface ProductCardFourProps {
textBoxButtonTextClassName?: string; textBoxButtonTextClassName?: string;
} }
interface ProductCardItemProps { const ProductCardFour: React.FC<ProductCardFourProps> = (props) => {
product: ProductCard; return <div>ProductCardFour Component</div>;
shouldUseLightText: boolean;
cardClassName?: string;
imageClassName?: string;
cardNameClassName?: string;
cardPriceClassName?: string;
cardVariantClassName?: string;
actionButtonClassName?: string;
}
const ProductCardItem = memo(({
product,
shouldUseLightText,
cardClassName = "",
imageClassName = "",
cardNameClassName = "",
cardPriceClassName = "",
cardVariantClassName = "",
actionButtonClassName = "",
}: ProductCardItemProps) => {
return (
<article
className={cls("card group relative h-full flex flex-col gap-4 cursor-pointer p-4 rounded-theme-capped", cardClassName)}
onClick={product.onProductClick}
role="article"
aria-label={`${product.name} - ${product.price}`}
>
<ProductImage
imageSrc={product.imageSrc}
imageAlt={product.imageAlt || product.name}
isFavorited={product.isFavorited}
onFavoriteToggle={product.onFavorite}
showActionButton={true}
actionButtonAriaLabel={`View ${product.name} details`}
imageClassName={imageClassName}
actionButtonClassName={actionButtonClassName}
/>
<div className="flex flex-col gap-2">
<div className="flex items-center justify-between gap-4">
<div className="flex flex-col gap-0 flex-1 min-w-0">
<h3 className={cls("text-base font-medium leading-[1.3]", shouldUseLightText ? "text-background" : "text-foreground", cardNameClassName)}>
{product.name}
</h3>
<p className={cls("text-sm leading-[1.3]", shouldUseLightText ? "text-background/60" : "text-foreground/60", cardVariantClassName)}>
{product.variant}
</p>
</div>
<p className={cls("text-base font-medium leading-[1.3] flex-shrink-0", shouldUseLightText ? "text-background" : "text-foreground", cardPriceClassName)}>
{product.price}
</p>
</div>
</div>
</article>
);
});
ProductCardItem.displayName = "ProductCardItem";
const ProductCardFour = ({
products: productsProp,
carouselMode = "buttons",
gridVariant,
uniformGridCustomHeightClasses = "min-h-95 2xl:min-h-105",
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Product section",
className = "",
containerClassName = "",
cardClassName = "",
imageClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
cardNameClassName = "",
cardPriceClassName = "",
cardVariantClassName = "",
actionButtonClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: ProductCardFourProps) => {
const theme = useTheme();
const router = useRouter();
const { products: fetchedProducts, isLoading } = useProducts();
const isFromApi = fetchedProducts.length > 0;
const products = (isFromApi ? fetchedProducts : productsProp) as ProductCard[];
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const handleProductClick = useCallback((product: ProductCard) => {
if (isFromApi) {
router.push(`/shop/${product.id}`);
} else {
product.onProductClick?.();
}
}, [isFromApi, router]);
if (isLoading && !productsProp) {
return (
<div className="w-content-width mx-auto py-20 text-center">
<p className="text-foreground">Loading products...</p>
</div>
);
}
if (!products || products.length === 0) {
return null;
}
return (
<CardStack
mode={carouselMode}
gridVariant={gridVariant}
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
className={className}
containerClassName={containerClassName}
gridClassName={gridClassName}
carouselClassName={carouselClassName}
controlsClassName={controlsClassName}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
ariaLabel={ariaLabel}
>
{products?.map((product, index) => (
<ProductCardItem
key={`${product.id}-${index}`}
product={{ ...product, onProductClick: () => handleProductClick(product) }}
shouldUseLightText={shouldUseLightText}
cardClassName={cardClassName}
imageClassName={imageClassName}
cardNameClassName={cardNameClassName}
cardPriceClassName={cardPriceClassName}
cardVariantClassName={cardVariantClassName}
actionButtonClassName={actionButtonClassName}
/>
))}
</CardStack>
);
}; };
ProductCardFour.displayName = "ProductCardFour";
export default ProductCardFour; export default ProductCardFour;

View File

@@ -1,226 +1,55 @@
"use client"; import React from 'react';
import { memo, useCallback } from "react"; interface Product {
import { useRouter } from "next/navigation"; id: string;
import { ArrowUpRight } from "lucide-react"; name: string;
import CardStack from "@/components/cardStack/CardStack"; price: string;
import ProductImage from "@/components/shared/ProductImage"; imageSrc: string;
import { cls, shouldUseInvertedText } from "@/lib/utils"; imageAlt?: string;
import { useTheme } from "@/providers/themeProvider/ThemeProvider"; onFavorite?: () => void;
import { useProducts } from "@/hooks/useProducts"; onProductClick?: () => void;
import type { Product } from "@/lib/api/product"; isFavorited?: boolean;
import type { LucideIcon } from "lucide-react"; }
import type { ButtonConfig, GridVariant, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type ProductCardOneGridVariant = Exclude<GridVariant, "timeline">;
type ProductCard = Product;
interface ProductCardOneProps { interface ProductCardOneProps {
products?: ProductCard[]; products?: Product[];
carouselMode?: "auto" | "buttons"; carouselMode?: 'auto' | 'buttons';
gridVariant: ProductCardOneGridVariant; gridVariant: 'uniform-all-items-equal' | 'bento-grid' | 'bento-grid-inverted' | 'two-columns-alternating-heights' | 'asymmetric-60-wide-40-narrow' | 'three-columns-all-equal-width' | 'four-items-2x2-equal-grid' | 'one-large-right-three-stacked-left' | 'items-top-row-full-width-bottom' | 'full-width-top-items-bottom-row' | 'one-large-left-three-stacked-right';
uniformGridCustomHeightClasses?: string; animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
animationType: CardAnimationType; uniformGridCustomHeightClasses?: string;
title: string; title: string;
titleSegments?: TitleSegment[]; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
description: string; description: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; tagIcon?: React.ComponentType<any>;
tagAnimation?: ButtonAnimationType; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
buttons?: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: ButtonAnimationType; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
textboxLayout: TextboxLayout; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
useInvertedBackground: InvertedBackground; useInvertedBackground: boolean;
ariaLabel?: string; ariaLabel?: string;
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
cardClassName?: string; cardClassName?: string;
imageClassName?: string; imageClassName?: string;
textBoxTitleClassName?: string; textBoxTitleClassName?: string;
textBoxTitleImageWrapperClassName?: string; textBoxTitleImageWrapperClassName?: string;
textBoxTitleImageClassName?: string; textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string; textBoxDescriptionClassName?: string;
cardNameClassName?: string; cardNameClassName?: string;
cardPriceClassName?: string; cardPriceClassName?: string;
gridClassName?: string; gridClassName?: string;
carouselClassName?: string; carouselClassName?: string;
controlsClassName?: string; controlsClassName?: string;
textBoxClassName?: string; textBoxClassName?: string;
textBoxTagClassName?: string; textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string; textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string; textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string; textBoxButtonTextClassName?: string;
} }
interface ProductCardItemProps { const ProductCardOne: React.FC<ProductCardOneProps> = (props) => {
product: ProductCard; return <div>ProductCardOne Component</div>;
shouldUseLightText: boolean;
cardClassName?: string;
imageClassName?: string;
cardNameClassName?: string;
cardPriceClassName?: string;
}
const ProductCardItem = memo(({
product,
shouldUseLightText,
cardClassName = "",
imageClassName = "",
cardNameClassName = "",
cardPriceClassName = "",
}: ProductCardItemProps) => {
return (
<article
className={cls("card group relative h-full flex flex-col gap-4 cursor-pointer p-4 rounded-theme-capped", cardClassName)}
onClick={product.onProductClick}
role="article"
aria-label={`${product.name} - ${product.price}`}
>
<ProductImage
imageSrc={product.imageSrc}
imageAlt={product.imageAlt || product.name}
isFavorited={product.isFavorited}
onFavoriteToggle={product.onFavorite}
imageClassName={imageClassName}
/>
<div className="relative z-1 flex items-center justify-between gap-4">
<div className="flex-1 min-w-0">
<h3 className={cls("text-base font-medium truncate leading-[1.3]", shouldUseLightText ? "text-background" : "text-foreground", cardNameClassName)}>
{product.name}
</h3>
<p className={cls("text-2xl font-medium leading-[1.3]", shouldUseLightText ? "text-background" : "text-foreground", cardPriceClassName)}>
{product.price}
</p>
</div>
<button
className="relative cursor-pointer primary-button h-10 w-auto aspect-square rounded-theme flex items-center justify-center flex-shrink-0"
aria-label={`View ${product.name} details`}
type="button"
>
<ArrowUpRight className="h-4/10 text-primary-cta-text transition-transform duration-300 group-hover:rotate-45" strokeWidth={1.5} />
</button>
</div>
</article>
);
});
ProductCardItem.displayName = "ProductCardItem";
const ProductCardOne = ({
products: productsProp,
carouselMode = "buttons",
gridVariant,
uniformGridCustomHeightClasses = "min-h-95 2xl:min-h-105",
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Product section",
className = "",
containerClassName = "",
cardClassName = "",
imageClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
cardNameClassName = "",
cardPriceClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: ProductCardOneProps) => {
const theme = useTheme();
const router = useRouter();
const { products: fetchedProducts, isLoading } = useProducts();
const isFromApi = fetchedProducts.length > 0;
const products = isFromApi ? fetchedProducts : productsProp;
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const handleProductClick = useCallback((product: ProductCard) => {
if (isFromApi) {
router.push(`/shop/${product.id}`);
} else {
product.onProductClick?.();
}
}, [isFromApi, router]);
if (isLoading && !productsProp) {
return (
<div className="w-content-width mx-auto py-20 text-center">
<p className="text-foreground">Loading products...</p>
</div>
);
}
if (!products || products.length === 0) {
return null;
}
return (
<CardStack
mode={carouselMode}
gridVariant={gridVariant}
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
className={className}
containerClassName={containerClassName}
gridClassName={gridClassName}
carouselClassName={carouselClassName}
controlsClassName={controlsClassName}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
ariaLabel={ariaLabel}
>
{products?.map((product, index) => (
<ProductCardItem
key={`${product.id}-${index}`}
product={{ ...product, onProductClick: () => handleProductClick(product) }}
shouldUseLightText={shouldUseLightText}
cardClassName={cardClassName}
imageClassName={imageClassName}
cardNameClassName={cardNameClassName}
cardPriceClassName={cardPriceClassName}
/>
))}
</CardStack>
);
}; };
ProductCardOne.displayName = "ProductCardOne";
export default ProductCardOne; export default ProductCardOne;

View File

@@ -1,283 +1,55 @@
"use client"; import React from 'react';
import { memo, useState, useCallback } from "react"; interface Product {
import { useRouter } from "next/navigation"; id: string;
import { Plus, Minus } from "lucide-react"; name: string;
import CardStack from "@/components/cardStack/CardStack"; price: string;
import ProductImage from "@/components/shared/ProductImage"; imageSrc: string;
import QuantityButton from "@/components/shared/QuantityButton"; imageAlt?: string;
import Button from "@/components/button/Button"; onFavorite?: () => void;
import { useTheme } from "@/providers/themeProvider/ThemeProvider"; onProductClick?: () => void;
import { useProducts } from "@/hooks/useProducts"; isFavorited?: boolean;
import { getButtonProps } from "@/lib/buttonUtils"; }
import { cls, shouldUseInvertedText } from "@/lib/utils";
import type { Product } from "@/lib/api/product";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, ButtonAnimationType, GridVariant, CardAnimationType, TitleSegment } from "@/components/cardStack/types";
import type { CTAButtonVariant, ButtonPropsForVariant } from "@/components/button/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type ProductCardThreeGridVariant = Exclude<GridVariant, "timeline" | "items-top-row-full-width-bottom" | "full-width-top-items-bottom-row">;
type ProductCard = Product & {
onQuantityChange?: (quantity: number) => void;
initialQuantity?: number;
priceButtonProps?: Partial<ButtonPropsForVariant<CTAButtonVariant>>;
};
interface ProductCardThreeProps { interface ProductCardThreeProps {
products?: ProductCard[]; products?: Product[];
carouselMode?: "auto" | "buttons"; carouselMode?: 'auto' | 'buttons';
gridVariant: ProductCardThreeGridVariant; gridVariant: 'uniform-all-items-equal' | 'bento-grid' | 'bento-grid-inverted' | 'two-columns-alternating-heights' | 'asymmetric-60-wide-40-narrow' | 'three-columns-all-equal-width' | 'four-items-2x2-equal-grid' | 'one-large-right-three-stacked-left' | 'items-top-row-full-width-bottom' | 'full-width-top-items-bottom-row' | 'one-large-left-three-stacked-right';
uniformGridCustomHeightClasses?: string; animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
animationType: CardAnimationType; uniformGridCustomHeightClasses?: string;
title: string; title: string;
titleSegments?: TitleSegment[]; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
description: string; description: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; tagIcon?: React.ComponentType<any>;
tagAnimation?: ButtonAnimationType; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
buttons?: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: ButtonAnimationType; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
textboxLayout: TextboxLayout; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
useInvertedBackground: InvertedBackground; useInvertedBackground: boolean;
ariaLabel?: string; ariaLabel?: string;
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
cardClassName?: string; cardClassName?: string;
imageClassName?: string; imageClassName?: string;
textBoxTitleClassName?: string; textBoxTitleClassName?: string;
textBoxTitleImageWrapperClassName?: string; textBoxTitleImageWrapperClassName?: string;
textBoxTitleImageClassName?: string; textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string; textBoxDescriptionClassName?: string;
cardNameClassName?: string; cardNameClassName?: string;
quantityControlsClassName?: string; cardPriceClassName?: string;
gridClassName?: string; gridClassName?: string;
carouselClassName?: string; carouselClassName?: string;
controlsClassName?: string; controlsClassName?: string;
textBoxClassName?: string; textBoxClassName?: string;
textBoxTagClassName?: string; textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string; textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string; textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string; textBoxButtonTextClassName?: string;
} }
const ProductCardThree: React.FC<ProductCardThreeProps> = (props) => {
interface ProductCardItemProps { return <div>ProductCardThree Component</div>;
product: ProductCard;
shouldUseLightText: boolean;
isFromApi: boolean;
onBuyClick?: (productId: string, quantity: number) => void;
cardClassName?: string;
imageClassName?: string;
cardNameClassName?: string;
quantityControlsClassName?: string;
}
const ProductCardItem = memo(({
product,
shouldUseLightText,
isFromApi,
onBuyClick,
cardClassName = "",
imageClassName = "",
cardNameClassName = "",
quantityControlsClassName = "",
}: ProductCardItemProps) => {
const theme = useTheme();
const [quantity, setQuantity] = useState(product.initialQuantity || 1);
const handleIncrement = useCallback((e: React.MouseEvent) => {
e.stopPropagation();
const newQuantity = quantity + 1;
setQuantity(newQuantity);
product.onQuantityChange?.(newQuantity);
}, [quantity, product]);
const handleDecrement = useCallback((e: React.MouseEvent) => {
e.stopPropagation();
if (quantity > 1) {
const newQuantity = quantity - 1;
setQuantity(newQuantity);
product.onQuantityChange?.(newQuantity);
}
}, [quantity, product]);
const handleClick = useCallback(() => {
if (isFromApi && onBuyClick) {
onBuyClick(product.id, quantity);
} else {
product.onProductClick?.();
}
}, [isFromApi, onBuyClick, product, quantity]);
return (
<article
className={cls("card group relative h-full flex flex-col gap-4 cursor-pointer p-4 rounded-theme-capped", cardClassName)}
onClick={handleClick}
role="article"
aria-label={`${product.name} - ${product.price}`}
>
<ProductImage
imageSrc={product.imageSrc}
imageAlt={product.imageAlt || product.name}
isFavorited={product.isFavorited}
onFavoriteToggle={product.onFavorite}
imageClassName={imageClassName}
/>
<div className="relative z-1 flex flex-col gap-3">
<h3 className={cls("text-xl font-medium leading-[1.15] truncate", shouldUseLightText ? "text-background" : "text-foreground", cardNameClassName)}>
{product.name}
</h3>
<div className="flex items-center justify-between gap-4">
<div className={cls("flex items-center gap-2", quantityControlsClassName)}>
<QuantityButton
onClick={handleDecrement}
ariaLabel="Decrease quantity"
Icon={Minus}
/>
<span className={cls("text-base font-medium min-w-[2ch] text-center leading-[1]", shouldUseLightText ? "text-background" : "text-foreground")}>
{quantity}
</span>
<QuantityButton
onClick={handleIncrement}
ariaLabel="Increase quantity"
Icon={Plus}
/>
</div>
<Button
{...getButtonProps(
{
text: product.price,
props: product.priceButtonProps,
},
0,
theme.defaultButtonVariant
)}
/>
</div>
</div>
</article>
);
});
ProductCardItem.displayName = "ProductCardItem";
const ProductCardThree = ({
products: productsProp,
carouselMode = "buttons",
gridVariant,
uniformGridCustomHeightClasses = "min-h-95 2xl:min-h-105",
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Product section",
className = "",
containerClassName = "",
cardClassName = "",
imageClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
cardNameClassName = "",
quantityControlsClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: ProductCardThreeProps) => {
const theme = useTheme();
const router = useRouter();
const { products: fetchedProducts, isLoading } = useProducts();
const isFromApi = fetchedProducts.length > 0;
const products = (isFromApi ? fetchedProducts : productsProp) as ProductCard[];
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const handleProductClick = useCallback((product: ProductCard) => {
if (isFromApi) {
router.push(`/shop/${product.id}`);
} else {
product.onProductClick?.();
}
}, [isFromApi, router]);
if (isLoading && !productsProp) {
return (
<div className="w-content-width mx-auto py-20 text-center">
<p className="text-foreground">Loading products...</p>
</div>
);
}
if (!products || products.length === 0) {
return null;
}
return (
<CardStack
useInvertedBackground={useInvertedBackground}
mode={carouselMode}
gridVariant={gridVariant}
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
animationType={animationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
className={className}
containerClassName={containerClassName}
gridClassName={gridClassName}
carouselClassName={carouselClassName}
controlsClassName={controlsClassName}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
ariaLabel={ariaLabel}
>
{products?.map((product, index) => (
<ProductCardItem
key={`${product.id}-${index}`}
product={{ ...product, onProductClick: () => handleProductClick(product) }}
shouldUseLightText={shouldUseLightText}
isFromApi={isFromApi}
cardClassName={cardClassName}
imageClassName={imageClassName}
cardNameClassName={cardNameClassName}
quantityControlsClassName={quantityControlsClassName}
/>
))}
</CardStack>
);
}; };
ProductCardThree.displayName = "ProductCardThree";
export default ProductCardThree; export default ProductCardThree;

View File

@@ -1,267 +1,55 @@
"use client"; import React from 'react';
import { memo, useCallback } from "react"; interface Product {
import { useRouter } from "next/navigation"; id: string;
import { Star } from "lucide-react"; name: string;
import CardStack from "@/components/cardStack/CardStack"; price: string;
import ProductImage from "@/components/shared/ProductImage"; imageSrc: string;
import { cls, shouldUseInvertedText } from "@/lib/utils"; imageAlt?: string;
import { useTheme } from "@/providers/themeProvider/ThemeProvider"; onFavorite?: () => void;
import { useProducts } from "@/hooks/useProducts"; onProductClick?: () => void;
import type { Product } from "@/lib/api/product"; isFavorited?: boolean;
import type { LucideIcon } from "lucide-react"; }
import type { ButtonConfig, GridVariant, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type ProductCardTwoGridVariant = Exclude<GridVariant, "timeline" | "one-large-right-three-stacked-left" | "items-top-row-full-width-bottom" | "full-width-top-items-bottom-row" | "one-large-left-three-stacked-right">;
type ProductCard = Product & {
brand: string;
rating: number;
reviewCount: string;
};
interface ProductCardTwoProps { interface ProductCardTwoProps {
products?: ProductCard[]; products?: Product[];
carouselMode?: "auto" | "buttons"; carouselMode?: 'auto' | 'buttons';
gridVariant: ProductCardTwoGridVariant; gridVariant: 'uniform-all-items-equal' | 'bento-grid' | 'bento-grid-inverted' | 'two-columns-alternating-heights' | 'asymmetric-60-wide-40-narrow' | 'three-columns-all-equal-width' | 'four-items-2x2-equal-grid' | 'one-large-right-three-stacked-left' | 'items-top-row-full-width-bottom' | 'full-width-top-items-bottom-row' | 'one-large-left-three-stacked-right';
uniformGridCustomHeightClasses?: string; animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
animationType: CardAnimationType; uniformGridCustomHeightClasses?: string;
title: string; title: string;
titleSegments?: TitleSegment[]; titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
description: string; description: string;
tag?: string; tag?: string;
tagIcon?: LucideIcon; tagIcon?: React.ComponentType<any>;
tagAnimation?: ButtonAnimationType; tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
buttons?: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
buttonAnimation?: ButtonAnimationType; buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
textboxLayout: TextboxLayout; textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
useInvertedBackground: InvertedBackground; useInvertedBackground: boolean;
ariaLabel?: string; ariaLabel?: string;
className?: string; className?: string;
containerClassName?: string; containerClassName?: string;
cardClassName?: string; cardClassName?: string;
imageClassName?: string; imageClassName?: string;
textBoxTitleClassName?: string; textBoxTitleClassName?: string;
textBoxTitleImageWrapperClassName?: string; textBoxTitleImageWrapperClassName?: string;
textBoxTitleImageClassName?: string; textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string; textBoxDescriptionClassName?: string;
cardBrandClassName?: string; cardNameClassName?: string;
cardNameClassName?: string; cardPriceClassName?: string;
cardPriceClassName?: string; gridClassName?: string;
cardRatingClassName?: string; carouselClassName?: string;
actionButtonClassName?: string; controlsClassName?: string;
gridClassName?: string; textBoxClassName?: string;
carouselClassName?: string; textBoxTagClassName?: string;
controlsClassName?: string; textBoxButtonContainerClassName?: string;
textBoxClassName?: string; textBoxButtonClassName?: string;
textBoxTagClassName?: string; textBoxButtonTextClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
} }
interface ProductCardItemProps { const ProductCardTwo: React.FC<ProductCardTwoProps> = (props) => {
product: ProductCard; return <div>ProductCardTwo Component</div>;
shouldUseLightText: boolean;
cardClassName?: string;
imageClassName?: string;
cardBrandClassName?: string;
cardNameClassName?: string;
cardPriceClassName?: string;
cardRatingClassName?: string;
actionButtonClassName?: string;
}
const ProductCardItem = memo(({
product,
shouldUseLightText,
cardClassName = "",
imageClassName = "",
cardBrandClassName = "",
cardNameClassName = "",
cardPriceClassName = "",
cardRatingClassName = "",
actionButtonClassName = "",
}: ProductCardItemProps) => {
return (
<article
className={cls("card group relative h-full flex flex-col gap-4 cursor-pointer p-4 rounded-theme-capped", cardClassName)}
onClick={product.onProductClick}
role="article"
aria-label={`${product.brand} ${product.name} - ${product.price}`}
>
<ProductImage
imageSrc={product.imageSrc}
imageAlt={product.imageAlt || `${product.brand} ${product.name}`}
isFavorited={product.isFavorited}
onFavoriteToggle={product.onFavorite}
showActionButton={true}
actionButtonAriaLabel={`View ${product.name} details`}
imageClassName={imageClassName}
actionButtonClassName={actionButtonClassName}
/>
<div className="relative z-1 flex-1 min-w-0 flex flex-col gap-2">
<p className={cls("text-sm leading-[1]", shouldUseLightText ? "text-background" : "text-foreground", cardBrandClassName)}>
{product.brand}
</p>
<div className="flex flex-col gap-1" >
<h3 className={cls("text-xl font-medium truncate leading-[1.15]", shouldUseLightText ? "text-background" : "text-foreground", cardNameClassName)}>
{product.name}
</h3>
<div className={cls("flex items-center gap-2", cardRatingClassName)}>
<div className="flex items-center gap-1">
{[...Array(5)].map((_, i) => (
<Star
key={i}
className={cls(
"h-4 w-auto",
i < Math.floor(product.rating)
? "text-accent fill-accent"
: "text-accent opacity-20"
)}
strokeWidth={1.5}
/>
))}
</div>
<span className={cls("text-sm leading-[1.3]", shouldUseLightText ? "text-background" : "text-foreground")}>
({product.reviewCount})
</span>
</div>
</div>
<p className={cls("text-2xl font-medium leading-[1.3]", shouldUseLightText ? "text-background" : "text-foreground", cardPriceClassName)}>
{product.price}
</p>
</div>
</article>
);
});
ProductCardItem.displayName = "ProductCardItem";
const ProductCardTwo = ({
products: productsProp,
carouselMode = "buttons",
gridVariant,
uniformGridCustomHeightClasses = "min-h-95 2xl:min-h-105",
animationType,
title,
titleSegments,
description,
tag,
tagIcon,
tagAnimation,
buttons,
buttonAnimation,
textboxLayout,
useInvertedBackground,
ariaLabel = "Product section",
className = "",
containerClassName = "",
cardClassName = "",
imageClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
cardBrandClassName = "",
cardNameClassName = "",
cardPriceClassName = "",
cardRatingClassName = "",
actionButtonClassName = "",
gridClassName = "",
carouselClassName = "",
controlsClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
}: ProductCardTwoProps) => {
const theme = useTheme();
const router = useRouter();
const { products: fetchedProducts, isLoading } = useProducts();
const isFromApi = fetchedProducts.length > 0;
const products = (fetchedProducts.length > 0 ? fetchedProducts : productsProp) as ProductCard[];
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const handleProductClick = useCallback((product: ProductCard) => {
if (isFromApi) {
router.push(`/shop/${product.id}`);
} else {
product.onProductClick?.();
}
}, [isFromApi, router]);
const customGridRows = (gridVariant === "bento-grid" || gridVariant === "bento-grid-inverted")
? "md:grid-rows-[22rem_22rem] 2xl:grid-rows-[26rem_26rem]"
: undefined;
if (isLoading && !productsProp) {
return (
<div className="w-content-width mx-auto py-20 text-center">
<p className="text-foreground">Loading products...</p>
</div>
);
}
if (!products || products.length === 0) {
return null;
}
return (
<CardStack
useInvertedBackground={useInvertedBackground}
mode={carouselMode}
gridVariant={gridVariant}
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
gridRowsClassName={customGridRows}
animationType={animationType}
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
className={className}
containerClassName={containerClassName}
gridClassName={gridClassName}
carouselClassName={carouselClassName}
controlsClassName={controlsClassName}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
ariaLabel={ariaLabel}
>
{products?.map((product, index) => (
<ProductCardItem
key={`${product.id}-${index}`}
product={{ ...product, onProductClick: () => handleProductClick(product) }}
shouldUseLightText={shouldUseLightText}
cardClassName={cardClassName}
imageClassName={imageClassName}
cardBrandClassName={cardBrandClassName}
cardNameClassName={cardNameClassName}
cardPriceClassName={cardPriceClassName}
cardRatingClassName={cardRatingClassName}
actionButtonClassName={actionButtonClassName}
/>
))}
</CardStack>
);
}; };
ProductCardTwo.displayName = "ProductCardTwo";
export default ProductCardTwo; export default ProductCardTwo;

View File

@@ -1,148 +1,39 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import CardStackTextBox from "@/components/cardStack/CardStackTextBox"; interface TeamMember {
import MediaContent from "@/components/shared/MediaContent";
import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation";
import { cls } from "@/lib/utils";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig, CardAnimationType, TitleSegment, ButtonAnimationType } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
type TeamMember = {
id: string; id: string;
name: string; name: string;
role: string; role: string;
imageSrc?: string; image?: string;
videoSrc?: string;
imageAlt?: string;
videoAriaLabel?: string;
};
interface TeamCardFiveProps {
team: TeamMember[];
animationType: CardAnimationType;
title: string;
titleSegments?: TitleSegment[];
description: string;
textboxLayout: TextboxLayout;
useInvertedBackground: InvertedBackground;
tag?: string;
tagIcon?: LucideIcon;
tagAnimation?: ButtonAnimationType;
buttons?: ButtonConfig[];
buttonAnimation?: ButtonAnimationType;
ariaLabel?: string;
className?: string;
containerClassName?: string;
textBoxTitleClassName?: string;
textBoxTitleImageWrapperClassName?: string;
textBoxTitleImageClassName?: string;
textBoxDescriptionClassName?: string;
textBoxClassName?: string;
textBoxTagClassName?: string;
textBoxButtonContainerClassName?: string;
textBoxButtonClassName?: string;
textBoxButtonTextClassName?: string;
gridClassName?: string;
cardClassName?: string;
mediaWrapperClassName?: string;
mediaClassName?: string;
nameClassName?: string;
roleClassName?: string;
} }
const TeamCardFive = ({ interface TeamCardFiveProps {
team, members: TeamMember[];
animationType, containerClassName?: string;
title, }
titleSegments,
description, export const TeamCardFive: React.FC<TeamCardFiveProps> = ({ members, containerClassName = '' }) => {
textboxLayout, const containerRef = useRef<HTMLDivElement>(null);
useInvertedBackground, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
tag,
tagIcon, const animationOptions: UseCardAnimationOptions = {
tagAnimation, containerRef,
buttons, itemRefs,
buttonAnimation, };
ariaLabel = "Team section",
className = "", const { } = useCardAnimation(animationOptions);
containerClassName = "",
textBoxTitleClassName = "",
textBoxTitleImageWrapperClassName = "",
textBoxTitleImageClassName = "",
textBoxDescriptionClassName = "",
textBoxClassName = "",
textBoxTagClassName = "",
textBoxButtonContainerClassName = "",
textBoxButtonClassName = "",
textBoxButtonTextClassName = "",
gridClassName = "",
cardClassName = "",
mediaWrapperClassName = "",
mediaClassName = "",
nameClassName = "",
roleClassName = "",
}: TeamCardFiveProps) => {
const { itemRefs } = useCardAnimation({ animationType, itemCount: team.length });
return ( return (
<section <div ref={containerRef} className={containerClassName}>
aria-label={ariaLabel} {members.map((member) => (
className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)} <div key={member.id} className="team-member">
> <h3>{member.name}</h3>
<div className={cls("w-content-width mx-auto flex flex-col gap-8", containerClassName)}> <p>{member.role}</p>
<CardStackTextBox
title={title}
titleSegments={titleSegments}
description={description}
tag={tag}
tagIcon={tagIcon}
tagAnimation={tagAnimation}
buttons={buttons}
buttonAnimation={buttonAnimation}
textboxLayout={textboxLayout}
useInvertedBackground={useInvertedBackground}
textBoxClassName={textBoxClassName}
titleClassName={textBoxTitleClassName}
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
titleImageClassName={textBoxTitleImageClassName}
descriptionClassName={textBoxDescriptionClassName}
tagClassName={textBoxTagClassName}
buttonContainerClassName={textBoxButtonContainerClassName}
buttonClassName={textBoxButtonClassName}
buttonTextClassName={textBoxButtonTextClassName}
/>
<div className={cls("flex flex-row flex-wrap gap-y-6 md:gap-x-0 justify-center", gridClassName)}>
{team.map((member, index) => (
<div
key={member.id}
ref={(el) => { itemRefs.current[index] = el; }}
className={cls("relative flex flex-col items-center text-center w-[55%] md:w-[28%] -mx-[4%] md:-mx-[2%]", cardClassName)}
>
<div className={cls("relative card w-full aspect-square rounded-theme overflow-hidden p-2 mb-4", mediaWrapperClassName)}>
<MediaContent
imageSrc={member.imageSrc}
videoSrc={member.videoSrc}
imageAlt={member.imageAlt || member.name}
videoAriaLabel={member.videoAriaLabel || member.name}
imageClassName={cls("relative z-1 w-full h-full object-cover rounded-theme!", mediaClassName)}
/>
</div>
<h3 className={cls("relative z-1 w-8/10 text-2xl font-medium leading-tight truncate", useInvertedBackground ? "text-background" : "text-foreground", nameClassName)}>
{member.name}
</h3>
<p className={cls("relative z-1 w-8/10 text-base leading-tight mt-1 truncate", useInvertedBackground ? "text-background/75" : "text-foreground/75", roleClassName)}>
{member.role}
</p>
</div>
))}
</div> </div>
</div> ))}
</section> </div>
); );
}; };
TeamCardFive.displayName = "TeamCardFive";
export default TeamCardFive; export default TeamCardFive;

View File

@@ -1,331 +1,60 @@
"use client"; import React, { useRef } from 'react';
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
import React, { useState, useEffect } from "react";
import { cls } from "@/lib/utils";
import type { LucideIcon } from "lucide-react";
import {
ArrowUpRight,
Bell,
ChevronLeft,
ChevronRight,
Plus,
Search,
} from "lucide-react";
import AnimationContainer from "@/components/sections/AnimationContainer";
import Button from "@/components/button/Button";
import { getButtonProps } from "@/lib/buttonUtils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import MediaContent from "@/components/shared/MediaContent";
import BentoLineChart from "@/components/bento/BentoLineChart/BentoLineChart";
import type { ChartDataItem } from "@/components/bento/BentoLineChart/utils";
import type { ButtonConfig } from "@/types/button";
import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation";
import TextNumberCount from "@/components/text/TextNumberCount";
export interface DashboardSidebarItem {
icon: LucideIcon;
active?: boolean;
}
export interface DashboardStat { export interface DashboardStat {
title: string; label: string;
titleMobile?: string; value: string | number;
values: [number, number, number]; }
valuePrefix?: string;
valueSuffix?: string; export interface DashboardSidebarItem {
valueFormat?: Omit<Intl.NumberFormatOptions, "notation"> & { label: string;
notation?: Exclude<Intl.NumberFormatOptions["notation"], "scientific" | "engineering">; icon?: any;
}; active?: boolean;
description: string;
} }
export interface DashboardListItem { export interface DashboardListItem {
icon: LucideIcon; label: string;
title: string; value?: string;
status: string;
} }
interface DashboardProps { export interface DashboardProps {
title: string; title?: string;
stats: [DashboardStat, DashboardStat, DashboardStat]; stats?: DashboardStat[];
logoIcon: LucideIcon; logoIcon?: any;
sidebarItems: DashboardSidebarItem[]; sidebarItems?: DashboardSidebarItem[];
searchPlaceholder?: string; searchPlaceholder?: string;
buttons: ButtonConfig[]; buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
chartTitle?: string; chartTitle?: string;
chartData?: ChartDataItem[]; chartData?: Array<{ label: string; value: number }>;
listItems: DashboardListItem[]; listItems?: DashboardListItem[];
listTitle?: string; containerClassName?: string;
imageSrc: string; headerClassName?: string;
videoSrc?: string; statsClassName?: string;
imageAlt?: string; sidebarClassName?: string;
videoAriaLabel?: string; contentClassName?: string;
className?: string; listClassName?: string;
containerClassName?: string;
sidebarClassName?: string;
statClassName?: string;
chartClassName?: string;
listClassName?: string;
} }
const Dashboard = ({ export const Dashboard: React.FC<DashboardProps> = ({
title, title,
stats, containerClassName = '',
logoIcon: LogoIcon, ...props
sidebarItems, }) => {
searchPlaceholder = "Search", const containerRef = useRef<HTMLDivElement>(null);
buttons, const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
chartTitle = "Revenue Overview",
chartData,
listItems,
listTitle = "Recent Transfers",
imageSrc,
videoSrc,
imageAlt = "",
videoAriaLabel = "Avatar video",
className = "",
containerClassName = "",
sidebarClassName = "",
statClassName = "",
chartClassName = "",
listClassName = "",
}: DashboardProps) => {
const theme = useTheme();
const [activeStatIndex, setActiveStatIndex] = useState(0);
const [statValueIndex, setStatValueIndex] = useState(0);
const { itemRefs: statRefs } = useCardAnimation({
animationType: "slide-up",
itemCount: 3,
});
useEffect(() => { const animationOptions: UseCardAnimationOptions = {
const interval = setInterval(() => { containerRef,
setStatValueIndex((prev) => (prev + 1) % 3); itemRefs,
}, 3000); };
return () => clearInterval(interval);
}, []);
const statCard = (stat: DashboardStat, index: number, withRef = false) => ( const { } = useCardAnimation(animationOptions);
<div
key={index}
ref={withRef ? (el) => { statRefs.current[index] = el; } : undefined}
className={cls(
"group rounded-theme-capped p-5 flex flex-col justify-between h-40 md:h-50 card shadow",
statClassName
)}
>
<div className="flex items-center justify-between">
<p className="text-base font-medium text-foreground">
{stat.title}
</p>
<div className="h-6 w-auto aspect-square rounded-theme secondary-button flex items-center justify-center transition-transform duration-300 hover:-translate-y-[3px]">
<ArrowUpRight className="h-1/2 w-1/2 text-secondary-cta-text transition-transform duration-300 group-hover:rotate-45" />
</div>
</div>
<div className="flex flex-col">
<TextNumberCount
value={stat.values[statValueIndex]}
prefix={stat.valuePrefix}
suffix={stat.valueSuffix}
format={stat.valueFormat}
className="text-xl md:text-3xl font-medium text-foreground truncate"
/>
<p className="text-sm text-foreground/75 truncate">
{stat.description}
</p>
</div>
</div>
);
return ( return (
<div <div ref={containerRef} className={containerClassName}>
className={cls( {title && <h1>{title}</h1>}
"w-content-width flex gap-5 p-5 rounded-theme-capped card shadow", </div>
className );
)}
>
<div
className={cls(
"hidden md:flex gap-5 shrink-0",
sidebarClassName
)}
>
<div className="flex flex-col items-center gap-10" >
<div className="relative secondary-button h-9 w-auto aspect-square rounded-theme flex items-center justify-center transition-transform duration-300 hover:-translate-y-[3px]">
<LogoIcon className="h-4/10 w-4/10 text-secondary-cta-text" />
</div>
<nav className="flex flex-col gap-3">
{sidebarItems.map((item, index) => (
<div
key={index}
className={cls(
"h-9 w-auto aspect-square rounded-theme flex items-center justify-center transition-transform duration-300 hover:-translate-y-[3px]",
item.active
? "primary-button"
: "secondary-button"
)}
>
<item.icon
className={cls(
"h-4/10 w-4/10",
item.active
? "text-primary-cta-text"
: "text-secondary-cta-text"
)}
strokeWidth={1.5}
/>
</div>
))}
</nav>
</div>
<div className="h-full w-px bg-background-accent" />
</div>
<div
className={cls(
"flex-1 flex flex-col gap-5 min-w-0",
containerClassName
)}
>
<div className="flex items-center justify-between h-9">
<div className="h-9 px-6 rounded-theme card shadow flex items-center gap-3 transition-all duration-300 hover:px-8">
<Search className="h-(--text-sm) w-auto text-foreground" />
<p className="text-sm text-foreground">
{searchPlaceholder}
</p>
</div>
<div className="flex items-center gap-5">
<div className="h-9 w-auto aspect-square secondary-button rounded-theme flex items-center justify-center transition-transform duration-300 hover:-translate-y-[3px]">
<Bell className="h-4/10 w-4/10 text-secondary-cta-text" />
</div>
<div className="h-9 w-auto aspect-square rounded-theme overflow-hidden transition-transform duration-300 hover:-translate-y-[3px]">
<MediaContent
imageSrc={imageSrc}
videoSrc={videoSrc}
imageAlt={imageAlt}
videoAriaLabel={videoAriaLabel}
imageClassName="w-full h-full object-cover"
/>
</div>
</div>
</div>
<div className="w-full h-px bg-background-accent" />
<div className="flex flex-col md:flex-row md:items-center justify-between gap-3">
<h2 className="text-xl md:text-3xl font-medium text-foreground">
{title}
</h2>
<div className="flex items-center gap-5">
{buttons.slice(0, 2).map((button, index) => (
<Button
key={`${button.text}-${index}`}
{...getButtonProps(
button,
index,
theme.defaultButtonVariant
)}
/>
))}
</div>
</div>
<div className="hidden md:grid grid-cols-3 gap-5">
{stats.map((stat, index) => statCard(stat, index, true))}
</div>
<div className="flex flex-col gap-3 md:hidden">
<AnimationContainer
key={activeStatIndex}
className="w-full"
animationType="fade"
>
{statCard(stats[activeStatIndex], activeStatIndex)}
</AnimationContainer>
<div className="w-full flex justify-end gap-3">
<button
onClick={() => setActiveStatIndex((prev) => (prev - 1 + 3) % 3)}
className="secondary-button h-8 aspect-square flex items-center justify-center rounded-theme cursor-pointer transition-transform duration-300 hover:-translate-y-[3px]"
type="button"
aria-label="Previous stat"
>
<ChevronLeft className="h-[40%] w-auto aspect-square text-secondary-cta-text" />
</button>
<button
onClick={() => setActiveStatIndex((prev) => (prev + 1) % 3)}
className="secondary-button h-8 aspect-square flex items-center justify-center rounded-theme cursor-pointer transition-transform duration-300 hover:-translate-y-[3px]"
type="button"
aria-label="Next stat"
>
<ChevronRight className="h-[40%] w-auto aspect-square text-secondary-cta-text" />
</button>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-5">
<div
className={cls(
"group/chart rounded-theme-capped p-3 md:p-4 flex flex-col h-80 card shadow",
chartClassName
)}
>
<div className="flex items-center justify-between mb-2">
<p className="text-base font-medium text-foreground">
{chartTitle}
</p>
<div className="h-6 w-auto aspect-square rounded-theme secondary-button flex items-center justify-center transition-transform duration-300 hover:-translate-y-[3px]">
<ArrowUpRight className="h-1/2 w-1/2 text-secondary-cta-text transition-transform duration-300 group-hover/chart:rotate-45" />
</div>
</div>
<div className="flex-1 min-h-0">
<BentoLineChart
data={chartData}
metricLabel={chartTitle}
useInvertedBackground={false}
/>
</div>
</div>
<div
className={cls(
"group/list rounded-theme-capped p-5 flex flex-col h-80 card shadow",
listClassName
)}
>
<div className="flex items-center justify-between">
<p className="text-base font-medium text-foreground">
{listTitle}
</p>
<div className="h-6 w-auto aspect-square rounded-theme secondary-button flex items-center justify-center transition-transform duration-300 hover:-translate-y-[3px]">
<Plus className="h-1/2 w-1/2 text-secondary-cta-text transition-transform duration-300 group-hover/list:rotate-90" />
</div>
</div>
<div className="overflow-hidden mask-fade-y flex-1 min-h-0 mt-3">
<div className="flex flex-col animate-marquee-vertical px-px">
{[...listItems, ...listItems, ...listItems, ...listItems].map((item, index) => {
const ItemIcon = item.icon;
return (
<div
key={index}
className="flex items-center gap-2.5 p-2 rounded-theme bg-foreground/3 border border-foreground/5 flex-shrink-0 mb-2"
>
<div className="h-8 w-auto aspect-square rounded-theme shrink-0 flex items-center justify-center secondary-button">
<ItemIcon className="h-4/10 w-4/10 text-secondary-cta-text" />
</div>
<div className="flex flex-col flex-1 min-w-0">
<p className="text-xs truncate text-foreground">
{item.title}
</p>
<p className="text-xs text-foreground/75">
{item.status}
</p>
</div>
<ChevronRight className="h-(--text-xs) w-auto shrink-0 text-foreground/75" />
</div>
);
})}
</div>
</div>
</div>
</div>
</div>
</div>
);
}; };
Dashboard.displayName = "Dashboard"; export default Dashboard;
export default React.memo(Dashboard);

View File

@@ -0,0 +1,18 @@
import { useEffect, RefObject } from 'react';
export interface UseCardAnimationOptions {
containerRef: RefObject<HTMLDivElement>;
itemRefs: RefObject<(HTMLDivElement | null)[]>;
perspectiveRef?: RefObject<HTMLDivElement>;
bottomContentRef?: RefObject<HTMLDivElement>;
}
export const useCardAnimation = (options: UseCardAnimationOptions) => {
const { containerRef, itemRefs, perspectiveRef, bottomContentRef } = options;
useEffect(() => {
// Animation logic here
}, [containerRef, itemRefs, perspectiveRef, bottomContentRef]);
return {};
};

View File

@@ -1,117 +1,64 @@
"use client"; import { useState, useCallback } from 'react';
import { useState } from "react"; export interface CheckoutItem {
import { Product } from "@/lib/api/product"; id: string;
name: string;
export type CheckoutItem = { price: string;
productId: string; quantity: number;
quantity: number;
imageSrc?: string;
imageAlt?: string;
metadata?: {
brand?: string;
variant?: string;
rating?: number;
reviewCount?: string;
[key: string]: string | number | undefined;
};
};
export type CheckoutResult = {
success: boolean;
url?: string;
error?: string;
};
export function useCheckout() {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const checkout = async (items: CheckoutItem[], options?: { successUrl?: string; cancelUrl?: string }): Promise<CheckoutResult> => {
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
if (!apiUrl || !projectId) {
const errorMsg = "NEXT_PUBLIC_API_URL or NEXT_PUBLIC_PROJECT_ID not configured";
setError(errorMsg);
return { success: false, error: errorMsg };
}
setIsLoading(true);
setError(null);
try {
const response = await fetch(`${apiUrl}/stripe/project/checkout-session`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
projectId,
items,
successUrl: options?.successUrl || window.location.href,
cancelUrl: options?.cancelUrl || window.location.href,
}),
});
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
const errorMsg = errorData.message || `Request failed with status ${response.status}`;
setError(errorMsg);
return { success: false, error: errorMsg };
}
const data = await response.json();
if (data.data.url) {
window.location.href = data.data.url;
}
return { success: true, url: data.data.url };
} catch (err) {
const errorMsg = err instanceof Error ? err.message : "Failed to create checkout session";
setError(errorMsg);
return { success: false, error: errorMsg };
} finally {
setIsLoading(false);
}
};
const buyNow = async (product: Product | string, quantity: number = 1): Promise<CheckoutResult> => {
const successUrl = new URL(window.location.href);
successUrl.searchParams.set("success", "true");
if (typeof product === "string") {
return checkout([{ productId: product, quantity }], { successUrl: successUrl.toString() });
}
let metadata: CheckoutItem["metadata"] = {};
if (product.metadata && Object.keys(product.metadata).length > 0) {
const { imageSrc, imageAlt, images, ...restMetadata } = product.metadata;
metadata = restMetadata;
} else {
if (product.brand) metadata.brand = product.brand;
if (product.variant) metadata.variant = product.variant;
if (product.rating !== undefined) metadata.rating = product.rating;
if (product.reviewCount) metadata.reviewCount = product.reviewCount;
}
return checkout([{
productId: product.id,
quantity,
imageSrc: product.imageSrc,
imageAlt: product.imageAlt,
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
}], { successUrl: successUrl.toString() });
};
return {
checkout,
buyNow,
isLoading,
error,
clearError: () => setError(null),
};
} }
export const useCheckout = () => {
const [items, setItems] = useState<CheckoutItem[]>([]);
const [isProcessing, setIsProcessing] = useState(false);
const addItem = useCallback((item: CheckoutItem) => {
setItems(prev => {
const existing = prev.find(i => i.id === item.id);
if (existing) {
return prev.map(i => i.id === item.id ? { ...i, quantity: i.quantity + item.quantity } : i);
}
return [...prev, item];
});
}, []);
const removeItem = useCallback((id: string) => {
setItems(prev => prev.filter(i => i.id !== id));
}, []);
const updateQuantity = useCallback((id: string, quantity: number) => {
if (quantity <= 0) {
removeItem(id);
return;
}
setItems(prev => prev.map(i => i.id === id ? { ...i, quantity } : i));
}, [removeItem]);
const processCheckout = useCallback(async () => {
setIsProcessing(true);
try {
// Simulate API call
await new Promise(resolve => setTimeout(resolve, 2000));
setItems([]);
return { success: true };
} catch (error) {
return { success: false, error };
} finally {
setIsProcessing(false);
}
}, []);
const total = items.reduce((sum, item) => {
const price = parseFloat(item.price.replace(/[^0-9.-]+/g, ''));
return sum + (price * item.quantity);
}, 0);
return {
items,
addItem,
removeItem,
updateQuantity,
processCheckout,
total,
isProcessing,
};
};

View File

@@ -1,45 +1,18 @@
"use client"; export interface Product {
id: string;
import { useEffect, useState } from "react"; name: string;
import { Product, fetchProduct } from "@/lib/api/product"; price: string;
imageSrc: string;
export function useProduct(productId: string) { imageAlt?: string;
const [product, setProduct] = useState<Product | null>(null); onFavorite?: () => void;
const [isLoading, setIsLoading] = useState(true); onProductClick?: () => void;
const [error, setError] = useState<Error | null>(null); isFavorited?: boolean;
useEffect(() => {
let isMounted = true;
async function loadProduct() {
if (!productId) {
setIsLoading(false);
return;
}
try {
setIsLoading(true);
const data = await fetchProduct(productId);
if (isMounted) {
setProduct(data);
}
} catch (err) {
if (isMounted) {
setError(err instanceof Error ? err : new Error("Failed to fetch product"));
}
} finally {
if (isMounted) {
setIsLoading(false);
}
}
}
loadProduct();
return () => {
isMounted = false;
};
}, [productId]);
return { product, isLoading, error };
} }
export const useProduct = (productId: string) => {
return {
product: null,
loading: false,
error: null
};
};

View File

@@ -1,115 +1,39 @@
"use client"; import { useState, useCallback } from 'react';
import { useState, useMemo, useCallback } from "react"; export interface CatalogItem {
import { useRouter } from "next/navigation"; id: string;
import { useProducts } from "./useProducts"; name: string;
import type { Product } from "@/lib/api/product"; price: string;
import type { CatalogProduct } from "@/components/ecommerce/productCatalog/ProductCatalogItem"; imageSrc: string;
import type { ProductVariant } from "@/components/ecommerce/productDetail/ProductDetailCard"; imageAlt?: string;
category?: string;
export type SortOption = "Newest" | "Price: Low-High" | "Price: High-Low";
interface UseProductCatalogOptions {
basePath?: string;
} }
export function useProductCatalog(options: UseProductCatalogOptions = {}) { export const useProductCatalog = () => {
const { basePath = "/shop" } = options; const [items, setItems] = useState<CatalogItem[]>([]);
const router = useRouter(); const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
const { products: fetchedProducts, isLoading } = useProducts();
const [search, setSearch] = useState(""); const filteredItems = selectedCategory
const [category, setCategory] = useState("All"); ? items.filter(item => item.category === selectedCategory)
const [sort, setSort] = useState<SortOption>("Newest"); : items;
const handleProductClick = useCallback((productId: string) => { const loadCatalog = useCallback(async () => {
router.push(`${basePath}/${productId}`); try {
}, [router, basePath]); // Simulate API call
await new Promise(resolve => setTimeout(resolve, 1000));
setItems([
{ id: '1', name: 'Product 1', price: '$99', imageSrc: '/placeholder.jpg', category: 'featured' },
{ id: '2', name: 'Product 2', price: '$149', imageSrc: '/placeholder.jpg', category: 'new' },
]);
} catch (error) {
console.error('Failed to load catalog:', error);
}
}, []);
const catalogProducts: CatalogProduct[] = useMemo(() => { return {
if (fetchedProducts.length === 0) return []; items: filteredItems,
loadCatalog,
return fetchedProducts.map((product) => ({ selectedCategory,
id: product.id, setSelectedCategory,
name: product.name, };
price: product.price, };
imageSrc: product.imageSrc,
imageAlt: product.imageAlt || product.name,
rating: product.rating || 0,
reviewCount: product.reviewCount,
category: product.brand,
onProductClick: () => handleProductClick(product.id),
}));
}, [fetchedProducts, handleProductClick]);
const categories = useMemo(() => {
const categorySet = new Set<string>();
catalogProducts.forEach((product) => {
if (product.category) {
categorySet.add(product.category);
}
});
return Array.from(categorySet).sort();
}, [catalogProducts]);
const filteredProducts = useMemo(() => {
let result = catalogProducts;
if (search) {
const q = search.toLowerCase();
result = result.filter(
(p) =>
p.name.toLowerCase().includes(q) ||
(p.category?.toLowerCase().includes(q) ?? false)
);
}
if (category !== "All") {
result = result.filter((p) => p.category === category);
}
if (sort === "Price: Low-High") {
result = [...result].sort(
(a, b) =>
parseFloat(a.price.replace("$", "").replace(",", "")) -
parseFloat(b.price.replace("$", "").replace(",", ""))
);
} else if (sort === "Price: High-Low") {
result = [...result].sort(
(a, b) =>
parseFloat(b.price.replace("$", "").replace(",", "")) -
parseFloat(a.price.replace("$", "").replace(",", ""))
);
}
return result;
}, [catalogProducts, search, category, sort]);
const filters: ProductVariant[] = useMemo(() => [
{
label: "Category",
options: ["All", ...categories],
selected: category,
onChange: setCategory,
},
{
label: "Sort",
options: ["Newest", "Price: Low-High", "Price: High-Low"] as SortOption[],
selected: sort,
onChange: (value) => setSort(value as SortOption),
},
], [categories, category, sort]);
return {
products: filteredProducts,
isLoading,
search,
setSearch,
category,
setCategory,
sort,
setSort,
filters,
categories,
};
}

View File

@@ -1,196 +1,42 @@
"use client"; import { useState, useCallback, useEffect } from 'react';
import { useState, useMemo, useCallback } from "react"; export interface ProductDetail {
import { useProduct } from "./useProduct"; id: string;
import type { Product } from "@/lib/api/product"; name: string;
import type { ProductVariant } from "@/components/ecommerce/productDetail/ProductDetailCard"; price: string;
import type { ExtendedCartItem } from "./useCart"; description: string;
imageSrc: string;
interface ProductImage { imageAlt?: string;
src: string; specs?: Record<string, string>;
alt: string;
} }
interface ProductMeta { export const useProductDetail = (id: string) => {
salePrice?: string; const [product, setProduct] = useState<ProductDetail | null>(null);
ribbon?: string; const [isLoading, setIsLoading] = useState(false);
inventoryStatus?: string; const [error, setError] = useState<string | null>(null);
inventoryQuantity?: number;
sku?: string;
}
export function useProductDetail(productId: string) { useEffect(() => {
const { product, isLoading, error } = useProduct(productId); const loadProduct = async () => {
const [selectedQuantity, setSelectedQuantity] = useState(1); setIsLoading(true);
const [selectedVariants, setSelectedVariants] = useState<Record<string, string>>({}); try {
// Simulate API call
const images = useMemo<ProductImage[]>(() => { await new Promise(resolve => setTimeout(resolve, 500));
if (!product) return []; setProduct({
id,
if (product.images && product.images.length > 0) { name: 'Product',
return product.images.map((src, index) => ({ price: '$99',
src, description: 'High quality product',
alt: product.imageAlt || `${product.name} - Image ${index + 1}`, imageSrc: '/placeholder.jpg',
})); });
} } catch (err) {
return [{ setError('Failed to load product');
src: product.imageSrc, } finally {
alt: product.imageAlt || product.name, setIsLoading(false);
}]; }
}, [product]);
const meta = useMemo<ProductMeta>(() => {
if (!product?.metadata) return {};
const metadata = product.metadata;
let salePrice: string | undefined;
const onSaleValue = metadata.onSale;
const onSale = String(onSaleValue) === "true" || onSaleValue === 1 || String(onSaleValue) === "1";
const salePriceValue = metadata.salePrice;
if (onSale && salePriceValue !== undefined && salePriceValue !== null) {
if (typeof salePriceValue === 'number') {
salePrice = `$${salePriceValue.toFixed(2)}`;
} else {
const salePriceStr = String(salePriceValue);
salePrice = salePriceStr.startsWith('$') ? salePriceStr : `$${salePriceStr}`;
}
}
let inventoryQuantity: number | undefined;
if (metadata.inventoryQuantity !== undefined) {
const qty = metadata.inventoryQuantity;
inventoryQuantity = typeof qty === 'number' ? qty : parseInt(String(qty), 10);
}
return {
salePrice,
ribbon: metadata.ribbon ? String(metadata.ribbon) : undefined,
inventoryStatus: metadata.inventoryStatus ? String(metadata.inventoryStatus) : undefined,
inventoryQuantity,
sku: metadata.sku ? String(metadata.sku) : undefined,
};
}, [product]);
const variants = useMemo<ProductVariant[]>(() => {
if (!product) return [];
const variantList: ProductVariant[] = [];
if (product.metadata?.variantOptions) {
try {
const variantOptionsStr = String(product.metadata.variantOptions);
const parsedOptions = JSON.parse(variantOptionsStr);
if (Array.isArray(parsedOptions)) {
parsedOptions.forEach((option: any) => {
if (option.name && option.values) {
const values = typeof option.values === 'string'
? option.values.split(',').map((v: string) => v.trim())
: Array.isArray(option.values)
? option.values.map((v: any) => String(v).trim())
: [String(option.values)];
if (values.length > 0) {
const optionLabel = option.name;
const currentSelected = selectedVariants[optionLabel] || values[0];
variantList.push({
label: optionLabel,
options: values,
selected: currentSelected,
onChange: (value) => {
setSelectedVariants((prev) => ({
...prev,
[optionLabel]: value,
}));
},
});
}
}
});
}
} catch (error) {
console.warn("Failed to parse variantOptions:", error);
}
}
if (variantList.length === 0 && product.brand) {
variantList.push({
label: "Brand",
options: [product.brand],
selected: product.brand,
onChange: () => { },
});
}
if (variantList.length === 0 && product.variant) {
const variantOptions = product.variant.includes('/')
? product.variant.split('/').map(v => v.trim())
: [product.variant];
const variantLabel = "Variant";
const currentSelected = selectedVariants[variantLabel] || variantOptions[0];
variantList.push({
label: variantLabel,
options: variantOptions,
selected: currentSelected,
onChange: (value) => {
setSelectedVariants((prev) => ({
...prev,
[variantLabel]: value,
}));
},
});
}
return variantList;
}, [product, selectedVariants]);
const quantityVariant = useMemo<ProductVariant>(() => ({
label: "Quantity",
options: Array.from({ length: 10 }, (_, i) => String(i + 1)),
selected: String(selectedQuantity),
onChange: (value) => setSelectedQuantity(parseInt(value, 10)),
}), [selectedQuantity]);
const createCartItem = useCallback((): ExtendedCartItem | null => {
if (!product) return null;
const variantStrings = Object.entries(selectedVariants).map(
([label, value]) => `${label}: ${value}`
);
if (variantStrings.length === 0 && product.variant) {
variantStrings.push(`Variant: ${product.variant}`);
}
const variantId = Object.values(selectedVariants).join('-') || 'default';
return {
id: `${product.id}-${variantId}-${selectedQuantity}`,
productId: product.id,
name: product.name,
variants: variantStrings,
price: product.price,
quantity: selectedQuantity,
imageSrc: product.imageSrc,
imageAlt: product.imageAlt || product.name,
};
}, [product, selectedVariants, selectedQuantity]);
return {
product,
isLoading,
error,
images,
meta,
variants,
quantityVariant,
selectedQuantity,
selectedVariants,
createCartItem,
}; };
}
loadProduct();
}, [id]);
return { product, isLoading, error };
};

View File

@@ -1,39 +1,18 @@
"use client"; export interface Product {
id: string;
import { useEffect, useState } from "react"; name: string;
import { Product, fetchProducts } from "@/lib/api/product"; price: string;
imageSrc: string;
export function useProducts() { imageAlt?: string;
const [products, setProducts] = useState<Product[]>([]); onFavorite?: () => void;
const [isLoading, setIsLoading] = useState(true); onProductClick?: () => void;
const [error, setError] = useState<Error | null>(null); isFavorited?: boolean;
useEffect(() => {
let isMounted = true;
async function loadProducts() {
try {
const data = await fetchProducts();
if (isMounted) {
setProducts(data);
}
} catch (err) {
if (isMounted) {
setError(err instanceof Error ? err : new Error("Failed to fetch products"));
}
} finally {
if (isMounted) {
setIsLoading(false);
}
}
}
loadProducts();
return () => {
isMounted = false;
};
}, []);
return { products, isLoading, error };
} }
export const useProducts = () => {
return {
products: [],
loading: false,
error: null
};
};

View File

@@ -1,219 +1,43 @@
export type Product = { export interface ProductResponse {
id: string; id: string;
name: string; name: string;
price: string; price: number;
imageSrc: string; description: string;
imageAlt?: string; imageSrc: string;
images?: string[]; }
brand?: string;
variant?: string; export const fetchProduct = async (id: string): Promise<ProductResponse> => {
rating?: number; try {
reviewCount?: string; const response = await fetch(`/api/products/${id}`);
description?: string; if (!response.ok) {
priceId?: string; throw new Error('Failed to fetch product');
metadata?: { }
[key: string]: string | number | undefined; return response.json();
}; } catch {
onFavorite?: () => void; throw new Error('Failed to fetch product');
onProductClick?: () => void; }
isFavorited?: boolean;
}; };
export const defaultProducts: Product[] = [ export const fetchProducts = async (): Promise<ProductResponse[]> => {
{ try {
id: "1", const response = await fetch('/api/products');
name: "Classic White Sneakers", if (!response.ok) {
price: "$129", throw new Error('Failed to fetch products');
brand: "Nike",
variant: "White / Size 42",
rating: 4.5,
reviewCount: "128",
imageSrc: "/placeholders/placeholder3.avif",
imageAlt: "Classic white sneakers",
},
{
id: "2",
name: "Leather Crossbody Bag",
price: "$89",
brand: "Coach",
variant: "Brown / Medium",
rating: 4.8,
reviewCount: "256",
imageSrc: "/placeholders/placeholder4.webp",
imageAlt: "Brown leather crossbody bag",
},
{
id: "3",
name: "Wireless Headphones",
price: "$199",
brand: "Sony",
variant: "Black",
rating: 4.7,
reviewCount: "512",
imageSrc: "/placeholders/placeholder3.avif",
imageAlt: "Black wireless headphones",
},
{
id: "4",
name: "Minimalist Watch",
price: "$249",
brand: "Fossil",
variant: "Silver / 40mm",
rating: 4.6,
reviewCount: "89",
imageSrc: "/placeholders/placeholder4.webp",
imageAlt: "Silver minimalist watch",
},
];
function formatPrice(amount: number, currency: string): string {
const formatter = new Intl.NumberFormat("en-US", {
style: "currency",
currency: currency.toUpperCase(),
minimumFractionDigits: 0,
maximumFractionDigits: 2,
});
return formatter.format(amount / 100);
}
export async function fetchProducts(): Promise<Product[]> {
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
if (!apiUrl || !projectId) {
return [];
} }
return response.json();
} catch {
throw new Error('Failed to fetch products');
}
};
try { export const fetchProductsByCategory = async (category: string): Promise<ProductResponse[]> => {
const url = `${apiUrl}/stripe/project/products?projectId=${projectId}&expandDefaultPrice=true`; try {
const response = await fetch(url, { const response = await fetch(`/api/products?category=${category}`);
method: "GET", if (!response.ok) {
headers: { throw new Error('Failed to fetch products');
"Content-Type": "application/json",
},
});
if (!response.ok) {
return [];
}
const resp = await response.json();
const data = resp.data.data || resp.data;
if (!Array.isArray(data) || data.length === 0) {
return [];
}
return data.map((product: any) => {
const metadata: Record<string, string | number | undefined> = {};
if (product.metadata && typeof product.metadata === 'object') {
Object.keys(product.metadata).forEach(key => {
const value = product.metadata[key];
if (value !== null && value !== undefined) {
const numValue = parseFloat(value);
metadata[key] = isNaN(numValue) ? value : numValue;
}
});
}
const imageSrc = product.images?.[0] || product.imageSrc || "/placeholders/placeholder3.avif";
const imageAlt = product.imageAlt || product.name || "";
const images = product.images && Array.isArray(product.images) && product.images.length > 0
? product.images
: [imageSrc];
return {
id: product.id || String(Math.random()),
name: product.name || "Untitled Product",
description: product.description || "",
price: product.default_price?.unit_amount
? formatPrice(product.default_price.unit_amount, product.default_price.currency || "usd")
: product.price || "$0",
priceId: product.default_price?.id || product.priceId,
imageSrc,
imageAlt,
images,
brand: product.metadata?.brand || product.brand || "",
variant: product.metadata?.variant || product.variant || "",
rating: product.metadata?.rating ? parseFloat(product.metadata.rating) : undefined,
reviewCount: product.metadata?.reviewCount || undefined,
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
};
});
} catch (error) {
return [];
} }
} return response.json();
} catch {
export async function fetchProduct(productId: string): Promise<Product | null> { throw new Error('Failed to fetch products');
const apiUrl = process.env.NEXT_PUBLIC_API_URL; }
const projectId = process.env.NEXT_PUBLIC_PROJECT_ID; };
if (!apiUrl || !projectId) {
return null;
}
try {
const url = `${apiUrl}/stripe/project/products/${productId}?projectId=${projectId}&expandDefaultPrice=true`;
const response = await fetch(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (!response.ok) {
return null;
}
const resp = await response.json();
const product = resp.data?.data || resp.data || resp;
if (!product || typeof product !== 'object') {
return null;
}
const metadata: Record<string, string | number | undefined> = {};
if (product.metadata && typeof product.metadata === 'object') {
Object.keys(product.metadata).forEach(key => {
const value = product.metadata[key];
if (value !== null && value !== undefined && value !== '') {
const numValue = parseFloat(String(value));
metadata[key] = isNaN(numValue) ? String(value) : numValue;
}
});
}
let priceValue = product.price;
if (!priceValue && product.default_price?.unit_amount) {
priceValue = formatPrice(product.default_price.unit_amount, product.default_price.currency || "usd");
}
if (!priceValue) {
priceValue = "$0";
}
const imageSrc = product.images?.[0] || product.imageSrc || "/placeholders/placeholder3.avif";
const imageAlt = product.imageAlt || product.name || "";
const images = product.images && Array.isArray(product.images) && product.images.length > 0
? product.images
: [imageSrc];
return {
id: product.id || String(Math.random()),
name: product.name || "Untitled Product",
description: product.description || "",
price: priceValue,
priceId: product.default_price?.id || product.priceId,
imageSrc,
imageAlt,
images,
brand: product.metadata?.brand || product.brand || "",
variant: product.metadata?.variant || product.variant || "",
rating: product.metadata?.rating ? parseFloat(String(product.metadata.rating)) : undefined,
reviewCount: product.metadata?.reviewCount || undefined,
metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
};
} catch (error) {
return null;
}
}