/** @jsxRuntime classic */ /** @jsx jsx */ import { Box, jsx, useContainerSize } from "@front10/base-elements"; import * as React from "react"; import { ImageData } from "../CardProps"; import { imagePlaceholder } from "../_commons/atoms/placeholder"; import { openLightbox } from "@front10/utils"; interface Props { images: ImageData[]; } export interface ImageProps extends ImageData { width: number; height: number; placeholder?: boolean; onClick?: () => void; } export function TwitterImage({ image, width, altText, height, placeholder = true, onClick, }: ImageProps) { if (width === 0) { return null; } let url = image; const isFromTwitterCDN = url.includes("pbs.twimg.com"); if (isFromTwitterCDN) { url = url.replace("http://", "https://"); } const webpUrl = `${url}?format=webp`; return ( {altText ); } export function TwitterImages(props: Props) { const ref = React.useRef(null); const width = useContainerSize(ref); // Twitter recommends a 16:9 aspect ratio for tweet images const height = width * 0.5625; const count = props.images.length; const cols = count > 1 ? 2 : 1; const gap = width <= 768 ? 2 : 4; const cardHeight = count > 2 ? height / 2 - gap : height; return ( :first-child": { gridRow: "1 / span 2" } }), }} > {props.images.map((image, index) => { return ( openLightbox(index, props.images, "twitter")} /> ); })} ); }