Files
8a31beaf-fcc0-428a-93b9-d55…/src/components/sections/about/SplitAbout.tsx
vitalijmulika a829c2a578 Initial commit
2025-12-22 13:17:13 +02:00

179 lines
6.0 KiB
TypeScript

"use client";
import { memo, Fragment } from "react";
import CardStackTextBox from "@/components/cardStack/CardStackTextBox";
import MediaContent from "@/components/shared/MediaContent";
import { cls, shouldUseInvertedText } from "@/lib/utils";
import { useTheme } from "@/providers/themeProvider/ThemeProvider";
import type { LucideIcon } from "lucide-react";
import type { ButtonConfig } from "@/types/button";
import type { TitleSegment } from "@/components/cardStack/types";
import type { TextboxLayout, InvertedBackground } from "@/providers/themeProvider/config/constants";
interface BulletPoint {
title: string;
description: string;
icon?: LucideIcon;
}
interface SplitAboutProps {
title: string;
titleSegments?: TitleSegment[];
description: string;
tag?: string;
tagIcon?: LucideIcon;
buttons?: ButtonConfig[];
bulletPoints: BulletPoint[];
imageSrc?: string;
videoSrc?: string;
imageAlt?: string;
videoAriaLabel?: string;
ariaLabel?: string;
imagePosition?: "left" | "right";
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;
contentClassName?: string;
bulletPointClassName?: string;
bulletTitleClassName?: string;
bulletDescriptionClassName?: string;
mediaWrapperClassName?: string;
imageClassName?: string;
}
const SplitAbout = ({
title,
titleSegments,
description,
tag,
tagIcon,
buttons,
bulletPoints,
imageSrc,
videoSrc,
imageAlt = "",
videoAriaLabel = "About section video",
ariaLabel = "About section",
imagePosition = "right",
textboxLayout,
useInvertedBackground,
className = "",
containerClassName = "",
textBoxClassName = "",
titleClassName = "",
titleImageWrapperClassName = "",
titleImageClassName = "",
descriptionClassName = "",
tagClassName = "",
buttonContainerClassName = "",
buttonClassName = "",
buttonTextClassName = "",
contentClassName = "",
bulletPointClassName = "",
bulletTitleClassName = "",
bulletDescriptionClassName = "",
mediaWrapperClassName = "",
imageClassName = "",
}: SplitAboutProps) => {
const theme = useTheme();
const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle);
const mediaContent = (
<div className={cls("w-full md:w-6/10 2xl:w-7/10 overflow-hidden rounded-theme-capped card md:relative p-4", mediaWrapperClassName)}>
<div className="md:relative w-full md:h-full">
<MediaContent
imageSrc={imageSrc}
videoSrc={videoSrc}
imageAlt={imageAlt}
videoAriaLabel={videoAriaLabel}
imageClassName={cls("z-1 w-full h-auto object-cover rounded-theme-capped md:absolute md:inset-0 md:h-full", imageClassName)}
/>
</div>
</div>
);
return (
<section
aria-label={ariaLabel}
className={cls(
"relative py-20",
useInvertedBackground === "invertCard"
? "w-content-width-expanded mx-auto rounded-theme-capped bg-foreground"
: "w-full",
useInvertedBackground === "invertDefault" && "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}
buttons={buttons}
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("flex flex-col md:flex-row gap-6 md:items-stretch")}>
{imagePosition === "left" && mediaContent}
<div className={cls("w-full md:w-4/10 2xl:w-3/10 rounded-theme-capped card p-6 flex flex-col gap-6 justify-center", contentClassName)}>
{bulletPoints.map((point, index) => {
const Icon = point.icon;
return (
<Fragment key={index}>
<div className={cls("relative z-1 flex flex-col gap-2", bulletPointClassName)}>
{Icon && (
<div className="h-10 w-fit aspect-square rounded-theme primary-button flex items-center justify-center flex-shrink-0 mb-1">
<Icon className="h-[40%] w-[40%] text-background" strokeWidth={1.5} />
</div>
)}
<div className="flex flex-col gap-0">
<h3 className={cls("text-xl font-medium", shouldUseLightText && "text-background", bulletTitleClassName)}>
{point.title}
</h3>
<p className={cls("text-base leading-[1.4]", shouldUseLightText ? "text-background" : "text-foreground", bulletDescriptionClassName)}>
{point.description}
</p>
</div>
</div>
{index < bulletPoints.length - 1 && (
<div className="relative z-1 w-full border-b border-accent/10" />
)}
</Fragment>
);
})}
</div>
{imagePosition === "right" && mediaContent}
</div>
</div>
</section>
);
};
SplitAbout.displayName = "SplitAbout";
export default memo(SplitAbout);