From 655f91b3366bbc8f08347f1832c7c3b4d7dc0d9d Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 21 Oct 2023 16:27:07 -0500 Subject: [PATCH] Refactor button loader behavior --- src/components/IconButton.tsx | 15 ++++++++++----- src/components/IconPathButton.tsx | 5 ++++- src/components/ShareButton.tsx | 1 + src/components/Spinner.tsx | 24 ++++++++++++++++-------- src/photo/PhotoLarge.tsx | 26 ++++++++++++-------------- src/photo/SharePhotoButton.tsx | 25 ------------------------- 6 files changed, 43 insertions(+), 53 deletions(-) delete mode 100644 src/photo/SharePhotoButton.tsx diff --git a/src/components/IconButton.tsx b/src/components/IconButton.tsx index a8076e1e..4424e751 100644 --- a/src/components/IconButton.tsx +++ b/src/components/IconButton.tsx @@ -21,21 +21,26 @@ export default function IconButton({ return ( {!isLoading - ? {icon} - + : ); } diff --git a/src/components/ShareButton.tsx b/src/components/ShareButton.tsx index a3d4388a..02057aac 100644 --- a/src/components/ShareButton.tsx +++ b/src/components/ShareButton.tsx @@ -21,6 +21,7 @@ export default function ShareButton({ prefetch, shouldScroll, shouldReplace: true, + spinnerColor: 'dim', }} /> ); } diff --git a/src/components/Spinner.tsx b/src/components/Spinner.tsx index 20e2ed3d..c33510e1 100644 --- a/src/components/Spinner.tsx +++ b/src/components/Spinner.tsx @@ -1,25 +1,33 @@ +import { cc } from '@/utility/css'; + const SIZE_DEFAULT = 12; -export type SpinnerColor = 'text' | 'light-gray'; +export type SpinnerColor = 'text' | 'dim' | 'light-gray'; export default function Spinner({ size = SIZE_DEFAULT, color = 'light-gray', + className, }: { size?: number color?: SpinnerColor + className?: string }) { return ( - + }} + > + const renderMiniGrid = (children: JSX.Element, rightPadding = true) =>
*]:sm:flex-grow', - 'pr-2', + rightPadding && 'pr-2', )}> {children}
; @@ -114,19 +114,17 @@ export default function PhotoLarge({ )}> {photo.takenAtNaiveFormatted} -
- -
+ - )} + , false)} } /> ); diff --git a/src/photo/SharePhotoButton.tsx b/src/photo/SharePhotoButton.tsx deleted file mode 100644 index 2c02f421..00000000 --- a/src/photo/SharePhotoButton.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { Photo } from '.'; -import { pathForPhotoShare } from '@/site/paths'; -import { TbPhotoShare } from 'react-icons/tb'; -import IconPathButton from '@/components/IconPathButton'; - -export default function SharePhotoButton({ - photo, - tag, - prefetch, - shouldScroll, -}: { - photo: Photo - tag?: string - prefetch?: boolean - shouldScroll?: boolean -}) { - return ( - } - path={pathForPhotoShare(photo, tag)} - prefetch={prefetch} - shouldScroll={shouldScroll} - /> - ); -}