From 1728e2a870d2d19a27d12de2a273ec8d7526c501 Mon Sep 17 00:00:00 2001 From: GameDog9988 Date: Mon, 18 Sep 2023 22:55:02 -0400 Subject: [PATCH 1/2] feat: add skeleton image --- .../src/components/game/image-choice.tsx | 24 ++++++++++- apps/client/src/components/game/prompt.tsx | 43 +++++++++++-------- apps/client/tailwind.config.js | 5 +++ 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/apps/client/src/components/game/image-choice.tsx b/apps/client/src/components/game/image-choice.tsx index 9aff5575..af209682 100644 --- a/apps/client/src/components/game/image-choice.tsx +++ b/apps/client/src/components/game/image-choice.tsx @@ -14,9 +14,24 @@ type ImageChoiceProps = { imageOption2: { src: string; alt: string }; selectedImage: ImageOption | undefined; setSelectedImage: Dispatch>; + loading?: boolean; disabled?: boolean; }; +/** + * Skeleton component taken from Delba's fantastic blog post + * https://delba.dev/blog/animated-loading-skeletons-with-tailwind + */ +const SkeletonImage = () => { + return ( + + ); +}; + const ImageChoiceOption = ({ image, option, @@ -38,6 +53,10 @@ const ImageChoiceOption = ({ bothShown: boolean; selectedImage: ImageOption | undefined; }) => { + if (!image.src) { + return ; + } + return ( { const [showImage1, setShowImage1] = useState(false); @@ -115,7 +135,7 @@ const ImageChoice = ({ return (
- {imageOption1.src && ( + {(loading || imageOption1.src) && ( )} - {imageOption2.src && ( + {(loading || imageOption2.src) && ( {!imagesLoaded && ( @@ -233,24 +234,30 @@ const Prompt = ({ onSubmit={onPromptSubmit} >
-