import React from "react"; import { ResultCardProps } from "../../models/components"; import "./ResultCard.scss"; import Button from "../button/Button"; import clsx from "clsx"; const ResultCard: React.FC = ({ title, body, category, date, tags = [], image, href, rtl, actionButtons = [], dimmed, score, type, lazyLoad = false, }) => { if (!title || !href) return null; const hasActionButtons = Array.isArray(actionButtons) && actionButtons.length > 0; const hasTags = Array.isArray(tags) && tags.length > 0; return (
{hasActionButtons && (
{actionButtons.map((button, index) => (
{score && (
{score}
)}
)}
{" "} {category &&
{category}
} {type && ( <> {category && }
{type}
)}
{title} {(date || body) && (
{date && {date}} {date && body && ( )} {body && {body}}
)} {hasTags && (
{tags.slice(0, 4).map( (tag, index) => tag.label && tag.href && ( {tag.label} {index < 3 && index < tags.slice(0, 4).length - 1 && ( )} ) )}
)}
{image && ( )}
); }; export default ResultCard;