import cx from "classnames"; import React from "react"; import { Grid, GridCol } from "../Grid"; import { Image } from "../Image"; interface PromoBannerImageSrc { src: string; srcSet?: string; } interface PromoBannerProps { className?: string; image?: string | PromoBannerImageSrc; alignImage?: "bottom" | "top"; /** Remove top padding from item on sm and smaller breakpoints */ flushTopSmDown?: boolean; /** Remove bottom padding from item on sm and smaller breakpoints */ flushBottomSmDown?: boolean; imageFullWidth?: boolean; /** Make image extend to the edge of viewport even when inside container */ bleedImage?: boolean; /** Make image extend to Container boundaries on sm and smaller breakpoints */ bleedImageSmDown?: boolean; children?: React.ReactNode; itemClassName?: string; imageClassName?: string; variant?: "vertical" | "reverse"; } const CLASS_ROOT = "promo-banner"; const getImageProps = (image?: string | PromoBannerImageSrc) => { if (!image) return null; return typeof image === "string" ? { src: image } : { src: image.src, srcSet: image.srcSet }; }; export const PromoBanner = ({ image, className, alignImage, flushTopSmDown, flushBottomSmDown, bleedImage, bleedImageSmDown, children, itemClassName, imageClassName, variant, imageFullWidth, ...other }: PromoBannerProps) => { const imageProps = getImageProps(image); const classes = cx(CLASS_ROOT, className, { [`${CLASS_ROOT}--flush-top-sm-down`]: flushTopSmDown, [`${CLASS_ROOT}--flush-bottom-sm-down`]: flushBottomSmDown, [`${CLASS_ROOT}--reverse`]: variant === "reverse" && !!imageProps?.src, [`${CLASS_ROOT}--vertical`]: variant === "vertical", }); return (