From 4167a1de05f55bb472bc67a2627d8dda0a2ef7cd Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 31 Jan 2023 13:34:29 -0600 Subject: [PATCH] Break out MediaItemThumbnail into a separate component --- app/soapbox/components/media-gallery.tsx | 47 ++++++++++++++++-------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/app/soapbox/components/media-gallery.tsx b/app/soapbox/components/media-gallery.tsx index 9b9d1fb7d..c24d55f61 100644 --- a/app/soapbox/components/media-gallery.tsx +++ b/app/soapbox/components/media-gallery.tsx @@ -1,4 +1,4 @@ -import classNames from 'clsx'; +import classNames, { clsx } from 'clsx'; import React, { useState, useRef, useLayoutEffect } from 'react'; import Blurhash from 'soapbox/components/blurhash'; @@ -153,22 +153,20 @@ const Item: React.FC = ({ return (
- + {attachmentIcon} {filename} - +
); } else if (attachment.type === 'image') { const letterboxed = total === 1 && shouldLetterbox(attachment); thumbnail = ( - = ({ letterboxed={letterboxed} showExt /> - + ); } else if (attachment.type === 'gifv') { const conditionalAttributes: React.VideoHTMLAttributes = {}; @@ -210,25 +208,21 @@ const Item: React.FC = ({ } else if (attachment.type === 'audio') { const ext = attachment.url.split('.').pop()?.toUpperCase(); thumbnail = ( - {ext} - + ); } else if (attachment.type === 'video') { const ext = attachment.url.split('.').pop()?.toUpperCase(); thumbnail = ( - {ext} - + ); } @@ -552,4 +546,27 @@ const MediaGallery: React.FC = (props) => { ); }; +interface IMediaItemThumbnail extends Pick, 'href' | 'onClick' | 'title'> { + children: React.ReactNode + pointer?: boolean +} + +const MediaItemThumbnail: React.FC = ({ + children, + pointer = false, + ...rest +}) => { + return ( + + {children} + + ); +}; + export default MediaGallery;