import { Fragment } from 'react'; import clsx from 'clsx'; import { type EnrichedTweet, type EnrichedQuotedTweet, getMediaUrl, TwitterComponents, } from 'react-tweet'; import type { MediaDetails } from 'react-tweet/api'; import s from './tweet-media.module.css'; import { TweetMediaVideo } from './TweetMediaVideo'; const getSkeletonStyle = (media: MediaDetails, itemCount: number) => { let paddingBottom = 56.25; // default of 16x9 // if we only have 1 item, show at original ratio if (itemCount === 1) paddingBottom = (100 / media.original_info.width) * media.original_info.height; // if we have 2 items, double the default to be 16x9 total if (itemCount === 2) paddingBottom = paddingBottom * 2; return { width: media.type === 'photo' ? undefined : 'unset', paddingBottom: `${paddingBottom}%`, }; }; type Props = { tweet: EnrichedTweet | EnrichedQuotedTweet; components?: TwitterComponents; quoted?: boolean; }; export const TweetMedia = ({ tweet, components, quoted }: Props) => { const length = tweet.mediaDetails?.length ?? 0; const Img = components?.MediaImg ?? MediaImg; return (