From 2aa5dc01eb0955af5829e426a1c4a9481f4b442e Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 29 May 2024 11:59:06 +0200 Subject: [PATCH] feat(catalog post): add loading skeleton for image, "file deleted" fallback img --- .../catalog-row/catalog-row.module.css | 10 +++ src/components/catalog-row/catalog-row.tsx | 80 ++++++++++++------- .../post-menu-desktop.module.css | 8 +- src/views/home/home.tsx | 2 +- 4 files changed, 66 insertions(+), 34 deletions(-) diff --git a/src/components/catalog-row/catalog-row.module.css b/src/components/catalog-row/catalog-row.module.css index f09270bb..e97bb7c5 100644 --- a/src/components/catalog-row/catalog-row.module.css +++ b/src/components/catalog-row/catalog-row.module.css @@ -85,4 +85,14 @@ .post:hover .postMenu { visibility: visible; +} + +.loadingSkeleton { + width: 150px; + height: 150px; + display: inline-block; +} + +.fileDeleted { + image-rendering: pixelated; } \ No newline at end of file diff --git a/src/components/catalog-row/catalog-row.tsx b/src/components/catalog-row/catalog-row.tsx index 30a19bde..766cd4ff 100644 --- a/src/components/catalog-row/catalog-row.tsx +++ b/src/components/catalog-row/catalog-row.tsx @@ -8,34 +8,24 @@ import useFetchGifFirstFrame from '../../hooks/use-fetch-gif-first-frame'; import useCountLinksInReplies from '../../hooks/use-count-links-in-replies'; import PostMenuDesktop from '../post/post-desktop/post-menu-desktop/'; -export const CatalogPostMedia = ({ commentMediaInfo }: { commentMediaInfo: any }) => { +import React, { useState } from 'react'; + +interface CatalogPostMediaProps { + commentMediaInfo: any; + isOutOfFeed?: boolean; + linkWidth?: number; + linkHeight?: number; +} + +export const CatalogPostMedia = ({ commentMediaInfo, isOutOfFeed, linkWidth, linkHeight }: CatalogPostMediaProps) => { const { patternThumbnailUrl, thumbnail, type, url } = commentMediaInfo || {}; const iframeThumbnail = patternThumbnailUrl || thumbnail; const gifFrameUrl = useFetchGifFirstFrame(type === 'gif' ? url : undefined); - let thumbnailComponent: React.ReactNode = null; - - if (type === 'image') { - thumbnailComponent = ; - } else if (type === 'video') { - thumbnailComponent = thumbnail ? :