diff --git a/apps/client/package.json b/apps/client/package.json index 868cfc61..56409e96 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -1,6 +1,6 @@ { "name": "client", - "version": "0.3.3", + "version": "0.3.4", "private": true, "scripts": { "dev": "next dev", 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) && ( ) => { e.preventDefault(); setLoading(true); + const formPrompt = e.currentTarget.elements.prompt.value; + setImagePrompt(formPrompt); console.time("Execution Time"); @@ -116,8 +118,6 @@ const Prompt = ({ console.timeEnd("Execution Time"); if (images && images.length === 2) { - setImagePrompt(formPrompt); - if (userId) { const generations = await createGenerations({ userId, @@ -222,6 +222,7 @@ const Prompt = ({ }} selectedImage={selectedImage} setSelectedImage={setSelectedImage} + loading={loading} /> {!imagesLoaded && ( @@ -233,24 +234,30 @@ const Prompt = ({ onSubmit={onPromptSubmit} >
-