import React, { type ReactNode } from "react"; import classNames from "classnames"; import { isDate, format } from "date-fns"; import { filterAttrs } from "@arc-ui/community-utils/filter-attrs"; import { ArcSizeBreakpointsM } from "@arc-ui/tokens-arc"; import { AppButton } from "@arc-ui/components/AppButton"; import { Grid, GridRow, GridCol } from "@arc-ui/components/Grid"; import { ButtonV2 } from "@arc-ui/components/ButtonV2"; import { Heading, type HeadingLevel } from "@arc-ui/components/Heading"; import { Text } from "@arc-ui/components/Text"; import { VerticalSpace } from "@arc-ui/components/VerticalSpace"; import { useMediaQuery } from "@arc-ui/components/use-media-query"; import { type VideoPlayerProps } from "@arc-ui/components/VideoPlayer"; import { Author } from "../Author"; import { type FeaturePostAppButtonFooter, type FeaturePostCtaFooter, type FeaturePostImage, } from "./types"; import styles from "./FeaturePost.module.css"; import { MediaContent } from "./components/MediaContent/MediaContent"; /** * Use `FeaturePost` to direct traffic towards an article, case study, or product information page, or to a 3rd part App Store provider. Where the component links to an article page, the author attribution can be given here. The `FeaturePost` must be supported by an image, and in future, the component will support embedded video as well. * */ export const FeaturePost: React.FC = ({ heading, id, headingLevel = "2", label, image, content, footer, video, isHeadingWordWrap, isReverseOrder = false, ...props }) => { const isMinWidthArcBreakpointM = useMediaQuery( `(min-width: ${ArcSizeBreakpointsM})`, ); return (
{label && ( {label.text}
{isDate(label.date) ? ( ) : ( {label.date as string} )}
)} {heading} {!isMinWidthArcBreakpointM && (
)} {typeof content === "string" ? ( {content} ) : ( content )} {footer?.type === "cta" && ( <> {footer.author && ( <> )} )} {footer?.type === "appButton" && ( <> {footer.appStore && ( )} {footer.googlePlay && (
)}
)}
{isMinWidthArcBreakpointM && (
)}
); }; export interface FeaturePostProps { /** * heading for `FeaturePost`. */ heading: string; /** * id for `FeaturePost`. */ id?: string; /** * Determine a heading level for `` */ headingLevel?: HeadingLevel; /** * Word wrap behavior for the heading */ isHeadingWordWrap?: boolean; /** * Text content for `FeaturePost`. */ content: ReactNode; /** * Reverse the columns so the image / video appears on the left. Doesn't affect mobile layouts, and is only applied if there is a video or an image. */ isReverseOrder?: boolean; /** * Image for `FeaturePost`. */ image?: FeaturePostImage; /** * Footer for `FeaturePost`. Types included are `cta` or `appButton`. */ footer?: FeaturePostCtaFooter | FeaturePostAppButtonFooter; /** * Label for `FeaturePost`. */ label?: { text: string; date: string | Date; }; /** * Video embed. Supported platforms are YouTube and Vimeo. */ video?: VideoPlayerProps; }