Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f5bcc6e40d | |||
| 6518d28772 | |||
| 06dcaf500d | |||
| 9ba60256e2 | |||
| 39fbb62e9d | |||
| 101737d93b | |||
| bcd3ed80c7 | |||
| b958875873 | |||
| 4a760304bf | |||
| 7dfb6f3f95 | |||
| 58697ead0e | |||
| 037ef82c3d | |||
| 25fef0aec6 | |||
| b55725bda8 | |||
| ca9ddc0a90 | |||
| aa349f3d83 | |||
| a53e0030bb | |||
| 5f850bac37 | |||
| 2c9735cce2 | |||
| 521faa156b | |||
| 4966363406 | |||
| 10f33044ae | |||
| 39c2ca6ef4 | |||
| a5fc9943c4 | |||
| c1e8d6c8d5 | |||
| 0c037dd603 | |||
| be20bbb4dc | |||
| aade90a21f | |||
| 1286dc1aa5 | |||
| ca5ff42d8f | |||
| 5c2f7f374e | |||
| 2ccea76e4f | |||
| 02dad55fe9 | |||
| bfa4a8db78 | |||
| 14398cadd7 | |||
| 6c1bc0b01d | |||
| ea2ee7f715 | |||
| e8b2a950ad | |||
| e4e3ac93f3 | |||
| 8e9ebbfd20 | |||
| 5309779be9 | |||
| d114bef4d0 | |||
| 9102f58624 | |||
| bab04bed97 | |||
| c9b303b81a | |||
| a6d3b35969 | |||
| af2a39ee2a | |||
| ed81a59c66 | |||
| 2d7f08f1f9 | |||
| 810ec6d9a3 | |||
| 094645cc72 | |||
| 278ac5189f | |||
| 49b118c1eb | |||
| 869ce33d0b | |||
| 32b3c9ef3f | |||
| c876b1fd20 | |||
| 326ea116f9 | |||
| b6e0ce95e4 | |||
| 6610d14553 | |||
| 8bbf752b4d | |||
| 700bc27fa7 |
@@ -1,31 +1,123 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
export interface CardListProps {
|
import { memo, Children } from "react";
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CardList: React.FC<CardListProps> = ({ children, containerClassName = '' }) => {
|
const CardList = ({
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
children,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
animationType,
|
||||||
const bottomContentRef = useRef<HTMLDivElement>(null);
|
useUncappedRounding = false,
|
||||||
const perspectiveRef = useRef<HTMLDivElement>(null);
|
title,
|
||||||
|
titleSegments,
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
description,
|
||||||
containerRef,
|
tag,
|
||||||
itemRefs,
|
tagIcon,
|
||||||
bottomContentRef,
|
tagAnimation,
|
||||||
perspectiveRef,
|
buttons,
|
||||||
};
|
buttonAnimation,
|
||||||
|
textboxLayout,
|
||||||
const { } = useCardAnimation(animationOptions);
|
useInvertedBackground,
|
||||||
|
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 (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{children}
|
aria-label={ariaLabel}
|
||||||
</div>
|
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={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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CardList;
|
CardList.displayName = "CardList";
|
||||||
|
|
||||||
|
export default memo(CardList);
|
||||||
|
|||||||
@@ -1,5 +1,229 @@
|
|||||||
import React from 'react';
|
"use client";
|
||||||
import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
|
|
||||||
|
|
||||||
export { TimelineHorizontalCardStack };
|
import { memo, Children } from "react";
|
||||||
export default TimelineHorizontalCardStack;
|
import { CardStackProps } from "./types";
|
||||||
|
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);
|
||||||
|
|||||||
@@ -1,18 +1,187 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { 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";
|
||||||
|
|
||||||
interface UseCardAnimationOptions {
|
gsap.registerPlugin(ScrollTrigger);
|
||||||
perspective?: number;
|
|
||||||
|
interface UseCardAnimationProps {
|
||||||
|
animationType: CardAnimationType | "depth-3d";
|
||||||
|
itemCount: number;
|
||||||
|
isGrid?: boolean;
|
||||||
|
supports3DAnimation?: boolean;
|
||||||
|
gridVariant?: GridVariant;
|
||||||
|
useIndividualTriggers?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useCardAnimation = (options: UseCardAnimationOptions = {}) => {
|
export const useCardAnimation = ({
|
||||||
const { perspective = 1000 } = options;
|
animationType,
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
itemCount,
|
||||||
|
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);
|
||||||
|
|
||||||
useEffect(() => {
|
// Enable 3D effect only when explicitly supported and conditions are met
|
||||||
if (!containerRef.current) return;
|
const { isMobile } = useDepth3DAnimation({
|
||||||
|
itemRefs,
|
||||||
|
containerRef,
|
||||||
|
perspectiveRef,
|
||||||
|
isEnabled: animationType === "depth-3d" && isGrid && supports3DAnimation && gridVariant === "uniform-all-items-equal",
|
||||||
|
});
|
||||||
|
|
||||||
containerRef.current.style.perspective = `${perspective}px`;
|
// Use scale-rotate as fallback when depth-3d conditions aren't met
|
||||||
}, [perspective]);
|
const effectiveAnimationType =
|
||||||
|
animationType === "depth-3d" && (isMobile || !isGrid || gridVariant !== "uniform-all-items-equal")
|
||||||
|
? "scale-rotate"
|
||||||
|
: animationType;
|
||||||
|
|
||||||
return { containerRef };
|
useGSAP(() => {
|
||||||
|
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 };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +1,118 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState, useRef, RefObject } from "react";
|
||||||
|
|
||||||
export const useDepth3DAnimation = () => {
|
const MOBILE_BREAKPOINT = 768;
|
||||||
const [perspective, setPerspective] = useState(1000);
|
const ANIMATION_SPEED = 0.05;
|
||||||
|
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 handleMouseMove = (e: MouseEvent) => {
|
const checkMobile = () => {
|
||||||
const x = e.clientX / window.innerWidth;
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||||
const y = e.clientY / window.innerHeight;
|
|
||||||
const newPerspective = 1000 - (x + y) * 200;
|
|
||||||
setPerspective(Math.max(800, newPerspective));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('mousemove', handleMouseMove);
|
checkMobile();
|
||||||
return () => window.removeEventListener('mousemove', handleMouseMove);
|
window.addEventListener("resize", checkMobile);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("resize", checkMobile);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return { perspective };
|
// 3D mouse-tracking effect (desktop only)
|
||||||
|
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 };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,48 +1,148 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
export interface AutoCarouselProps {
|
import { memo, Children } from "react";
|
||||||
children: React.ReactNode;
|
import Marquee from "react-fast-marquee";
|
||||||
title?: string;
|
import CardStackTextBox from "../../CardStackTextBox";
|
||||||
description?: string;
|
import { cls } from "@/lib/utils";
|
||||||
textboxLayout?: string;
|
import { AutoCarouselProps } from "../../types";
|
||||||
animationType?: string;
|
import { useCardAnimation } from "../../hooks/useCardAnimation";
|
||||||
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 }>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AutoCarousel: React.FC<AutoCarouselProps> = ({
|
const AutoCarousel = ({
|
||||||
children,
|
children,
|
||||||
containerClassName = '',
|
uniformGridCustomHeightClasses,
|
||||||
...props
|
animationType,
|
||||||
}) => {
|
speed = 50,
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
title,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
titleSegments,
|
||||||
const bottomContentRef = useRef<HTMLDivElement>(null);
|
description,
|
||||||
|
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
|
||||||
|
});
|
||||||
|
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
// Bottom marquee direction is opposite of top
|
||||||
containerRef,
|
const bottomMarqueeDirection = topMarqueeDirection === "left" ? "right" : "left";
|
||||||
itemRefs,
|
|
||||||
bottomContentRef,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
// Reverse order for bottom marquee to avoid alignment with top
|
||||||
|
const bottomChildren = dualMarquee ? [...childrenArray].reverse() : [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{children}
|
className={cls(
|
||||||
</div>
|
"relative py-20 w-full",
|
||||||
);
|
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>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AutoCarousel;
|
AutoCarousel.displayName = "AutoCarousel";
|
||||||
|
|
||||||
|
export default memo(AutoCarousel);
|
||||||
|
|||||||
@@ -1,29 +1,182 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
interface ButtonCarouselProps {
|
import { memo, Children } from "react";
|
||||||
children: React.ReactNode;
|
import useEmblaCarousel from "embla-carousel-react";
|
||||||
containerClassName?: string;
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
||||||
}
|
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";
|
||||||
|
|
||||||
export const ButtonCarousel: React.FC<ButtonCarouselProps> = ({ children, containerClassName = '' }) => {
|
const ButtonCarousel = ({
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
children,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
uniformGridCustomHeightClasses,
|
||||||
const bottomContentRef = useRef<HTMLDivElement>(null);
|
animationType,
|
||||||
|
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 animationOptions: UseCardAnimationOptions = {
|
const {
|
||||||
containerRef,
|
prevBtnDisabled,
|
||||||
itemRefs,
|
nextBtnDisabled,
|
||||||
bottomContentRef,
|
onPrevButtonClick,
|
||||||
};
|
onNextButtonClick,
|
||||||
|
} = usePrevNextButtons(emblaApi);
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
const scrollProgress = useScrollProgress(emblaApi);
|
||||||
|
|
||||||
return (
|
const childrenArray = Children.toArray(children);
|
||||||
<div ref={containerRef} className={containerClassName}>
|
const heightClasses = uniformGridCustomHeightClasses || "min-h-80 2xl:min-h-90";
|
||||||
{children}
|
const { itemRefs, bottomContentRef } = useCardAnimation({
|
||||||
</div>
|
animationType,
|
||||||
);
|
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>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ButtonCarousel;
|
ButtonCarousel.displayName = "ButtonCarousel";
|
||||||
|
|
||||||
|
export default memo(ButtonCarousel);
|
||||||
|
|||||||
@@ -1,31 +1,150 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
interface GridLayoutProps {
|
import { memo, Children } from "react";
|
||||||
children: React.ReactNode;
|
import CardStackTextBox from "../../CardStackTextBox";
|
||||||
containerClassName?: string;
|
import { cls } from "@/lib/utils";
|
||||||
}
|
import { GridLayoutProps } from "../../types";
|
||||||
|
import { gridConfigs } from "./gridConfigs";
|
||||||
|
import { useCardAnimation } from "../../hooks/useCardAnimation";
|
||||||
|
|
||||||
export const GridLayout: React.FC<GridLayoutProps> = ({ children, containerClassName = '' }) => {
|
const GridLayout = ({
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
children,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
itemCount,
|
||||||
const perspectiveRef = useRef<HTMLDivElement>(null);
|
gridVariant = "uniform-all-items-equal",
|
||||||
const bottomContentRef = useRef<HTMLDivElement>(null);
|
uniformGridCustomHeightClasses,
|
||||||
|
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];
|
||||||
|
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
// Fallback to default uniform grid if no config
|
||||||
containerRef,
|
const gridColsMap = {
|
||||||
itemRefs,
|
1: "md:grid-cols-1",
|
||||||
perspectiveRef,
|
2: "md:grid-cols-2",
|
||||||
bottomContentRef,
|
3: "md:grid-cols-3",
|
||||||
};
|
4: "md:grid-cols-4",
|
||||||
|
};
|
||||||
|
const defaultGridCols = gridColsMap[itemCount as keyof typeof gridColsMap] || "md:grid-cols-4";
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
// Use config values or fallback
|
||||||
|
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 || "";
|
||||||
|
|
||||||
return (
|
const childrenArray = Children.toArray(children);
|
||||||
<div ref={containerRef} className={containerClassName}>
|
const { itemRefs, containerRef, perspectiveRef, bottomContentRef } = useCardAnimation({
|
||||||
{children}
|
animationType,
|
||||||
</div>
|
itemCount: childrenArray.length,
|
||||||
);
|
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>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default GridLayout;
|
GridLayout.displayName = "GridLayout";
|
||||||
|
|
||||||
|
export default memo(GridLayout);
|
||||||
|
|||||||
@@ -1,32 +1,149 @@
|
|||||||
import React from 'react';
|
"use client";
|
||||||
|
|
||||||
|
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 {
|
||||||
id: string;
|
children: React.ReactNode;
|
||||||
title: string;
|
variant?: TimelineVariant;
|
||||||
description: string;
|
uniformGridCustomHeightClasses?: string;
|
||||||
isActive: boolean;
|
animationType: CardAnimationType;
|
||||||
isPast: boolean;
|
title?: string;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TimelineBase: React.FC<TimelineBaseProps> = ({
|
const TimelineBase = ({
|
||||||
id,
|
children,
|
||||||
|
variant = "timeline",
|
||||||
|
uniformGridCustomHeightClasses = "min-h-80 2xl:min-h-90",
|
||||||
|
animationType,
|
||||||
title,
|
title,
|
||||||
|
titleSegments,
|
||||||
description,
|
description,
|
||||||
isActive,
|
tag,
|
||||||
isPast,
|
tagIcon,
|
||||||
}) => {
|
tagAnimation,
|
||||||
const opacity = isActive ? 'opacity-100' : isPast ? 'opacity-75' : 'opacity-50';
|
buttons,
|
||||||
const scale = isActive ? 'scale-100' : 'scale-95';
|
buttonAnimation,
|
||||||
|
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 (
|
||||||
<div
|
<section
|
||||||
className={`transition-all duration-500 ${opacity} ${scale}`}
|
className={cls(
|
||||||
data-timeline-id={id}
|
"relative py-20 w-full",
|
||||||
|
useInvertedBackground && "bg-foreground",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
aria-label={ariaLabel}
|
||||||
>
|
>
|
||||||
<div className="space-y-2">
|
<div
|
||||||
<h3 className="text-lg font-semibold">{title}</h3>
|
className={cls("w-content-width mx-auto flex flex-col gap-6", containerClassName)}
|
||||||
<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>
|
||||||
</div>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TimelineBase.displayName = "TimelineBase";
|
||||||
|
|
||||||
|
export default React.memo(TimelineBase);
|
||||||
|
|||||||
@@ -1,25 +1,32 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
export interface TimelineHorizontalCardStackProps {
|
import React, { Children, useCallback } from "react";
|
||||||
|
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;
|
||||||
description?: string;
|
titleSegments?: TitleSegment[];
|
||||||
|
description: string;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
textboxLayout?: string;
|
tagIcon?: LucideIcon;
|
||||||
animationType?: string;
|
tagAnimation?: ButtonAnimationType;
|
||||||
containerClassName?: string;
|
buttons?: ButtonConfig[];
|
||||||
mediaItems?: Array<{ imageSrc?: string; videoSrc?: string; imageAlt?: string; videoAriaLabel?: string }>;
|
buttonAnimation?: ButtonAnimationType;
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
textboxLayout: TextboxLayout;
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
useInvertedBackground?: InvertedBackground;
|
||||||
buttonAnimation?: string;
|
mediaItems?: MediaItem[];
|
||||||
tagIcon?: any;
|
|
||||||
tagAnimation?: string;
|
|
||||||
useInvertedBackground?: boolean;
|
|
||||||
ariaLabel?: string;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
|
containerClassName?: 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;
|
||||||
@@ -29,28 +36,140 @@ export interface TimelineHorizontalCardStackProps {
|
|||||||
progressBarClassName?: string;
|
progressBarClassName?: string;
|
||||||
mediaContainerClassName?: string;
|
mediaContainerClassName?: string;
|
||||||
mediaClassName?: string;
|
mediaClassName?: string;
|
||||||
|
ariaLabel?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TimelineHorizontalCardStack: React.FC<TimelineHorizontalCardStackProps> = ({
|
const TimelineHorizontalCardStack = ({
|
||||||
children,
|
children,
|
||||||
containerClassName = '',
|
title,
|
||||||
...props
|
titleSegments,
|
||||||
}) => {
|
description,
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
tag,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
tagIcon,
|
||||||
|
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 animationOptions: UseCardAnimationOptions = {
|
const { activeIndex, progressRefs, handleItemClick, imageOpacity, currentMediaSrc } = useTimelineHorizontal({
|
||||||
containerRef,
|
itemCount,
|
||||||
itemRefs,
|
mediaItems,
|
||||||
};
|
});
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
const getGridColumns = useCallback(() => {
|
||||||
|
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 (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{children}
|
className={cls(
|
||||||
</div>
|
"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)}>
|
||||||
|
<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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TimelineHorizontalCardStack;
|
TimelineHorizontalCardStack.displayName = "TimelineHorizontalCardStack";
|
||||||
|
|
||||||
|
export default React.memo(TimelineHorizontalCardStack);
|
||||||
|
|||||||
@@ -1,26 +1,63 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
export interface TimelinePhoneViewItem {
|
import React, { memo } from "react";
|
||||||
[key: string]: any;
|
import MediaContent from "@/components/shared/MediaContent";
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TimelinePhoneViewProps {
|
const PhoneFrame = memo(({
|
||||||
children: React.ReactNode;
|
imageSrc,
|
||||||
|
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?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
titleSegments?: TitleSegment[];
|
||||||
description?: string;
|
description: string;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
tagIcon?: any;
|
tagIcon?: LucideIcon;
|
||||||
tagAnimation?: string;
|
tagAnimation?: ButtonAnimationType;
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
buttons?: ButtonConfig[];
|
||||||
buttonAnimation?: string;
|
buttonAnimation?: ButtonAnimationType;
|
||||||
textboxLayout?: string;
|
animationType: CardAnimationType;
|
||||||
animationType?: string;
|
textboxLayout: TextboxLayout;
|
||||||
useInvertedBackground?: boolean;
|
useInvertedBackground?: InvertedBackground;
|
||||||
ariaLabel?: string;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
textBoxClassName?: string;
|
textBoxClassName?: string;
|
||||||
@@ -30,28 +67,209 @@ export 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TimelinePhoneView: React.FC<TimelinePhoneViewProps> = ({
|
const TimelinePhoneView = ({
|
||||||
children,
|
items,
|
||||||
containerClassName = '',
|
showTextBox = true,
|
||||||
...props
|
showDivider = false,
|
||||||
}) => {
|
title,
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
titleSegments,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
description,
|
||||||
|
tag,
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
tagIcon,
|
||||||
containerRef,
|
tagAnimation,
|
||||||
itemRefs,
|
buttons,
|
||||||
};
|
buttonAnimation,
|
||||||
|
animationType,
|
||||||
const { } = useCardAnimation(animationOptions);
|
textboxLayout,
|
||||||
|
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 (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{children}
|
className={cls(
|
||||||
</div>
|
"relative py-20 overflow-hidden md:overflow-visible w-full",
|
||||||
|
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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TimelinePhoneView;
|
TimelinePhoneView.displayName = "TimelinePhoneView";
|
||||||
|
|
||||||
|
export default memo(TimelinePhoneView);
|
||||||
|
|||||||
@@ -1,52 +1,202 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
export interface TimelineProcessFlowProps {
|
import React, { useEffect, useRef, memo, useState } from "react";
|
||||||
children: React.ReactNode;
|
import { gsap } from "gsap";
|
||||||
title?: string;
|
import { ScrollTrigger } from "gsap/ScrollTrigger";
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
import CardStackTextBox from "../../CardStackTextBox";
|
||||||
description?: string;
|
import { useCardAnimation } from "../../hooks/useCardAnimation";
|
||||||
|
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?: any;
|
tagIcon?: LucideIcon;
|
||||||
tagAnimation?: string;
|
tagAnimation?: ButtonAnimationType;
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
buttons?: ButtonConfig[];
|
||||||
buttonAnimation?: string;
|
buttonAnimation?: ButtonAnimationType;
|
||||||
textboxLayout?: string;
|
textboxLayout: TextboxLayout;
|
||||||
animationType?: string;
|
animationType: CardAnimationType;
|
||||||
useInvertedBackground?: boolean;
|
useInvertedBackground?: InvertedBackground;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
textBoxClassName?: string;
|
textBoxClassName?: string;
|
||||||
titleClassName?: string;
|
textBoxTitleClassName?: string;
|
||||||
descriptionClassName?: string;
|
textBoxDescriptionClassName?: string;
|
||||||
tagClassName?: string;
|
textBoxTagClassName?: string;
|
||||||
buttonContainerClassName?: string;
|
textBoxButtonContainerClassName?: string;
|
||||||
buttonClassName?: string;
|
textBoxButtonClassName?: string;
|
||||||
buttonTextClassName?: string;
|
textBoxButtonTextClassName?: string;
|
||||||
|
itemClassName?: string;
|
||||||
|
mediaWrapperClassName?: string;
|
||||||
|
numberClassName?: string;
|
||||||
|
contentWrapperClassName?: string;
|
||||||
gapClassName?: string;
|
gapClassName?: string;
|
||||||
|
titleImageWrapperClassName?: string;
|
||||||
|
titleImageClassName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TimelineProcessFlow: React.FC<TimelineProcessFlowProps> = ({
|
const TimelineProcessFlow = ({
|
||||||
children,
|
items,
|
||||||
containerClassName = '',
|
title,
|
||||||
...props
|
titleSegments,
|
||||||
}) => {
|
description,
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
tag,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
tagIcon,
|
||||||
|
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);
|
||||||
|
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
useEffect(() => {
|
||||||
containerRef,
|
const checkScreenSize = () => {
|
||||||
itemRefs,
|
setIsMdScreen(window.innerWidth >= 768);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
checkScreenSize();
|
||||||
|
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 (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{children}
|
className={cls(
|
||||||
</div>
|
"relative py-20 w-full",
|
||||||
|
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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TimelineProcessFlow;
|
TimelineProcessFlow.displayName = "TimelineProcessFlow";
|
||||||
|
|
||||||
|
export default memo(TimelineProcessFlow);
|
||||||
|
|||||||
@@ -1,48 +1,156 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
"use client";
|
||||||
|
|
||||||
interface Product {
|
import { memo, useMemo, useCallback } from "react";
|
||||||
id: string;
|
import { useRouter } from "next/navigation";
|
||||||
name: string;
|
import Input from "@/components/form/Input";
|
||||||
price: string;
|
import ProductDetailVariantSelect from "@/components/ecommerce/productDetail/ProductDetailVariantSelect";
|
||||||
imageSrc: string;
|
import type { ProductVariant } from "@/components/ecommerce/productDetail/ProductDetailCard";
|
||||||
}
|
import { cls } from "@/lib/utils";
|
||||||
|
import { useProducts } from "@/hooks/useProducts";
|
||||||
interface ProductCatalogState {
|
import ProductCatalogItem from "./ProductCatalogItem";
|
||||||
products: Product[];
|
import type { CatalogProduct } from "./ProductCatalogItem";
|
||||||
loading: boolean;
|
|
||||||
error: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProductCatalogProps {
|
interface ProductCatalogProps {
|
||||||
onProductsLoaded?: (products: Product[]) => void;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ProductCatalog: React.FC<ProductCatalogProps> = ({ onProductsLoaded }) => {
|
const ProductCatalog = ({
|
||||||
const [state, setState] = useState<ProductCatalogState>({
|
layout,
|
||||||
products: [],
|
products: productsProp,
|
||||||
loading: false,
|
searchValue = "",
|
||||||
error: null,
|
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();
|
||||||
|
|
||||||
useEffect(() => {
|
const handleProductClick = useCallback((productId: string) => {
|
||||||
// Initialize or fetch products
|
router.push(`/shop/${productId}`);
|
||||||
setState(prev => ({ ...prev, loading: false }));
|
}, [router]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
const products: CatalogProduct[] = useMemo(() => {
|
||||||
<div className="product-catalog">
|
if (productsProp && productsProp.length > 0) {
|
||||||
{state.loading && <div>Loading...</div>}
|
return productsProp;
|
||||||
{state.error && <div>Error: {state.error}</div>}
|
}
|
||||||
<div className="products">
|
|
||||||
{state.products.map(product => (
|
if (fetchedProducts.length === 0) {
|
||||||
<div key={product.id} className="product-item">
|
return [];
|
||||||
<h3>{product.name}</h3>
|
}
|
||||||
<p>{product.price}</p>
|
|
||||||
</div>
|
return fetchedProducts.map((product) => ({
|
||||||
))}
|
id: product.id,
|
||||||
</div>
|
name: product.name,
|
||||||
</div>
|
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),
|
||||||
|
}));
|
||||||
|
}, [productsProp, fetchedProducts, handleProductClick]);
|
||||||
|
|
||||||
|
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>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProductCatalog;
|
ProductCatalog.displayName = "ProductCatalog";
|
||||||
|
|
||||||
|
export default memo(ProductCatalog);
|
||||||
@@ -1,216 +1,244 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useRef } from 'react';
|
import { memo } from "react";
|
||||||
import gsap from 'gsap';
|
import Image from "next/image";
|
||||||
import { ScrollTrigger } from 'gsap/ScrollTrigger';
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
|
import Badge from "@/components/shared/Badge";
|
||||||
|
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";
|
||||||
|
|
||||||
gsap.registerPlugin(ScrollTrigger);
|
type BlogCard = BlogPost;
|
||||||
|
|
||||||
interface BlogCardOneProps {
|
interface BlogCardOneProps {
|
||||||
blogs: Array<{
|
blogs: BlogCard[];
|
||||||
id: string;
|
carouselMode?: "auto" | "buttons";
|
||||||
category: string;
|
uniformGridCustomHeightClasses?: string;
|
||||||
|
animationType: CardAnimationType;
|
||||||
title: string;
|
title: string;
|
||||||
excerpt: string;
|
titleSegments?: TitleSegment[];
|
||||||
imageSrc: string;
|
description: string;
|
||||||
imageAlt?: string;
|
tag?: string;
|
||||||
authorName: string;
|
tagIcon?: LucideIcon;
|
||||||
authorAvatar: string;
|
tagAnimation?: ButtonAnimationType;
|
||||||
date: string;
|
buttons?: ButtonConfig[];
|
||||||
onBlogClick?: () => void;
|
buttonAnimation?: ButtonAnimationType;
|
||||||
}>;
|
textboxLayout: TextboxLayout;
|
||||||
carouselMode?: 'auto' | 'buttons';
|
useInvertedBackground: InvertedBackground;
|
||||||
uniformGridCustomHeightClasses?: string;
|
ariaLabel?: string;
|
||||||
animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
|
className?: string;
|
||||||
title: string;
|
containerClassName?: string;
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
cardClassName?: string;
|
||||||
description: string;
|
imageWrapperClassName?: string;
|
||||||
tag?: string;
|
imageClassName?: string;
|
||||||
tagIcon?: React.ComponentType<any>;
|
categoryClassName?: 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';
|
authorContainerClassName?: string;
|
||||||
textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
|
authorAvatarClassName?: string;
|
||||||
useInvertedBackground: boolean;
|
authorNameClassName?: string;
|
||||||
ariaLabel?: string;
|
dateClassName?: 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlogCardOne: React.FC<BlogCardOneProps> = ({
|
interface BlogCardItemProps {
|
||||||
blogs,
|
blog: BlogCard;
|
||||||
carouselMode = 'buttons',
|
shouldUseLightText: boolean;
|
||||||
uniformGridCustomHeightClasses = 'min-h-95 2xl:min-h-105',
|
cardClassName?: string;
|
||||||
animationType,
|
imageWrapperClassName?: string;
|
||||||
title,
|
imageClassName?: string;
|
||||||
titleSegments,
|
categoryClassName?: string;
|
||||||
description,
|
cardTitleClassName?: string;
|
||||||
tag,
|
excerptClassName?: string;
|
||||||
tagIcon: TagIcon,
|
authorContainerClassName?: string;
|
||||||
tagAnimation,
|
authorAvatarClassName?: string;
|
||||||
buttons,
|
authorNameClassName?: string;
|
||||||
buttonAnimation,
|
dateClassName?: 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)[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const BlogCardItem = memo(({
|
||||||
if (animationType === 'none' || !sectionRef.current) return;
|
blog,
|
||||||
|
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>
|
||||||
|
|
||||||
const cards = cardsRef.current.filter((card): card is HTMLDivElement => card !== null);
|
<div className="relative z-1 flex flex-col justify-between gap-6 flex-1">
|
||||||
if (cards.length === 0) return;
|
<div className="flex flex-col gap-2">
|
||||||
|
<Badge text={blog.category} variant="primary" className={categoryClassName} />
|
||||||
|
|
||||||
cards.forEach((card, index) => {
|
<h3 className={cls("text-2xl font-medium leading-[1.25] mt-1", shouldUseLightText ? "text-background" : "text-foreground", cardTitleClassName)}>
|
||||||
gsap.set(card, { opacity: 0, y: 20 });
|
{blog.title}
|
||||||
|
</h3>
|
||||||
|
|
||||||
ScrollTrigger.create({
|
<p className={cls("text-base leading-[1.25]", shouldUseLightText ? "text-background" : "text-foreground", excerptClassName)}>
|
||||||
trigger: card,
|
{blog.excerpt}
|
||||||
onEnter: () => {
|
</p>
|
||||||
gsap.to(card, {
|
</div>
|
||||||
opacity: 1,
|
|
||||||
y: 0,
|
|
||||||
duration: 0.6,
|
|
||||||
delay: index * 0.1,
|
|
||||||
ease: 'power2.out',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
<div className={cls("flex items-center gap-3", authorContainerClassName)}>
|
||||||
cards.forEach(() => ScrollTrigger.getAll().forEach(trigger => trigger.kill()));
|
<Image
|
||||||
};
|
src={blog.authorAvatar}
|
||||||
}, [animationType]);
|
alt={blog.authorName}
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const gridVariant = blogs.length <= 4 ? 'uniform-all-items-equal' : 'uniform-all-items-equal';
|
BlogCardItem.displayName = "BlogCardItem";
|
||||||
const mode = blogs.length >= 5 ? 'auto' : carouselMode;
|
|
||||||
|
|
||||||
const blogChildren = blogs.map((blog, index) => (
|
const BlogCardOne = ({
|
||||||
<div
|
blogs = [],
|
||||||
key={blog.id}
|
carouselMode = "buttons",
|
||||||
ref={el => {
|
uniformGridCustomHeightClasses,
|
||||||
cardsRef.current[index] = el;
|
animationType,
|
||||||
}}
|
title,
|
||||||
className={`cursor-pointer group ${cardClassName}`}
|
titleSegments,
|
||||||
onClick={blog.onBlogClick}
|
description,
|
||||||
>
|
tag,
|
||||||
{/* Image wrapper with overlay arrow */}
|
tagIcon,
|
||||||
<div className={`relative overflow-hidden rounded-lg ${imageWrapperClassName}`}>
|
tagAnimation,
|
||||||
<img
|
buttons,
|
||||||
src={blog.imageSrc}
|
buttonAnimation,
|
||||||
alt={blog.imageAlt || blog.title}
|
textboxLayout,
|
||||||
className={`w-full h-full object-cover transition-transform duration-300 group-hover:scale-110 ${imageClassName}`}
|
useInvertedBackground,
|
||||||
/>
|
ariaLabel = "Blog section",
|
||||||
<div className="absolute inset-0 bg-black/20 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-center justify-center">
|
className = "",
|
||||||
<div className="text-white text-3xl">→</div>
|
containerClassName = "",
|
||||||
</div>
|
cardClassName = "",
|
||||||
</div>
|
imageWrapperClassName = "",
|
||||||
|
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);
|
||||||
|
|
||||||
{/* Category badge */}
|
return (
|
||||||
<div className={`mt-4 inline-block px-3 py-1 rounded-full bg-blue-500/20 text-blue-400 text-sm font-semibold ${categoryClassName}`}>
|
<CardStack
|
||||||
{blog.category}
|
mode={carouselMode}
|
||||||
</div>
|
gridVariant="uniform-all-items-equal"
|
||||||
|
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
|
||||||
{/* Title */}
|
animationType={animationType}
|
||||||
<h3 className={`mt-3 text-xl font-bold text-gray-900 dark:text-white line-clamp-2 ${cardTitleClassName}`}>
|
|
||||||
{blog.title}
|
title={title}
|
||||||
</h3>
|
titleSegments={titleSegments}
|
||||||
|
description={description}
|
||||||
{/* Excerpt */}
|
tag={tag}
|
||||||
<p className={`mt-2 text-gray-600 dark:text-gray-300 text-sm line-clamp-2 ${excerptClassName}`}>
|
tagIcon={tagIcon}
|
||||||
{blog.excerpt}
|
tagAnimation={tagAnimation}
|
||||||
</p>
|
buttons={buttons}
|
||||||
|
buttonAnimation={buttonAnimation}
|
||||||
{/* Author info */}
|
textboxLayout={textboxLayout}
|
||||||
<div className={`mt-4 flex items-center gap-3 ${authorContainerClassName}`}>
|
useInvertedBackground={useInvertedBackground}
|
||||||
<img
|
ariaLabel={ariaLabel}
|
||||||
src={blog.authorAvatar}
|
className={className}
|
||||||
alt={blog.authorName}
|
containerClassName={containerClassName}
|
||||||
className={`w-8 h-8 rounded-full object-cover ${authorAvatarClassName}`}
|
gridClassName={gridClassName}
|
||||||
/>
|
carouselClassName={carouselClassName}
|
||||||
<div className="flex-1 min-w-0">
|
controlsClassName={controlsClassName}
|
||||||
<p className={`text-sm font-semibold text-gray-900 dark:text-white truncate ${authorNameClassName}`}>
|
textBoxClassName={textBoxClassName}
|
||||||
{blog.authorName}
|
titleClassName={textBoxTitleClassName}
|
||||||
</p>
|
titleImageWrapperClassName={textBoxTitleImageWrapperClassName}
|
||||||
<p className={`text-xs text-gray-500 dark:text-gray-400 ${dateClassName}`}>{blog.date}</p>
|
titleImageClassName={textBoxTitleImageClassName}
|
||||||
</div>
|
descriptionClassName={textBoxDescriptionClassName}
|
||||||
</div>
|
tagClassName={textBoxTagClassName}
|
||||||
</div>
|
buttonContainerClassName={textBoxButtonContainerClassName}
|
||||||
));
|
buttonClassName={textBoxButtonClassName}
|
||||||
|
buttonTextClassName={textBoxButtonTextClassName}
|
||||||
return (
|
>
|
||||||
<section ref={sectionRef} className={`py-12 md:py-20 ${className}`} aria-label={ariaLabel}>
|
{blogs.map((blog) => (
|
||||||
<TimelineHorizontalCardStack
|
<BlogCardItem
|
||||||
children={blogChildren}
|
key={blog.id}
|
||||||
title={title}
|
blog={blog}
|
||||||
titleSegments={titleSegments}
|
shouldUseLightText={shouldUseLightText}
|
||||||
description={description}
|
cardClassName={cardClassName}
|
||||||
tag={tag}
|
imageWrapperClassName={imageWrapperClassName}
|
||||||
tagIcon={TagIcon}
|
imageClassName={imageClassName}
|
||||||
tagAnimation={tagAnimation}
|
categoryClassName={categoryClassName}
|
||||||
buttons={buttons}
|
cardTitleClassName={cardTitleClassName}
|
||||||
buttonAnimation={buttonAnimation}
|
excerptClassName={excerptClassName}
|
||||||
textboxLayout={textboxLayout}
|
authorContainerClassName={authorContainerClassName}
|
||||||
useInvertedBackground={useInvertedBackground}
|
authorAvatarClassName={authorAvatarClassName}
|
||||||
ariaLabel={ariaLabel}
|
authorNameClassName={authorNameClassName}
|
||||||
className={className}
|
dateClassName={dateClassName}
|
||||||
containerClassName={containerClassName}
|
/>
|
||||||
textBoxClassName={textBoxClassName}
|
))}
|
||||||
titleClassName={textBoxTitleImageClassName}
|
</CardStack>
|
||||||
descriptionClassName={textBoxDescriptionClassName}
|
);
|
||||||
tagClassName={textBoxTagClassName}
|
|
||||||
buttonContainerClassName={textBoxButtonContainerClassName}
|
|
||||||
buttonClassName={textBoxButtonClassName}
|
|
||||||
buttonTextClassName={textBoxButtonTextClassName}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BlogCardOne;
|
BlogCardOne.displayName = "BlogCardOne";
|
||||||
|
|
||||||
|
export default BlogCardOne;
|
||||||
|
|||||||
@@ -1,216 +1,288 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useRef } from 'react';
|
import { memo } from "react";
|
||||||
import gsap from 'gsap';
|
import Image from "next/image";
|
||||||
import { ScrollTrigger } from 'gsap/ScrollTrigger';
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
|
import Tag from "@/components/shared/Tag";
|
||||||
|
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";
|
||||||
|
|
||||||
gsap.registerPlugin(ScrollTrigger);
|
type BlogCard = BlogPost;
|
||||||
|
|
||||||
interface BlogCardThreeProps {
|
interface BlogCardThreeProps {
|
||||||
blogs: Array<{
|
blogs: BlogCard[];
|
||||||
id: string;
|
carouselMode?: "auto" | "buttons";
|
||||||
category: string;
|
uniformGridCustomHeightClasses?: string;
|
||||||
|
animationType: CardAnimationType;
|
||||||
title: string;
|
title: string;
|
||||||
excerpt: string;
|
titleSegments?: TitleSegment[];
|
||||||
imageSrc: string;
|
description: string;
|
||||||
imageAlt?: string;
|
tag?: string;
|
||||||
authorName: string;
|
tagIcon?: LucideIcon;
|
||||||
authorAvatar: string;
|
tagAnimation?: ButtonAnimationType;
|
||||||
date: string;
|
buttons?: ButtonConfig[];
|
||||||
onBlogClick?: () => void;
|
buttonAnimation?: ButtonAnimationType;
|
||||||
}>;
|
textboxLayout: TextboxLayout;
|
||||||
carouselMode?: 'auto' | 'buttons';
|
useInvertedBackground: InvertedBackground;
|
||||||
uniformGridCustomHeightClasses?: string;
|
ariaLabel?: string;
|
||||||
animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
|
className?: string;
|
||||||
title: string;
|
containerClassName?: string;
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
cardClassName?: string;
|
||||||
description: string;
|
cardContentClassName?: string;
|
||||||
tag?: string;
|
categoryTagClassName?: 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;
|
mediaWrapperClassName?: string;
|
||||||
className?: string;
|
mediaClassName?: string;
|
||||||
containerClassName?: string;
|
textBoxTitleClassName?: string;
|
||||||
cardClassName?: string;
|
textBoxTitleImageWrapperClassName?: string;
|
||||||
imageWrapperClassName?: string;
|
textBoxTitleImageClassName?: string;
|
||||||
imageClassName?: string;
|
textBoxDescriptionClassName?: string;
|
||||||
categoryClassName?: string;
|
gridClassName?: string;
|
||||||
cardTitleClassName?: string;
|
carouselClassName?: string;
|
||||||
excerptClassName?: string;
|
controlsClassName?: string;
|
||||||
authorContainerClassName?: string;
|
textBoxClassName?: string;
|
||||||
authorAvatarClassName?: string;
|
textBoxTagClassName?: string;
|
||||||
authorNameClassName?: string;
|
textBoxButtonContainerClassName?: string;
|
||||||
dateClassName?: string;
|
textBoxButtonClassName?: string;
|
||||||
textBoxTitleImageClassName?: string;
|
textBoxButtonTextClassName?: string;
|
||||||
textBoxDescriptionClassName?: string;
|
|
||||||
gridClassName?: string;
|
|
||||||
carouselClassName?: string;
|
|
||||||
controlsClassName?: string;
|
|
||||||
textBoxClassName?: string;
|
|
||||||
textBoxTagClassName?: string;
|
|
||||||
textBoxButtonContainerClassName?: string;
|
|
||||||
textBoxButtonClassName?: string;
|
|
||||||
textBoxButtonTextClassName?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlogCardThree: React.FC<BlogCardThreeProps> = ({
|
interface BlogCardItemProps {
|
||||||
blogs,
|
blog: BlogCard;
|
||||||
carouselMode = 'buttons',
|
useInvertedBackground: boolean;
|
||||||
uniformGridCustomHeightClasses = 'min-h-95 2xl:min-h-105',
|
cardClassName?: string;
|
||||||
animationType,
|
cardContentClassName?: string;
|
||||||
title,
|
categoryTagClassName?: string;
|
||||||
titleSegments,
|
cardTitleClassName?: string;
|
||||||
description,
|
excerptClassName?: string;
|
||||||
tag,
|
authorContainerClassName?: string;
|
||||||
tagIcon: TagIcon,
|
authorAvatarClassName?: string;
|
||||||
tagAnimation,
|
authorNameClassName?: string;
|
||||||
buttons,
|
dateClassName?: string;
|
||||||
buttonAnimation,
|
mediaWrapperClassName?: string;
|
||||||
textboxLayout,
|
mediaClassName?: string;
|
||||||
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)[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const BlogCardItem = memo(({
|
||||||
if (animationType === 'none' || !sectionRef.current) return;
|
blog,
|
||||||
|
useInvertedBackground,
|
||||||
|
cardClassName = "",
|
||||||
|
cardContentClassName = "",
|
||||||
|
categoryTagClassName = "",
|
||||||
|
cardTitleClassName = "",
|
||||||
|
excerptClassName = "",
|
||||||
|
authorContainerClassName = "",
|
||||||
|
authorAvatarClassName = "",
|
||||||
|
authorNameClassName = "",
|
||||||
|
dateClassName = "",
|
||||||
|
mediaWrapperClassName = "",
|
||||||
|
mediaClassName = "",
|
||||||
|
}: BlogCardItemProps) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
|
||||||
|
|
||||||
const cards = cardsRef.current.filter((card): card is HTMLDivElement => card !== null);
|
return (
|
||||||
if (cards.length === 0) return;
|
<article
|
||||||
|
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}
|
||||||
|
/>
|
||||||
|
|
||||||
cards.forEach((card, index) => {
|
<h3 className={cls(
|
||||||
gsap.set(card, { opacity: 0, y: 20 });
|
"text-3xl md:text-4xl font-medium leading-tight line-clamp-2",
|
||||||
|
shouldUseLightText ? "text-background" : "text-foreground",
|
||||||
|
cardTitleClassName
|
||||||
|
)}>
|
||||||
|
{blog.title}
|
||||||
|
</h3>
|
||||||
|
|
||||||
ScrollTrigger.create({
|
<p className={cls(
|
||||||
trigger: card,
|
"text-base leading-tight line-clamp-2",
|
||||||
onEnter: () => {
|
shouldUseLightText ? "text-background/75" : "text-foreground/75",
|
||||||
gsap.to(card, {
|
excerptClassName
|
||||||
opacity: 1,
|
)}>
|
||||||
y: 0,
|
{blog.excerpt}
|
||||||
duration: 0.6,
|
</p>
|
||||||
delay: index * 0.1,
|
|
||||||
ease: 'power2.out',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
{(blog.authorName || blog.date) && (
|
||||||
cards.forEach(() => ScrollTrigger.getAll().forEach(trigger => trigger.kill()));
|
<div className={cls(
|
||||||
};
|
"flex",
|
||||||
}, [animationType]);
|
blog.authorAvatar ? "items-center gap-3" : "flex-row justify-between items-center",
|
||||||
|
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>
|
||||||
|
|
||||||
const gridVariant = blogs.length <= 4 ? 'uniform-all-items-equal' : 'uniform-all-items-equal';
|
<div className={cls("relative z-1 w-full aspect-square", mediaWrapperClassName)}>
|
||||||
const mode = blogs.length >= 5 ? 'auto' : carouselMode;
|
<MediaContent
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const blogChildren = blogs.map((blog, index) => (
|
BlogCardItem.displayName = "BlogCardItem";
|
||||||
<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>
|
|
||||||
|
|
||||||
{/* Category badge */}
|
const BlogCardThree = ({
|
||||||
<div className={`mt-4 inline-block px-3 py-1 rounded-full bg-blue-500/20 text-blue-400 text-sm font-semibold ${categoryClassName}`}>
|
blogs = [],
|
||||||
{blog.category}
|
carouselMode = "buttons",
|
||||||
</div>
|
uniformGridCustomHeightClasses = "min-h-none",
|
||||||
|
animationType,
|
||||||
{/* Title */}
|
title,
|
||||||
<h3 className={`mt-3 text-xl font-bold text-gray-900 dark:text-white line-clamp-2 ${cardTitleClassName}`}>
|
titleSegments,
|
||||||
{blog.title}
|
description,
|
||||||
</h3>
|
tag,
|
||||||
|
tagIcon,
|
||||||
{/* Excerpt */}
|
tagAnimation,
|
||||||
<p className={`mt-2 text-gray-600 dark:text-gray-300 text-sm line-clamp-2 ${excerptClassName}`}>
|
buttons,
|
||||||
{blog.excerpt}
|
buttonAnimation,
|
||||||
</p>
|
textboxLayout,
|
||||||
|
useInvertedBackground,
|
||||||
{/* Author info */}
|
ariaLabel = "Blog section",
|
||||||
<div className={`mt-4 flex items-center gap-3 ${authorContainerClassName}`}>
|
className = "",
|
||||||
<img
|
containerClassName = "",
|
||||||
src={blog.authorAvatar}
|
cardClassName = "",
|
||||||
alt={blog.authorName}
|
cardContentClassName = "",
|
||||||
className={`w-8 h-8 rounded-full object-cover ${authorAvatarClassName}`}
|
categoryTagClassName = "",
|
||||||
/>
|
cardTitleClassName = "",
|
||||||
<div className="flex-1 min-w-0">
|
excerptClassName = "",
|
||||||
<p className={`text-sm font-semibold text-gray-900 dark:text-white truncate ${authorNameClassName}`}>
|
authorContainerClassName = "",
|
||||||
{blog.authorName}
|
authorAvatarClassName = "",
|
||||||
</p>
|
authorNameClassName = "",
|
||||||
<p className={`text-xs text-gray-500 dark:text-gray-400 ${dateClassName}`}>{blog.date}</p>
|
dateClassName = "",
|
||||||
</div>
|
mediaWrapperClassName = "",
|
||||||
</div>
|
mediaClassName = "",
|
||||||
</div>
|
textBoxTitleClassName = "",
|
||||||
));
|
textBoxTitleImageWrapperClassName = "",
|
||||||
|
textBoxTitleImageClassName = "",
|
||||||
return (
|
textBoxDescriptionClassName = "",
|
||||||
<section ref={sectionRef} className={`py-12 md:py-20 ${className}`} aria-label={ariaLabel}>
|
gridClassName = "",
|
||||||
<TimelineHorizontalCardStack
|
carouselClassName = "",
|
||||||
children={blogChildren}
|
controlsClassName = "",
|
||||||
title={title}
|
textBoxClassName = "",
|
||||||
titleSegments={titleSegments}
|
textBoxTagClassName = "",
|
||||||
description={description}
|
textBoxButtonContainerClassName = "",
|
||||||
tag={tag}
|
textBoxButtonClassName = "",
|
||||||
tagIcon={TagIcon}
|
textBoxButtonTextClassName = "",
|
||||||
tagAnimation={tagAnimation}
|
}: BlogCardThreeProps) => {
|
||||||
buttons={buttons}
|
return (
|
||||||
buttonAnimation={buttonAnimation}
|
<CardStack
|
||||||
textboxLayout={textboxLayout}
|
mode={carouselMode}
|
||||||
useInvertedBackground={useInvertedBackground}
|
gridVariant="uniform-all-items-equal"
|
||||||
ariaLabel={ariaLabel}
|
uniformGridCustomHeightClasses={uniformGridCustomHeightClasses}
|
||||||
className={className}
|
animationType={animationType}
|
||||||
containerClassName={containerClassName}
|
|
||||||
textBoxClassName={textBoxClassName}
|
title={title}
|
||||||
titleClassName={textBoxTitleImageClassName}
|
titleSegments={titleSegments}
|
||||||
descriptionClassName={textBoxDescriptionClassName}
|
description={description}
|
||||||
tagClassName={textBoxTagClassName}
|
tag={tag}
|
||||||
buttonContainerClassName={textBoxButtonContainerClassName}
|
tagIcon={tagIcon}
|
||||||
buttonClassName={textBoxButtonClassName}
|
tagAnimation={tagAnimation}
|
||||||
buttonTextClassName={textBoxButtonTextClassName}
|
buttons={buttons}
|
||||||
/>
|
buttonAnimation={buttonAnimation}
|
||||||
</section>
|
textboxLayout={textboxLayout}
|
||||||
);
|
useInvertedBackground={useInvertedBackground}
|
||||||
|
ariaLabel={ariaLabel}
|
||||||
|
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}
|
||||||
|
>
|
||||||
|
{blogs.map((blog) => (
|
||||||
|
<BlogCardItem
|
||||||
|
key={blog.id}
|
||||||
|
blog={blog}
|
||||||
|
useInvertedBackground={useInvertedBackground}
|
||||||
|
cardClassName={cardClassName}
|
||||||
|
cardContentClassName={cardContentClassName}
|
||||||
|
categoryTagClassName={categoryTagClassName}
|
||||||
|
cardTitleClassName={cardTitleClassName}
|
||||||
|
excerptClassName={excerptClassName}
|
||||||
|
authorContainerClassName={authorContainerClassName}
|
||||||
|
authorAvatarClassName={authorAvatarClassName}
|
||||||
|
authorNameClassName={authorNameClassName}
|
||||||
|
dateClassName={dateClassName}
|
||||||
|
mediaWrapperClassName={mediaWrapperClassName}
|
||||||
|
mediaClassName={mediaClassName}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardStack>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BlogCardThree;
|
BlogCardThree.displayName = "BlogCardThree";
|
||||||
|
|
||||||
|
export default BlogCardThree;
|
||||||
|
|||||||
@@ -1,216 +1,241 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useRef } from 'react';
|
import { memo } from "react";
|
||||||
import gsap from 'gsap';
|
import Image from "next/image";
|
||||||
import { ScrollTrigger } from 'gsap/ScrollTrigger';
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
import TimelineHorizontalCardStack from '@/components/cardStack/layouts/timelines/TimelineHorizontalCardStack';
|
import Badge from "@/components/shared/Badge";
|
||||||
|
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";
|
||||||
|
|
||||||
gsap.registerPlugin(ScrollTrigger);
|
type BlogCard = Omit<BlogPost, 'category'> & {
|
||||||
|
category: string | string[];
|
||||||
interface BlogCardTwoProps {
|
|
||||||
blogs: Array<{
|
|
||||||
id: string;
|
|
||||||
category: string;
|
|
||||||
title: string;
|
|
||||||
excerpt: string;
|
|
||||||
imageSrc: string;
|
|
||||||
imageAlt?: string;
|
|
||||||
authorName: string;
|
|
||||||
authorAvatar: string;
|
|
||||||
date: string;
|
|
||||||
onBlogClick?: () => void;
|
|
||||||
}>;
|
|
||||||
carouselMode?: 'auto' | 'buttons';
|
|
||||||
uniformGridCustomHeightClasses?: string;
|
|
||||||
animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
|
|
||||||
title: string;
|
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
|
||||||
description: string;
|
|
||||||
tag?: string;
|
|
||||||
tagIcon?: React.ComponentType<any>;
|
|
||||||
tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
|
||||||
buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
|
||||||
textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
|
|
||||||
useInvertedBackground: boolean;
|
|
||||||
ariaLabel?: string;
|
|
||||||
className?: string;
|
|
||||||
containerClassName?: string;
|
|
||||||
cardClassName?: string;
|
|
||||||
imageWrapperClassName?: string;
|
|
||||||
imageClassName?: string;
|
|
||||||
categoryClassName?: string;
|
|
||||||
cardTitleClassName?: string;
|
|
||||||
excerptClassName?: string;
|
|
||||||
authorContainerClassName?: 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BlogCardTwo: React.FC<BlogCardTwoProps> = ({
|
|
||||||
blogs,
|
|
||||||
carouselMode = 'buttons',
|
|
||||||
uniformGridCustomHeightClasses = 'min-h-95 2xl:min-h-105',
|
|
||||||
animationType,
|
|
||||||
title,
|
|
||||||
titleSegments,
|
|
||||||
description,
|
|
||||||
tag,
|
|
||||||
tagIcon: TagIcon,
|
|
||||||
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)[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (animationType === 'none' || !sectionRef.current) return;
|
|
||||||
|
|
||||||
const cards = cardsRef.current.filter((card): card is HTMLDivElement => card !== null);
|
|
||||||
if (cards.length === 0) return;
|
|
||||||
|
|
||||||
cards.forEach((card, index) => {
|
|
||||||
gsap.set(card, { opacity: 0, y: 20 });
|
|
||||||
|
|
||||||
ScrollTrigger.create({
|
|
||||||
trigger: card,
|
|
||||||
onEnter: () => {
|
|
||||||
gsap.to(card, {
|
|
||||||
opacity: 1,
|
|
||||||
y: 0,
|
|
||||||
duration: 0.6,
|
|
||||||
delay: index * 0.1,
|
|
||||||
ease: 'power2.out',
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cards.forEach(() => ScrollTrigger.getAll().forEach(trigger => trigger.kill()));
|
|
||||||
};
|
|
||||||
}, [animationType]);
|
|
||||||
|
|
||||||
const gridVariant = blogs.length <= 4 ? 'uniform-all-items-equal' : 'uniform-all-items-equal';
|
|
||||||
const mode = blogs.length >= 5 ? 'auto' : carouselMode;
|
|
||||||
|
|
||||||
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>
|
|
||||||
|
|
||||||
{/* Category badge */}
|
|
||||||
<div className={`mt-4 inline-block px-3 py-1 rounded-full bg-blue-500/20 text-blue-400 text-sm font-semibold ${categoryClassName}`}>
|
|
||||||
{blog.category}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Title */}
|
|
||||||
<h3 className={`mt-3 text-xl font-bold text-gray-900 dark:text-white line-clamp-2 ${cardTitleClassName}`}>
|
|
||||||
{blog.title}
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
{/* Excerpt */}
|
|
||||||
<p className={`mt-2 text-gray-600 dark:text-gray-300 text-sm line-clamp-2 ${excerptClassName}`}>
|
|
||||||
{blog.excerpt}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{/* Author info */}
|
|
||||||
<div className={`mt-4 flex items-center gap-3 ${authorContainerClassName}`}>
|
|
||||||
<img
|
|
||||||
src={blog.authorAvatar}
|
|
||||||
alt={blog.authorName}
|
|
||||||
className={`w-8 h-8 rounded-full object-cover ${authorAvatarClassName}`}
|
|
||||||
/>
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<p className={`text-sm font-semibold text-gray-900 dark:text-white truncate ${authorNameClassName}`}>
|
|
||||||
{blog.authorName}
|
|
||||||
</p>
|
|
||||||
<p className={`text-xs text-gray-500 dark:text-gray-400 ${dateClassName}`}>{blog.date}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section ref={sectionRef} className={`py-12 md:py-20 ${className}`} aria-label={ariaLabel}>
|
|
||||||
<TimelineHorizontalCardStack
|
|
||||||
children={blogChildren}
|
|
||||||
title={title}
|
|
||||||
titleSegments={titleSegments}
|
|
||||||
description={description}
|
|
||||||
tag={tag}
|
|
||||||
tagIcon={TagIcon}
|
|
||||||
tagAnimation={tagAnimation}
|
|
||||||
buttons={buttons}
|
|
||||||
buttonAnimation={buttonAnimation}
|
|
||||||
textboxLayout={textboxLayout}
|
|
||||||
useInvertedBackground={useInvertedBackground}
|
|
||||||
ariaLabel={ariaLabel}
|
|
||||||
className={className}
|
|
||||||
containerClassName={containerClassName}
|
|
||||||
textBoxClassName={textBoxClassName}
|
|
||||||
titleClassName={textBoxTitleImageClassName}
|
|
||||||
descriptionClassName={textBoxDescriptionClassName}
|
|
||||||
tagClassName={textBoxTagClassName}
|
|
||||||
buttonContainerClassName={textBoxButtonContainerClassName}
|
|
||||||
buttonClassName={textBoxButtonClassName}
|
|
||||||
buttonTextClassName={textBoxButtonTextClassName}
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BlogCardTwo;
|
interface BlogCardTwoProps {
|
||||||
|
blogs: BlogCard[];
|
||||||
|
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;
|
||||||
|
imageWrapperClassName?: string;
|
||||||
|
imageClassName?: string;
|
||||||
|
authorAvatarClassName?: string;
|
||||||
|
authorDateClassName?: string;
|
||||||
|
cardTitleClassName?: string;
|
||||||
|
excerptClassName?: string;
|
||||||
|
categoryClassName?: string;
|
||||||
|
textBoxTitleClassName?: string;
|
||||||
|
textBoxTitleImageWrapperClassName?: string;
|
||||||
|
textBoxTitleImageClassName?: string;
|
||||||
|
textBoxDescriptionClassName?: string;
|
||||||
|
gridClassName?: string;
|
||||||
|
carouselClassName?: string;
|
||||||
|
controlsClassName?: string;
|
||||||
|
textBoxClassName?: string;
|
||||||
|
textBoxTagClassName?: string;
|
||||||
|
textBoxButtonContainerClassName?: string;
|
||||||
|
textBoxButtonClassName?: string;
|
||||||
|
textBoxButtonTextClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BlogCardItemProps {
|
||||||
|
blog: BlogCard;
|
||||||
|
shouldUseLightText: boolean;
|
||||||
|
cardClassName?: string;
|
||||||
|
imageWrapperClassName?: string;
|
||||||
|
imageClassName?: string;
|
||||||
|
authorAvatarClassName?: string;
|
||||||
|
authorDateClassName?: string;
|
||||||
|
cardTitleClassName?: string;
|
||||||
|
excerptClassName?: string;
|
||||||
|
categoryClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BlogCardItem = memo(({
|
||||||
|
blog,
|
||||||
|
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">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<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)}>
|
||||||
|
{blog.title}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<p className={cls("text-base leading-[1.25]", shouldUseLightText ? "text-background" : "text-foreground", excerptClassName)}>
|
||||||
|
{blog.excerpt}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
{Array.isArray(blog.category) ? (
|
||||||
|
blog.category.map((cat, index) => (
|
||||||
|
<Badge key={`${cat}-${index}`} text={cat} variant="primary" className={categoryClassName} />
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Badge text={blog.category} variant="primary" className={categoryClassName} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
BlogCardItem.displayName = "BlogCardItem";
|
||||||
|
|
||||||
|
const BlogCardTwo = ({
|
||||||
|
blogs = [],
|
||||||
|
carouselMode = "buttons",
|
||||||
|
uniformGridCustomHeightClasses,
|
||||||
|
animationType,
|
||||||
|
title,
|
||||||
|
titleSegments,
|
||||||
|
description,
|
||||||
|
tag,
|
||||||
|
tagIcon,
|
||||||
|
tagAnimation,
|
||||||
|
buttons,
|
||||||
|
buttonAnimation,
|
||||||
|
textboxLayout,
|
||||||
|
useInvertedBackground,
|
||||||
|
ariaLabel = "Blog section",
|
||||||
|
className = "",
|
||||||
|
containerClassName = "",
|
||||||
|
cardClassName = "",
|
||||||
|
imageWrapperClassName = "",
|
||||||
|
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 (
|
||||||
|
<CardStack
|
||||||
|
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}
|
||||||
|
useInvertedBackground={useInvertedBackground}
|
||||||
|
ariaLabel={ariaLabel}
|
||||||
|
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}
|
||||||
|
>
|
||||||
|
{blogs.map((blog) => (
|
||||||
|
<BlogCardItem
|
||||||
|
key={blog.id}
|
||||||
|
blog={blog}
|
||||||
|
shouldUseLightText={shouldUseLightText}
|
||||||
|
cardClassName={cardClassName}
|
||||||
|
imageWrapperClassName={imageWrapperClassName}
|
||||||
|
imageClassName={imageClassName}
|
||||||
|
authorAvatarClassName={authorAvatarClassName}
|
||||||
|
authorDateClassName={authorDateClassName}
|
||||||
|
cardTitleClassName={cardTitleClassName}
|
||||||
|
excerptClassName={excerptClassName}
|
||||||
|
categoryClassName={categoryClassName}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardStack>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
BlogCardTwo.displayName = "BlogCardTwo";
|
||||||
|
|
||||||
|
export default BlogCardTwo;
|
||||||
|
|||||||
@@ -1,102 +1,131 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
import ContactForm from "@/components/form/ContactForm";
|
||||||
import { Mail, Phone, MapPin } from 'lucide-react';
|
import HeroBackgrounds, { type HeroBackgroundVariantProps } from "@/components/background/HeroBackgrounds";
|
||||||
|
import { cls } from "@/lib/utils";
|
||||||
|
import { LucideIcon } from "lucide-react";
|
||||||
|
import { sendContactEmail } from "@/utils/sendContactEmail";
|
||||||
|
import type { ButtonAnimationType } from "@/types/button";
|
||||||
|
|
||||||
interface ContactFormData {
|
type ContactCenterBackgroundProps = Extract<
|
||||||
name: string;
|
HeroBackgroundVariantProps,
|
||||||
email: string;
|
| { variant: "plain" }
|
||||||
message: string;
|
| { variant: "animated-grid" }
|
||||||
|
| { 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ContactCenter: React.FC = () => {
|
const ContactCenter = ({
|
||||||
const [formData, setFormData] = useState<ContactFormData>({
|
title,
|
||||||
name: '',
|
description,
|
||||||
email: '',
|
tag,
|
||||||
message: '',
|
tagIcon,
|
||||||
});
|
tagAnimation,
|
||||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
background,
|
||||||
|
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 handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
const handleSubmit = async (email: string) => {
|
||||||
const { name, value } = e.target;
|
try {
|
||||||
setFormData(prev => ({ ...prev, [name]: value }));
|
await sendContactEmail({ email });
|
||||||
};
|
console.log("Email send successfully");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to send email:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
return (
|
||||||
e.preventDefault();
|
<section aria-label={ariaLabel} className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}>
|
||||||
setIsSubmitted(true);
|
<div className={cls("w-content-width mx-auto relative z-10", containerClassName)}>
|
||||||
setFormData({ name: '', email: '', message: '' });
|
<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)}>
|
||||||
setTimeout(() => setIsSubmitted(false), 3000);
|
<div className="relative z-10 w-full md:w-1/2">
|
||||||
};
|
<ContactForm
|
||||||
|
tag={tag}
|
||||||
return (
|
tagIcon={tagIcon}
|
||||||
<div className="max-w-4xl mx-auto px-4 py-16">
|
tagAnimation={tagAnimation}
|
||||||
<div className="text-center mb-12">
|
title={title}
|
||||||
<h2 className="text-4xl font-bold mb-4">Get in Touch</h2>
|
description={description}
|
||||||
<p className="text-lg text-gray-600">We'd love to hear from you. Send us a message!</p>
|
useInvertedBackground={useInvertedBackground}
|
||||||
</div>
|
inputPlaceholder={inputPlaceholder}
|
||||||
|
buttonText={buttonText}
|
||||||
<div className="grid md:grid-cols-2 gap-8">
|
termsText={termsText}
|
||||||
<div className="space-y-6">
|
onSubmit={handleSubmit}
|
||||||
<div className="flex items-start gap-4">
|
centered={true}
|
||||||
<Mail className="w-6 h-6 mt-1 text-primary" />
|
tagClassName={tagClassName}
|
||||||
<div>
|
titleClassName={titleClassName}
|
||||||
<h3 className="font-semibold mb-1">Email</h3>
|
descriptionClassName={descriptionClassName}
|
||||||
<p className="text-gray-600">hello@company.com</p>
|
formWrapperClassName={cls("md:w-8/10 2xl:w-6/10", formWrapperClassName)}
|
||||||
|
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>
|
||||||
</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>
|
|
||||||
</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;
|
||||||
|
|||||||
@@ -1,32 +1,188 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
interface ContactFaqProps {
|
import { useState, Fragment } from "react";
|
||||||
faqs: Array<{ id: string; title: string; content: string }>;
|
import { cls, shouldUseInvertedText } from "@/lib/utils";
|
||||||
containerClassName?: string;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ContactFaq: React.FC<ContactFaqProps> = ({ faqs, containerClassName = '' }) => {
|
interface ContactFaqProps {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
faqs: FaqItem[];
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
ctaTitle: string;
|
||||||
|
ctaDescription: string;
|
||||||
|
ctaButton: ButtonConfig;
|
||||||
|
ctaIcon: LucideIcon;
|
||||||
|
useInvertedBackground: InvertedBackground;
|
||||||
|
animationType: CardAnimationType;
|
||||||
|
accordionAnimationType?: "smooth" | "instant";
|
||||||
|
showCard?: boolean;
|
||||||
|
ariaLabel?: string;
|
||||||
|
className?: 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 animationOptions: UseCardAnimationOptions = {
|
const ContactFaq = ({
|
||||||
containerRef,
|
faqs,
|
||||||
itemRefs,
|
ctaTitle,
|
||||||
|
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) => {
|
||||||
|
setActiveIndex(activeIndex === index ? null : index);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
const getButtonConfigProps = () => {
|
||||||
|
if (theme.defaultButtonVariant === "hover-bubble") {
|
||||||
|
return { bgClassName: "w-full" };
|
||||||
|
}
|
||||||
|
if (theme.defaultButtonVariant === "icon-arrow") {
|
||||||
|
return { className: "justify-between" };
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{faqs.map((faq) => (
|
aria-label={ariaLabel}
|
||||||
<div key={faq.id} className="faq-item">
|
className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}
|
||||||
<h3>{faq.title}</h3>
|
>
|
||||||
<p>{faq.content}</p>
|
<div className={cls("w-content-width mx-auto", containerClassName)}>
|
||||||
|
<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>
|
||||||
</div>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ContactFaq.displayName = "ContactFaq";
|
||||||
|
|
||||||
export default ContactFaq;
|
export default ContactFaq;
|
||||||
|
|||||||
@@ -1,104 +1,171 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
import ContactForm from "@/components/form/ContactForm";
|
||||||
import { Mail, Phone, MapPin } from 'lucide-react';
|
import MediaContent from "@/components/shared/MediaContent";
|
||||||
|
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";
|
||||||
|
|
||||||
interface ContactFormData {
|
type ContactSplitBackgroundProps = Extract<
|
||||||
name: string;
|
HeroBackgroundVariantProps,
|
||||||
email: string;
|
| { variant: "plain" }
|
||||||
message: string;
|
| { variant: "animated-grid" }
|
||||||
|
| { 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ContactSplit: React.FC = () => {
|
const ContactSplit = ({
|
||||||
const [formData, setFormData] = useState<ContactFormData>({
|
title,
|
||||||
name: '',
|
description,
|
||||||
email: '',
|
tag,
|
||||||
message: '',
|
tagIcon,
|
||||||
});
|
tagAnimation,
|
||||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
background,
|
||||||
|
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 handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
const handleSubmit = async (email: string) => {
|
||||||
const { name, value } = e.target;
|
try {
|
||||||
setFormData(prev => ({ ...prev, [name]: value }));
|
await sendContactEmail({ email });
|
||||||
};
|
console.log("Email send successfully");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to send email:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const contactContent = (
|
||||||
e.preventDefault();
|
<div className="relative card rounded-theme-capped p-6 py-15 md:py-6 flex items-center justify-center">
|
||||||
setIsSubmitted(true);
|
<ContactForm
|
||||||
setFormData({ name: '', email: '', message: '' });
|
tag={tag}
|
||||||
setTimeout(() => setIsSubmitted(false), 3000);
|
tagIcon={tagIcon}
|
||||||
};
|
tagAnimation={tagAnimation}
|
||||||
|
title={title}
|
||||||
return (
|
description={description}
|
||||||
<div className="max-w-6xl mx-auto px-4 py-16">
|
useInvertedBackground={useInvertedBackground}
|
||||||
<div className="grid md:grid-cols-2 gap-12 items-center">
|
inputPlaceholder={inputPlaceholder}
|
||||||
<div className="space-y-8">
|
buttonText={buttonText}
|
||||||
<div>
|
termsText={termsText}
|
||||||
<h2 className="text-4xl font-bold mb-4">Get in Touch</h2>
|
onSubmit={handleSubmit}
|
||||||
<p className="text-lg text-gray-600">We're here to help and answer any questions you might have.</p>
|
centered={true}
|
||||||
</div>
|
className={cls("w-full", contactFormClassName)}
|
||||||
|
tagClassName={tagClassName}
|
||||||
<div className="space-y-6">
|
titleClassName={titleClassName}
|
||||||
<div className="flex items-start gap-4">
|
descriptionClassName={descriptionClassName}
|
||||||
<Mail className="w-6 h-6 mt-1 text-primary" />
|
formWrapperClassName={cls("w-full md:w-8/10 2xl:w-7/10", formWrapperClassName)}
|
||||||
<div>
|
formClassName={formClassName}
|
||||||
<h3 className="font-semibold mb-1">Email</h3>
|
inputClassName={inputClassName}
|
||||||
<p className="text-gray-600">hello@company.com</p>
|
buttonClassName={buttonClassName}
|
||||||
</div>
|
buttonTextClassName={buttonTextClassName}
|
||||||
|
termsClassName={termsClassName}
|
||||||
|
/>
|
||||||
|
<div className="absolute inset w-full h-full z-0 rounded-theme-capped overflow-hidden" >
|
||||||
|
<HeroBackgrounds {...background} />
|
||||||
</div>
|
</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>
|
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
<form onSubmit={handleFormSubmit} className="space-y-4">
|
const mediaContent = (
|
||||||
<input
|
<div ref={mediaContainerRef} className={cls("overflow-hidden rounded-theme-capped card h-130", mediaWrapperClassName)}>
|
||||||
type="text"
|
<MediaContent
|
||||||
name="name"
|
imageSrc={imageSrc}
|
||||||
placeholder="Your Name"
|
videoSrc={videoSrc}
|
||||||
value={formData.name}
|
imageAlt={imageAlt}
|
||||||
onChange={handleChange}
|
videoAriaLabel={videoAriaLabel}
|
||||||
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
|
imageClassName={cls("relative z-1 w-full h-full object-cover", mediaClassName)}
|
||||||
required
|
/>
|
||||||
/>
|
</div>
|
||||||
<input
|
);
|
||||||
type="email"
|
|
||||||
name="email"
|
return (
|
||||||
placeholder="Your Email"
|
<section aria-label={ariaLabel} className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}>
|
||||||
value={formData.email}
|
<div className={cls("w-content-width mx-auto relative z-10", containerClassName)}>
|
||||||
onChange={handleChange}
|
<div className={cls("grid grid-cols-1 md:grid-cols-2 gap-6 md:auto-rows-fr", contentClassName)}>
|
||||||
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
|
{mediaPosition === "left" && mediaContent}
|
||||||
required
|
{contactContent}
|
||||||
/>
|
{mediaPosition === "right" && mediaContent}
|
||||||
<textarea
|
</div>
|
||||||
name="message"
|
</div>
|
||||||
placeholder="Your Message"
|
</section>
|
||||||
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;
|
||||||
|
|||||||
@@ -1,110 +1,214 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
import { useState } from "react";
|
||||||
import { Mail, Phone } from 'lucide-react';
|
import TextAnimation from "@/components/text/TextAnimation";
|
||||||
|
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";
|
||||||
|
|
||||||
interface ContactFormData {
|
export interface InputField {
|
||||||
name: string;
|
name: string;
|
||||||
email: string;
|
type: string;
|
||||||
subject: string;
|
placeholder: string;
|
||||||
message: string;
|
required?: boolean;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ContactSplitForm: React.FC = () => {
|
export interface TextareaField {
|
||||||
const [formData, setFormData] = useState<ContactFormData>({
|
name: string;
|
||||||
name: '',
|
placeholder: string;
|
||||||
email: '',
|
rows?: number;
|
||||||
subject: '',
|
required?: boolean;
|
||||||
message: '',
|
className?: string;
|
||||||
});
|
}
|
||||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
interface ContactSplitFormProps {
|
||||||
const { name, value } = e.target;
|
title: string;
|
||||||
setFormData(prev => ({ ...prev, [name]: value }));
|
description: string;
|
||||||
};
|
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 handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const ContactSplitForm = ({
|
||||||
e.preventDefault();
|
title,
|
||||||
setIsSubmitted(true);
|
description,
|
||||||
setFormData({ name: '', email: '', subject: '', message: '' });
|
inputs,
|
||||||
setTimeout(() => setIsSubmitted(false), 3000);
|
textarea,
|
||||||
};
|
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 });
|
||||||
|
|
||||||
return (
|
// Validate minimum inputs requirement
|
||||||
<div className="max-w-6xl mx-auto px-4 py-16">
|
if (inputs.length < 2) {
|
||||||
<div className="grid md:grid-cols-2 gap-12">
|
throw new Error("ContactSplitForm requires at least 2 inputs");
|
||||||
<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>
|
|
||||||
|
|
||||||
<div className="bg-gray-50 rounded-lg p-6 space-y-6">
|
// Initialize form data dynamically
|
||||||
<div className="flex items-start gap-4">
|
const initialFormData: Record<string, string> = {};
|
||||||
<Mail className="w-6 h-6 mt-1 text-primary" />
|
inputs.forEach(input => {
|
||||||
<div>
|
initialFormData[input.name] = "";
|
||||||
<h3 className="font-semibold mb-1">Email</h3>
|
});
|
||||||
<p className="text-gray-600">hello@company.com</p>
|
if (textarea) {
|
||||||
<p className="text-sm text-gray-500">We'll respond within 24 hours</p>
|
initialFormData[textarea.name] = "";
|
||||||
</div>
|
}
|
||||||
</div>
|
|
||||||
<div className="flex items-start gap-4">
|
const [formData, setFormData] = useState(initialFormData);
|
||||||
<Phone className="w-6 h-6 mt-1 text-primary" />
|
|
||||||
<div>
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
<h3 className="font-semibold mb-1">Phone</h3>
|
e.preventDefault();
|
||||||
<p className="text-gray-600">+1 (555) 123-4567</p>
|
try {
|
||||||
<p className="text-sm text-gray-500">Mon-Fri, 9am-6pm EST</p>
|
await sendContactEmail({ formData });
|
||||||
</div>
|
console.log("Email send successfully");
|
||||||
</div>
|
setFormData(initialFormData);
|
||||||
</div>
|
} 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>
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
<form onSubmit={handleFormSubmit} className="space-y-4">
|
const mediaContent = (
|
||||||
<input
|
<div ref={mediaContainerRef} className={cls("overflow-hidden rounded-theme-capped card md:relative md:h-full", mediaWrapperClassName)}>
|
||||||
type="text"
|
<MediaContent
|
||||||
name="name"
|
imageSrc={imageSrc}
|
||||||
placeholder="Full Name"
|
videoSrc={videoSrc}
|
||||||
value={formData.name}
|
imageAlt={imageAlt}
|
||||||
onChange={handleChange}
|
videoAriaLabel={videoAriaLabel}
|
||||||
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
|
imageClassName={cls("w-full md:absolute md:inset-0 md:h-full object-cover", mediaClassName)}
|
||||||
required
|
/>
|
||||||
/>
|
</div>
|
||||||
<input
|
);
|
||||||
type="email"
|
|
||||||
name="email"
|
return (
|
||||||
placeholder="Email Address"
|
<section aria-label={ariaLabel} className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}>
|
||||||
value={formData.email}
|
<div className={cls("w-content-width mx-auto", containerClassName)}>
|
||||||
onChange={handleChange}
|
<div className={cls("grid grid-cols-1 md:grid-cols-2 gap-6 md:auto-rows-fr", contentClassName)}>
|
||||||
className="w-full px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary"
|
{mediaPosition === "left" && mediaContent}
|
||||||
required
|
{formContent}
|
||||||
/>
|
{mediaPosition === "right" && mediaContent}
|
||||||
<input
|
</div>
|
||||||
type="text"
|
</div>
|
||||||
name="subject"
|
</section>
|
||||||
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;
|
||||||
|
|||||||
@@ -1,34 +1,167 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
interface FeatureCardSixteenProps {
|
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
|
||||||
features: Array<{ id: string; title: string; description: string }>;
|
import PricingFeatureList from "@/components/shared/PricingFeatureList";
|
||||||
containerClassName?: string;
|
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";
|
||||||
|
|
||||||
export const FeatureCardSixteen: React.FC<FeatureCardSixteenProps> = ({ features, containerClassName = '' }) => {
|
type ComparisonItem = {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
items: string[];
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
|
||||||
const perspectiveRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
|
||||||
containerRef,
|
|
||||||
itemRefs,
|
|
||||||
perspectiveRef,
|
|
||||||
};
|
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref={containerRef} className={containerClassName}>
|
|
||||||
{features.map((feature) => (
|
|
||||||
<div key={feature.id} className="feature-item">
|
|
||||||
<h3>{feature.title}</h3>
|
|
||||||
<p>{feature.description}</p>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FeatureCardSixteen;
|
interface FeatureCardSixteenProps {
|
||||||
|
negativeCard: ComparisonItem;
|
||||||
|
positiveCard: ComparisonItem;
|
||||||
|
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 = ({
|
||||||
|
negativeCard,
|
||||||
|
positiveCard,
|
||||||
|
animationType,
|
||||||
|
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 = [
|
||||||
|
{ ...negativeCard, variant: "negative" as const },
|
||||||
|
{ ...positiveCard, variant: "positive" as const },
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<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
|
||||||
|
ref={perspectiveRef}
|
||||||
|
className={cls(
|
||||||
|
"relative mx-auto w-full md:w-60 grid grid-cols-1 gap-6",
|
||||||
|
cards.length >= 2 ? "md:grid-cols-2" : "md:grid-cols-1",
|
||||||
|
gridClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{cards.map((card, index) => (
|
||||||
|
<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;
|
||||||
@@ -1,32 +1,274 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
interface MetricCardElevenProps {
|
import { memo } from "react";
|
||||||
metrics: Array<{ id: string; value: string; title: string }>;
|
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
|
||||||
containerClassName?: string;
|
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";
|
||||||
|
|
||||||
export const MetricCardEleven: React.FC<MetricCardElevenProps> = ({ metrics, containerClassName = '' }) => {
|
type MediaProps =
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
| {
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
imageSrc: string;
|
||||||
|
imageAlt?: string;
|
||||||
|
videoSrc?: never;
|
||||||
|
videoAriaLabel?: never;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
videoSrc: string;
|
||||||
|
videoAriaLabel?: string;
|
||||||
|
imageSrc?: never;
|
||||||
|
imageAlt?: never;
|
||||||
|
};
|
||||||
|
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
type Metric = MediaProps & {
|
||||||
containerRef,
|
id: string;
|
||||||
itemRefs,
|
value: string;
|
||||||
};
|
title: string;
|
||||||
|
description: string;
|
||||||
const { } = useCardAnimation(animationOptions);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref={containerRef} className={containerClassName}>
|
|
||||||
{metrics.map((metric) => (
|
|
||||||
<div key={metric.id} className="metric-item">
|
|
||||||
<div className="value">{metric.value}</div>
|
|
||||||
<div className="title">{metric.title}</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MetricCardEleven;
|
interface MetricCardElevenProps {
|
||||||
|
metrics: Metric[];
|
||||||
|
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;
|
||||||
|
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 {
|
||||||
|
metric: Metric;
|
||||||
|
shouldUseLightText: boolean;
|
||||||
|
cardClassName?: string;
|
||||||
|
valueClassName?: string;
|
||||||
|
cardTitleClassName?: string;
|
||||||
|
cardDescriptionClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MetricMediaCardProps {
|
||||||
|
metric: Metric;
|
||||||
|
mediaCardClassName?: string;
|
||||||
|
mediaClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MetricTextCard = memo(({
|
||||||
|
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">
|
||||||
|
<p className={cls(
|
||||||
|
"text-xl md:text-2xl font-medium leading-tight truncate",
|
||||||
|
shouldUseLightText ? "text-background" : "text-foreground",
|
||||||
|
cardTitleClassName
|
||||||
|
)}>
|
||||||
|
{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>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
@@ -1,57 +1,248 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React from 'react';
|
import { memo } from "react";
|
||||||
import { Check } from 'lucide-react';
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
|
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";
|
||||||
|
|
||||||
interface PricingPlan {
|
type PricingPlan = {
|
||||||
id: string;
|
id: string;
|
||||||
badge: string;
|
badge: string;
|
||||||
price: string;
|
badgeIcon?: LucideIcon;
|
||||||
subtitle: string;
|
price: string;
|
||||||
features: string[];
|
subtitle: string;
|
||||||
buttons?: Array<{ text: string; href?: string; onClick?: () => void }>;
|
buttons: ButtonConfig[];
|
||||||
}
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PricingCardEight: React.FC<PricingCardEightProps> = ({ plans }) => {
|
interface PricingCardItemProps {
|
||||||
return (
|
plan: PricingPlan;
|
||||||
<div className="max-w-6xl mx-auto px-4 py-16">
|
shouldUseLightText: boolean;
|
||||||
<div className="grid md:grid-cols-3 gap-8">
|
cardClassName?: string;
|
||||||
{plans.map((plan) => (
|
badgeClassName?: string;
|
||||||
<div
|
priceClassName?: string;
|
||||||
key={plan.id}
|
subtitleClassName?: string;
|
||||||
className="rounded-lg border border-gray-200 overflow-hidden hover:shadow-lg transition"
|
planButtonContainerClassName?: string;
|
||||||
>
|
planButtonClassName?: string;
|
||||||
<div className="bg-secondary-button p-6 space-y-4">
|
featuresClassName?: string;
|
||||||
<div className="text-sm font-semibold text-primary">{plan.badge}</div>
|
featureItemClassName?: string;
|
||||||
<div className="text-3xl font-bold">{plan.price}</div>
|
}
|
||||||
<div className="text-sm text-gray-600">{plan.subtitle}</div>
|
|
||||||
<div className="flex gap-2">
|
const PricingCardItem = memo(({
|
||||||
{plan.buttons?.map((button, idx) => (
|
plan,
|
||||||
<button
|
shouldUseLightText,
|
||||||
key={idx}
|
cardClassName = "",
|
||||||
onClick={button.onClick}
|
badgeClassName = "",
|
||||||
className="flex-1 px-4 py-2 bg-primary text-white rounded font-semibold hover:bg-primary/90 transition"
|
priceClassName = "",
|
||||||
>
|
subtitleClassName = "",
|
||||||
{button.text}
|
planButtonContainerClassName = "",
|
||||||
</button>
|
planButtonClassName = "",
|
||||||
))}
|
featuresClassName = "",
|
||||||
</div>
|
featureItemClassName = "",
|
||||||
</div>
|
}: PricingCardItemProps) => {
|
||||||
<div className="p-6 space-y-3">
|
const theme = useTheme();
|
||||||
{plan.features.map((feature, idx) => (
|
|
||||||
<div key={idx} className="flex items-start gap-3">
|
const getButtonConfigProps = () => {
|
||||||
<Check className="w-5 h-5 text-green-500 mt-0.5 flex-shrink-0" />
|
if (theme.defaultButtonVariant === "hover-bubble") {
|
||||||
<span className="text-sm text-gray-700">{feature}</span>
|
return { bgClassName: "w-full" };
|
||||||
|
}
|
||||||
|
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" >
|
||||||
</div>
|
<PricingFeatureList
|
||||||
</div>
|
features={plan.features}
|
||||||
);
|
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;
|
||||||
|
|||||||
@@ -1,33 +1,39 @@
|
|||||||
import React from 'react';
|
"use client";
|
||||||
|
|
||||||
interface Product {
|
import { memo, useCallback } from "react";
|
||||||
id: string;
|
import { useRouter } from "next/navigation";
|
||||||
name: string;
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
|
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?: Product[];
|
products?: ProductCard[];
|
||||||
carouselMode?: 'auto' | 'buttons';
|
carouselMode?: "auto" | "buttons";
|
||||||
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';
|
gridVariant: ProductCardFourGridVariant;
|
||||||
animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
|
|
||||||
uniformGridCustomHeightClasses?: string;
|
uniformGridCustomHeightClasses?: string;
|
||||||
|
animationType: CardAnimationType;
|
||||||
title: string;
|
title: string;
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
titleSegments?: TitleSegment[];
|
||||||
description: string;
|
description: string;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
tagIcon?: React.ComponentType<any>;
|
tagIcon?: LucideIcon;
|
||||||
tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
tagAnimation?: ButtonAnimationType;
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
buttons?: ButtonConfig[];
|
||||||
buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
buttonAnimation?: ButtonAnimationType;
|
||||||
textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
|
textboxLayout: TextboxLayout;
|
||||||
useInvertedBackground: boolean;
|
useInvertedBackground: InvertedBackground;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
containerClassName?: string;
|
containerClassName?: string;
|
||||||
@@ -39,6 +45,8 @@ 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;
|
||||||
@@ -49,8 +57,182 @@ interface ProductCardFourProps {
|
|||||||
textBoxButtonTextClassName?: string;
|
textBoxButtonTextClassName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProductCardFour: React.FC<ProductCardFourProps> = (props) => {
|
interface ProductCardItemProps {
|
||||||
return <div>ProductCardFour Component</div>;
|
product: ProductCard;
|
||||||
|
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;
|
||||||
|
|||||||
@@ -1,55 +1,226 @@
|
|||||||
import React from 'react';
|
"use client";
|
||||||
|
|
||||||
interface Product {
|
import { memo, useCallback } from "react";
|
||||||
id: string;
|
import { useRouter } from "next/navigation";
|
||||||
name: string;
|
import { ArrowUpRight } from "lucide-react";
|
||||||
price: string;
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
imageSrc: string;
|
import ProductImage from "@/components/shared/ProductImage";
|
||||||
imageAlt?: string;
|
import { cls, shouldUseInvertedText } from "@/lib/utils";
|
||||||
onFavorite?: () => void;
|
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
|
||||||
onProductClick?: () => void;
|
import { useProducts } from "@/hooks/useProducts";
|
||||||
isFavorited?: boolean;
|
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 ProductCardOneGridVariant = Exclude<GridVariant, "timeline">;
|
||||||
|
|
||||||
|
type ProductCard = Product;
|
||||||
|
|
||||||
interface ProductCardOneProps {
|
interface ProductCardOneProps {
|
||||||
products?: Product[];
|
products?: ProductCard[];
|
||||||
carouselMode?: 'auto' | 'buttons';
|
carouselMode?: "auto" | "buttons";
|
||||||
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';
|
gridVariant: ProductCardOneGridVariant;
|
||||||
animationType: 'none' | 'opacity' | 'slide-up' | 'scale-rotate' | 'blur-reveal';
|
uniformGridCustomHeightClasses?: string;
|
||||||
uniformGridCustomHeightClasses?: string;
|
animationType: CardAnimationType;
|
||||||
title: string;
|
title: string;
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
titleSegments?: TitleSegment[];
|
||||||
description: string;
|
description: string;
|
||||||
tag?: string;
|
tag?: string;
|
||||||
tagIcon?: React.ComponentType<any>;
|
tagIcon?: LucideIcon;
|
||||||
tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
tagAnimation?: ButtonAnimationType;
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
buttons?: ButtonConfig[];
|
||||||
buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
buttonAnimation?: ButtonAnimationType;
|
||||||
textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
|
textboxLayout: TextboxLayout;
|
||||||
useInvertedBackground: boolean;
|
useInvertedBackground: InvertedBackground;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProductCardOne: React.FC<ProductCardOneProps> = (props) => {
|
interface ProductCardItemProps {
|
||||||
return <div>ProductCardOne Component</div>;
|
product: ProductCard;
|
||||||
|
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;
|
||||||
|
|||||||
@@ -1,55 +1,283 @@
|
|||||||
import React from 'react';
|
"use client";
|
||||||
|
|
||||||
interface Product {
|
import { memo, useState, useCallback } from "react";
|
||||||
id: string;
|
import { useRouter } from "next/navigation";
|
||||||
name: string;
|
import { Plus, Minus } from "lucide-react";
|
||||||
price: string;
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
imageSrc: string;
|
import ProductImage from "@/components/shared/ProductImage";
|
||||||
imageAlt?: string;
|
import QuantityButton from "@/components/shared/QuantityButton";
|
||||||
onFavorite?: () => void;
|
import Button from "@/components/button/Button";
|
||||||
onProductClick?: () => void;
|
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
|
||||||
isFavorited?: boolean;
|
import { useProducts } from "@/hooks/useProducts";
|
||||||
}
|
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";
|
||||||
|
|
||||||
interface ProductCardThreeProps {
|
type ProductCardThreeGridVariant = Exclude<GridVariant, "timeline" | "items-top-row-full-width-bottom" | "full-width-top-items-bottom-row">;
|
||||||
products?: Product[];
|
|
||||||
carouselMode?: 'auto' | 'buttons';
|
|
||||||
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;
|
|
||||||
title: string;
|
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
|
||||||
description: string;
|
|
||||||
tag?: string;
|
|
||||||
tagIcon?: React.ComponentType<any>;
|
|
||||||
tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
|
||||||
buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
|
||||||
textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
|
|
||||||
useInvertedBackground: boolean;
|
|
||||||
ariaLabel?: string;
|
|
||||||
className?: string;
|
|
||||||
containerClassName?: string;
|
|
||||||
cardClassName?: string;
|
|
||||||
imageClassName?: string;
|
|
||||||
textBoxTitleClassName?: string;
|
|
||||||
textBoxTitleImageWrapperClassName?: string;
|
|
||||||
textBoxTitleImageClassName?: string;
|
|
||||||
textBoxDescriptionClassName?: string;
|
|
||||||
cardNameClassName?: string;
|
|
||||||
cardPriceClassName?: string;
|
|
||||||
gridClassName?: string;
|
|
||||||
carouselClassName?: string;
|
|
||||||
controlsClassName?: string;
|
|
||||||
textBoxClassName?: string;
|
|
||||||
textBoxTagClassName?: string;
|
|
||||||
textBoxButtonContainerClassName?: string;
|
|
||||||
textBoxButtonClassName?: string;
|
|
||||||
textBoxButtonTextClassName?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ProductCardThree: React.FC<ProductCardThreeProps> = (props) => {
|
type ProductCard = Product & {
|
||||||
return <div>ProductCardThree Component</div>;
|
onQuantityChange?: (quantity: number) => void;
|
||||||
|
initialQuantity?: number;
|
||||||
|
priceButtonProps?: Partial<ButtonPropsForVariant<CTAButtonVariant>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface ProductCardThreeProps {
|
||||||
|
products?: ProductCard[];
|
||||||
|
carouselMode?: "auto" | "buttons";
|
||||||
|
gridVariant: ProductCardThreeGridVariant;
|
||||||
|
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;
|
||||||
|
imageClassName?: string;
|
||||||
|
textBoxTitleClassName?: string;
|
||||||
|
textBoxTitleImageWrapperClassName?: string;
|
||||||
|
textBoxTitleImageClassName?: string;
|
||||||
|
textBoxDescriptionClassName?: string;
|
||||||
|
cardNameClassName?: string;
|
||||||
|
quantityControlsClassName?: string;
|
||||||
|
gridClassName?: string;
|
||||||
|
carouselClassName?: string;
|
||||||
|
controlsClassName?: string;
|
||||||
|
textBoxClassName?: string;
|
||||||
|
textBoxTagClassName?: string;
|
||||||
|
textBoxButtonContainerClassName?: string;
|
||||||
|
textBoxButtonClassName?: string;
|
||||||
|
textBoxButtonTextClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface ProductCardItemProps {
|
||||||
|
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;
|
||||||
|
|||||||
@@ -1,55 +1,267 @@
|
|||||||
import React from 'react';
|
"use client";
|
||||||
|
|
||||||
interface Product {
|
import { memo, useCallback } from "react";
|
||||||
id: string;
|
import { useRouter } from "next/navigation";
|
||||||
name: string;
|
import { Star } from "lucide-react";
|
||||||
price: string;
|
import CardStack from "@/components/cardStack/CardStack";
|
||||||
imageSrc: string;
|
import ProductImage from "@/components/shared/ProductImage";
|
||||||
imageAlt?: string;
|
import { cls, shouldUseInvertedText } from "@/lib/utils";
|
||||||
onFavorite?: () => void;
|
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
|
||||||
onProductClick?: () => void;
|
import { useProducts } from "@/hooks/useProducts";
|
||||||
isFavorited?: boolean;
|
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";
|
||||||
|
|
||||||
interface ProductCardTwoProps {
|
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">;
|
||||||
products?: Product[];
|
|
||||||
carouselMode?: 'auto' | 'buttons';
|
|
||||||
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;
|
|
||||||
title: string;
|
|
||||||
titleSegments?: Array<{ type: 'text'; content: string } | { type: 'image'; src: string; alt?: string }>;
|
|
||||||
description: string;
|
|
||||||
tag?: string;
|
|
||||||
tagIcon?: React.ComponentType<any>;
|
|
||||||
tagAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
|
||||||
buttonAnimation?: 'none' | 'opacity' | 'slide-up' | 'blur-reveal';
|
|
||||||
textboxLayout: 'default' | 'split' | 'split-actions' | 'split-description' | 'inline-image';
|
|
||||||
useInvertedBackground: boolean;
|
|
||||||
ariaLabel?: string;
|
|
||||||
className?: string;
|
|
||||||
containerClassName?: string;
|
|
||||||
cardClassName?: string;
|
|
||||||
imageClassName?: string;
|
|
||||||
textBoxTitleClassName?: string;
|
|
||||||
textBoxTitleImageWrapperClassName?: string;
|
|
||||||
textBoxTitleImageClassName?: string;
|
|
||||||
textBoxDescriptionClassName?: string;
|
|
||||||
cardNameClassName?: string;
|
|
||||||
cardPriceClassName?: string;
|
|
||||||
gridClassName?: string;
|
|
||||||
carouselClassName?: string;
|
|
||||||
controlsClassName?: string;
|
|
||||||
textBoxClassName?: string;
|
|
||||||
textBoxTagClassName?: string;
|
|
||||||
textBoxButtonContainerClassName?: string;
|
|
||||||
textBoxButtonClassName?: string;
|
|
||||||
textBoxButtonTextClassName?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ProductCardTwo: React.FC<ProductCardTwoProps> = (props) => {
|
type ProductCard = Product & {
|
||||||
return <div>ProductCardTwo Component</div>;
|
brand: string;
|
||||||
|
rating: number;
|
||||||
|
reviewCount: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface ProductCardTwoProps {
|
||||||
|
products?: ProductCard[];
|
||||||
|
carouselMode?: "auto" | "buttons";
|
||||||
|
gridVariant: ProductCardTwoGridVariant;
|
||||||
|
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;
|
||||||
|
imageClassName?: string;
|
||||||
|
textBoxTitleClassName?: string;
|
||||||
|
textBoxTitleImageWrapperClassName?: string;
|
||||||
|
textBoxTitleImageClassName?: string;
|
||||||
|
textBoxDescriptionClassName?: string;
|
||||||
|
cardBrandClassName?: string;
|
||||||
|
cardNameClassName?: string;
|
||||||
|
cardPriceClassName?: string;
|
||||||
|
cardRatingClassName?: string;
|
||||||
|
actionButtonClassName?: string;
|
||||||
|
gridClassName?: string;
|
||||||
|
carouselClassName?: string;
|
||||||
|
controlsClassName?: string;
|
||||||
|
textBoxClassName?: string;
|
||||||
|
textBoxTagClassName?: string;
|
||||||
|
textBoxButtonContainerClassName?: string;
|
||||||
|
textBoxButtonClassName?: string;
|
||||||
|
textBoxButtonTextClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProductCardItemProps {
|
||||||
|
product: ProductCard;
|
||||||
|
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;
|
||||||
|
|||||||
@@ -1,39 +1,148 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
interface TeamMember {
|
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
|
||||||
|
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;
|
||||||
image?: string;
|
imageSrc?: string;
|
||||||
}
|
videoSrc?: string;
|
||||||
|
imageAlt?: string;
|
||||||
|
videoAriaLabel?: string;
|
||||||
|
};
|
||||||
|
|
||||||
interface TeamCardFiveProps {
|
interface TeamCardFiveProps {
|
||||||
members: TeamMember[];
|
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;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TeamCardFive: React.FC<TeamCardFiveProps> = ({ members, containerClassName = '' }) => {
|
const TeamCardFive = ({
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
team,
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
animationType,
|
||||||
|
title,
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
titleSegments,
|
||||||
containerRef,
|
description,
|
||||||
itemRefs,
|
textboxLayout,
|
||||||
};
|
useInvertedBackground,
|
||||||
|
tag,
|
||||||
const { } = useCardAnimation(animationOptions);
|
tagIcon,
|
||||||
|
tagAnimation,
|
||||||
|
buttons,
|
||||||
|
buttonAnimation,
|
||||||
|
ariaLabel = "Team section",
|
||||||
|
className = "",
|
||||||
|
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 (
|
||||||
<div ref={containerRef} className={containerClassName}>
|
<section
|
||||||
{members.map((member) => (
|
aria-label={ariaLabel}
|
||||||
<div key={member.id} className="team-member">
|
className={cls("relative py-20 w-full", useInvertedBackground && "bg-foreground", className)}
|
||||||
<h3>{member.name}</h3>
|
>
|
||||||
<p>{member.role}</p>
|
<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={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>
|
||||||
</div>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TeamCardFive.displayName = "TeamCardFive";
|
||||||
|
|
||||||
export default TeamCardFive;
|
export default TeamCardFive;
|
||||||
|
|||||||
@@ -1,60 +1,331 @@
|
|||||||
import React, { useRef } from 'react';
|
"use client";
|
||||||
import { useCardAnimation, UseCardAnimationOptions } from '@/hooks/useCardAnimation';
|
|
||||||
|
|
||||||
export interface DashboardStat {
|
import React, { useState, useEffect } from "react";
|
||||||
label: string;
|
import { cls } from "@/lib/utils";
|
||||||
value: string | number;
|
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 {
|
export interface DashboardSidebarItem {
|
||||||
label: string;
|
icon: LucideIcon;
|
||||||
icon?: any;
|
active?: boolean;
|
||||||
active?: boolean;
|
}
|
||||||
|
|
||||||
|
export interface DashboardStat {
|
||||||
|
title: string;
|
||||||
|
titleMobile?: string;
|
||||||
|
values: [number, number, number];
|
||||||
|
valuePrefix?: string;
|
||||||
|
valueSuffix?: string;
|
||||||
|
valueFormat?: Omit<Intl.NumberFormatOptions, "notation"> & {
|
||||||
|
notation?: Exclude<Intl.NumberFormatOptions["notation"], "scientific" | "engineering">;
|
||||||
|
};
|
||||||
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DashboardListItem {
|
export interface DashboardListItem {
|
||||||
label: string;
|
icon: LucideIcon;
|
||||||
value?: string;
|
title: string;
|
||||||
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DashboardProps {
|
interface DashboardProps {
|
||||||
title?: string;
|
title: string;
|
||||||
stats?: DashboardStat[];
|
stats: [DashboardStat, DashboardStat, DashboardStat];
|
||||||
logoIcon?: any;
|
logoIcon: LucideIcon;
|
||||||
sidebarItems?: DashboardSidebarItem[];
|
sidebarItems: DashboardSidebarItem[];
|
||||||
searchPlaceholder?: string;
|
searchPlaceholder?: string;
|
||||||
buttons?: Array<{ text: string; onClick?: () => void; href?: string }>;
|
buttons: ButtonConfig[];
|
||||||
chartTitle?: string;
|
chartTitle?: string;
|
||||||
chartData?: Array<{ label: string; value: number }>;
|
chartData?: ChartDataItem[];
|
||||||
listItems?: DashboardListItem[];
|
listItems: DashboardListItem[];
|
||||||
containerClassName?: string;
|
listTitle?: string;
|
||||||
headerClassName?: string;
|
imageSrc: string;
|
||||||
statsClassName?: string;
|
videoSrc?: string;
|
||||||
sidebarClassName?: string;
|
imageAlt?: string;
|
||||||
contentClassName?: string;
|
videoAriaLabel?: string;
|
||||||
listClassName?: string;
|
className?: string;
|
||||||
|
containerClassName?: string;
|
||||||
|
sidebarClassName?: string;
|
||||||
|
statClassName?: string;
|
||||||
|
chartClassName?: string;
|
||||||
|
listClassName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Dashboard: React.FC<DashboardProps> = ({
|
const Dashboard = ({
|
||||||
title,
|
title,
|
||||||
containerClassName = '',
|
stats,
|
||||||
...props
|
logoIcon: LogoIcon,
|
||||||
}) => {
|
sidebarItems,
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
searchPlaceholder = "Search",
|
||||||
const itemRefs = useRef<(HTMLDivElement | null)[]>([]);
|
buttons,
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
const animationOptions: UseCardAnimationOptions = {
|
useEffect(() => {
|
||||||
containerRef,
|
const interval = setInterval(() => {
|
||||||
itemRefs,
|
setStatValueIndex((prev) => (prev + 1) % 3);
|
||||||
};
|
}, 3000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const { } = useCardAnimation(animationOptions);
|
const statCard = (stat: DashboardStat, index: number, withRef = false) => (
|
||||||
|
<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 ref={containerRef} className={containerClassName}>
|
<div
|
||||||
{title && <h1>{title}</h1>}
|
className={cls(
|
||||||
</div>
|
"w-content-width flex gap-5 p-5 rounded-theme-capped card shadow",
|
||||||
);
|
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>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Dashboard;
|
Dashboard.displayName = "Dashboard";
|
||||||
|
|
||||||
|
export default React.memo(Dashboard);
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
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 {};
|
|
||||||
};
|
|
||||||
@@ -1,64 +1,117 @@
|
|||||||
import { useState, useCallback } from 'react';
|
"use client";
|
||||||
|
|
||||||
export interface CheckoutItem {
|
import { useState } from "react";
|
||||||
id: string;
|
import { Product } from "@/lib/api/product";
|
||||||
name: string;
|
|
||||||
price: string;
|
|
||||||
quantity: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useCheckout = () => {
|
export type CheckoutItem = {
|
||||||
const [items, setItems] = useState<CheckoutItem[]>([]);
|
productId: string;
|
||||||
const [isProcessing, setIsProcessing] = useState(false);
|
quantity: number;
|
||||||
|
imageSrc?: string;
|
||||||
const addItem = useCallback((item: CheckoutItem) => {
|
imageAlt?: string;
|
||||||
setItems(prev => {
|
metadata?: {
|
||||||
const existing = prev.find(i => i.id === item.id);
|
brand?: string;
|
||||||
if (existing) {
|
variant?: string;
|
||||||
return prev.map(i => i.id === item.id ? { ...i, quantity: i.quantity + item.quantity } : i);
|
rating?: number;
|
||||||
}
|
reviewCount?: string;
|
||||||
return [...prev, item];
|
[key: string]: string | number | undefined;
|
||||||
});
|
};
|
||||||
}, []);
|
|
||||||
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,18 +1,45 @@
|
|||||||
export interface Product {
|
"use client";
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
price: string;
|
|
||||||
imageSrc: string;
|
|
||||||
imageAlt?: string;
|
|
||||||
onFavorite?: () => void;
|
|
||||||
onProductClick?: () => void;
|
|
||||||
isFavorited?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useProduct = (productId: string) => {
|
import { useEffect, useState } from "react";
|
||||||
return {
|
import { Product, fetchProduct } from "@/lib/api/product";
|
||||||
product: null,
|
|
||||||
loading: false,
|
export function useProduct(productId: string) {
|
||||||
error: null
|
const [product, setProduct] = useState<Product | null>(null);
|
||||||
};
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
};
|
const [error, setError] = useState<Error | null>(null);
|
||||||
|
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,39 +1,115 @@
|
|||||||
import { useState, useCallback } from 'react';
|
"use client";
|
||||||
|
|
||||||
export interface CatalogItem {
|
import { useState, useMemo, useCallback } from "react";
|
||||||
id: string;
|
import { useRouter } from "next/navigation";
|
||||||
name: string;
|
import { useProducts } from "./useProducts";
|
||||||
price: string;
|
import type { Product } from "@/lib/api/product";
|
||||||
imageSrc: string;
|
import type { CatalogProduct } from "@/components/ecommerce/productCatalog/ProductCatalogItem";
|
||||||
imageAlt?: string;
|
import type { ProductVariant } from "@/components/ecommerce/productDetail/ProductDetailCard";
|
||||||
category?: string;
|
|
||||||
|
export type SortOption = "Newest" | "Price: Low-High" | "Price: High-Low";
|
||||||
|
|
||||||
|
interface UseProductCatalogOptions {
|
||||||
|
basePath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useProductCatalog = () => {
|
export function useProductCatalog(options: UseProductCatalogOptions = {}) {
|
||||||
const [items, setItems] = useState<CatalogItem[]>([]);
|
const { basePath = "/shop" } = options;
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string | null>(null);
|
const router = useRouter();
|
||||||
|
const { products: fetchedProducts, isLoading } = useProducts();
|
||||||
|
|
||||||
const filteredItems = selectedCategory
|
const [search, setSearch] = useState("");
|
||||||
? items.filter(item => item.category === selectedCategory)
|
const [category, setCategory] = useState("All");
|
||||||
: items;
|
const [sort, setSort] = useState<SortOption>("Newest");
|
||||||
|
|
||||||
const loadCatalog = useCallback(async () => {
|
const handleProductClick = useCallback((productId: string) => {
|
||||||
try {
|
router.push(`${basePath}/${productId}`);
|
||||||
// Simulate API call
|
}, [router, basePath]);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return {
|
const catalogProducts: CatalogProduct[] = useMemo(() => {
|
||||||
items: filteredItems,
|
if (fetchedProducts.length === 0) return [];
|
||||||
loadCatalog,
|
|
||||||
selectedCategory,
|
return fetchedProducts.map((product) => ({
|
||||||
setSelectedCategory,
|
id: product.id,
|
||||||
};
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,42 +1,196 @@
|
|||||||
import { useState, useCallback, useEffect } from 'react';
|
"use client";
|
||||||
|
|
||||||
export interface ProductDetail {
|
import { useState, useMemo, useCallback } from "react";
|
||||||
id: string;
|
import { useProduct } from "./useProduct";
|
||||||
name: string;
|
import type { Product } from "@/lib/api/product";
|
||||||
price: string;
|
import type { ProductVariant } from "@/components/ecommerce/productDetail/ProductDetailCard";
|
||||||
description: string;
|
import type { ExtendedCartItem } from "./useCart";
|
||||||
imageSrc: string;
|
|
||||||
imageAlt?: string;
|
interface ProductImage {
|
||||||
specs?: Record<string, string>;
|
src: string;
|
||||||
|
alt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useProductDetail = (id: string) => {
|
interface ProductMeta {
|
||||||
const [product, setProduct] = useState<ProductDetail | null>(null);
|
salePrice?: string;
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
ribbon?: string;
|
||||||
const [error, setError] = useState<string | null>(null);
|
inventoryStatus?: string;
|
||||||
|
inventoryQuantity?: number;
|
||||||
|
sku?: string;
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
export function useProductDetail(productId: string) {
|
||||||
const loadProduct = async () => {
|
const { product, isLoading, error } = useProduct(productId);
|
||||||
setIsLoading(true);
|
const [selectedQuantity, setSelectedQuantity] = useState(1);
|
||||||
try {
|
const [selectedVariants, setSelectedVariants] = useState<Record<string, string>>({});
|
||||||
// Simulate API call
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
const images = useMemo<ProductImage[]>(() => {
|
||||||
setProduct({
|
if (!product) return [];
|
||||||
id,
|
|
||||||
name: 'Product',
|
if (product.images && product.images.length > 0) {
|
||||||
price: '$99',
|
return product.images.map((src, index) => ({
|
||||||
description: 'High quality product',
|
src,
|
||||||
imageSrc: '/placeholder.jpg',
|
alt: product.imageAlt || `${product.name} - Image ${index + 1}`,
|
||||||
});
|
}));
|
||||||
} catch (err) {
|
}
|
||||||
setError('Failed to load product');
|
return [{
|
||||||
} finally {
|
src: product.imageSrc,
|
||||||
setIsLoading(false);
|
alt: product.imageAlt || product.name,
|
||||||
}
|
}];
|
||||||
|
}, [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 };
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,18 +1,39 @@
|
|||||||
export interface Product {
|
"use client";
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
price: string;
|
|
||||||
imageSrc: string;
|
|
||||||
imageAlt?: string;
|
|
||||||
onFavorite?: () => void;
|
|
||||||
onProductClick?: () => void;
|
|
||||||
isFavorited?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useProducts = () => {
|
import { useEffect, useState } from "react";
|
||||||
return {
|
import { Product, fetchProducts } from "@/lib/api/product";
|
||||||
products: [],
|
|
||||||
loading: false,
|
export function useProducts() {
|
||||||
error: null
|
const [products, setProducts] = useState<Product[]>([]);
|
||||||
};
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
};
|
const [error, setError] = useState<Error | null>(null);
|
||||||
|
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,43 +1,219 @@
|
|||||||
export interface ProductResponse {
|
export type Product = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
price: number;
|
price: string;
|
||||||
description: string;
|
imageSrc: string;
|
||||||
imageSrc: string;
|
imageAlt?: string;
|
||||||
|
images?: string[];
|
||||||
|
brand?: string;
|
||||||
|
variant?: string;
|
||||||
|
rating?: number;
|
||||||
|
reviewCount?: string;
|
||||||
|
description?: string;
|
||||||
|
priceId?: string;
|
||||||
|
metadata?: {
|
||||||
|
[key: string]: string | number | undefined;
|
||||||
|
};
|
||||||
|
onFavorite?: () => void;
|
||||||
|
onProductClick?: () => void;
|
||||||
|
isFavorited?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const defaultProducts: Product[] = [
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
name: "Classic White Sneakers",
|
||||||
|
price: "$129",
|
||||||
|
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 const fetchProduct = async (id: string): Promise<ProductResponse> => {
|
export async function fetchProducts(): Promise<Product[]> {
|
||||||
try {
|
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
|
||||||
const response = await fetch(`/api/products/${id}`);
|
const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to fetch product');
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
} catch {
|
|
||||||
throw new Error('Failed to fetch product');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchProducts = async (): Promise<ProductResponse[]> => {
|
if (!apiUrl || !projectId) {
|
||||||
try {
|
return [];
|
||||||
const response = await fetch('/api/products');
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to fetch products');
|
|
||||||
}
|
}
|
||||||
return response.json();
|
|
||||||
} catch {
|
|
||||||
throw new Error('Failed to fetch products');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchProductsByCategory = async (category: string): Promise<ProductResponse[]> => {
|
try {
|
||||||
try {
|
const url = `${apiUrl}/stripe/project/products?projectId=${projectId}&expandDefaultPrice=true`;
|
||||||
const response = await fetch(`/api/products?category=${category}`);
|
const response = await fetch(url, {
|
||||||
if (!response.ok) {
|
method: "GET",
|
||||||
throw new Error('Failed to fetch products');
|
headers: {
|
||||||
|
"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 {
|
|
||||||
throw new Error('Failed to fetch products');
|
export async function fetchProduct(productId: string): Promise<Product | null> {
|
||||||
}
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user