import { useCallback } from 'react'; import tw from '../../../tw'; import BlockTitle from '../../Internal/BlockTitle'; import { CardProps, CardSquare } from '../types'; import useLocalizedText from '../../../useLocalizedText'; import CarouselNavigation from '../CarouselNavigation'; import ActionOrLink from '../../ActionOrLink'; import Truncated from '../Truncated'; import { RichText } from '../../RichText'; interface SquareProps extends CardProps {} const Square = ({ title, styles, cards, container, canScroll, scroll, className = '', }: SquareProps) => { const { localize } = useLocalizedText(); const getCoverStyle = useCallback( (index: number) => { const { cover } = cards[index] || {}; return { background: `linear-gradient(rgba(81, 81, 81, 0), rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), ${ cover ? `url("${cover}")` : 'rgb(140, 140, 140)' }`, }; }, [cards] ); return (
{title && }
{(cards as CardSquare[]).map( ({ title, description, action }, index) => (
{(truncatedText) => truncatedText} {(truncatedText) => ( {truncatedText || ''} )}
) )}
); }; export default Square;