From b13b286b3ff32b38e426af8f620c73b9f15b77d2 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 14 Mar 2025 23:14:32 -0500 Subject: [PATCH] Streamline custom image props --- src/admin/AdminUploadsTable.tsx | 6 +++++- src/components/image/ImageLarge.tsx | 4 ++-- src/components/image/ImageMedium.tsx | 4 ++-- src/components/image/ImageSmall.tsx | 4 ++-- src/components/image/ImageWithFallback.tsx | 10 +++++----- src/components/image/index.ts | 14 +++++++------- src/photo/PhotoLarge.tsx | 2 +- src/photo/PhotoMedium.tsx | 2 +- 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/admin/AdminUploadsTable.tsx b/src/admin/AdminUploadsTable.tsx index 091dfe98..2a4f57a6 100644 --- a/src/admin/AdminUploadsTable.tsx +++ b/src/admin/AdminUploadsTable.tsx @@ -2,7 +2,10 @@ import ImageSmall from '@/components/image/ImageSmall'; import Spinner from '@/components/Spinner'; -import { getExtensionFromStorageUrl } from '@/platforms/storage'; +import { + getIdFromStorageUrl, + getExtensionFromStorageUrl, +} from '@/platforms/storage'; import { clsx } from 'clsx/lite'; import { FaRegCircleCheck } from 'react-icons/fa6'; import { pathForAdminUploadUrl } from '@/app/paths'; @@ -46,6 +49,7 @@ export default function AdminUploadsTable({ 'scale-90', )}> {(showFallback || shouldDebugImageFallbacks) && @@ -87,8 +87,8 @@ export default function ImageWithFallback(props: ImageProps & { ...rest, src: blurDataURL, className: clsx( - imgClassName, getBlurClass(), + classNameImage, ), }} /> :
diff --git a/src/components/image/index.ts b/src/components/image/index.ts index eb7d6582..fea317ec 100644 --- a/src/components/image/index.ts +++ b/src/components/image/index.ts @@ -1,3 +1,6 @@ +import { ComponentProps } from 'react'; +import ImageWithFallback from './ImageWithFallback'; + // Height determined by intrinsic photo aspect ratio export const IMAGE_WIDTH_SMALL = 50; // Height determined by intrinsic photo aspect ratio @@ -5,13 +8,10 @@ export const IMAGE_WIDTH_MEDIUM = 300; // Height determined by intrinsic photo aspect ratio export const IMAGE_WIDTH_LARGE = 1000; -export interface ImageProps { +export type CustomImageProps = Omit< + ComponentProps, + 'blurCompatibilityLevel' +> & { aspectRatio: number blurCompatibilityMode?: boolean - className?: string - imgClassName?: string - src: string - alt: string - blurDataURL?: string - priority?: boolean } diff --git a/src/photo/PhotoLarge.tsx b/src/photo/PhotoLarge.tsx index 2aa203e0..e0ca83eb 100644 --- a/src/photo/PhotoLarge.tsx +++ b/src/photo/PhotoLarge.tsx @@ -180,7 +180,7 @@ export default function PhotoLarge({ >