import { ContentCardProps } from "@app/models/components"; import React, { useEffect, useState } from "react"; import Button from "../button/Button"; import "./content-card-styles.scss"; import InfoBadge from "../InfoBadge/InfoBadge"; const ContentCard: React.FC = ({ title, description, meta, imageSrc, imageAlign, tags, actionButtons, maxWidth, overlayContent, hoverEffect = true, onHoverContent, stickContent = false, }) => { const [isHovering, setIsHovering] = useState(false); useEffect(() => { if (stickContent) { setIsHovering(true); } else { setIsHovering(false); } }, [stickContent]); const contentClass = isHovering ? "contentCard-content--expanded" : ""; const hasContent = title || description || meta || !!actionButtons?.length; const handleMouseEnter = () => { if (!hoverEffect) return; setIsHovering(true); }; const handleMouseLeave = () => { if (!hoverEffect || stickContent) return; setIsHovering(false); }; return ( <> {imageSrc && (
{overlayContent && (
{overlayContent}
)}
{isHovering &&
}
{hasContent && (
{onHoverContent ?? ( <> {title &&

{title}

} {description && (

{description}

)} {meta &&

{meta}

} )} {!!actionButtons?.length && (
{actionButtons.map((buttonProps, index) => (
)}
)}
{tags && tags.map( (badge, index) => badge && (badge.icon || badge.text) && (
) )}
)} ); }; export default ContentCard;