From 65a1f0f0588a458850f52fd7fb27cdf58cf3ee35 Mon Sep 17 00:00:00 2001 From: Rushi Vishavadia Date: Thu, 28 Sep 2023 13:12:58 +0530 Subject: [PATCH] X2-6577 Add ability to specify the caption for the button --- src/components/ImageUpload.jsx | 6 ++++-- src/stories/Media/ImageUpload.stories.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/ImageUpload.jsx b/src/components/ImageUpload.jsx index ee22f90d2..7e5028d1a 100644 --- a/src/components/ImageUpload.jsx +++ b/src/components/ImageUpload.jsx @@ -10,6 +10,7 @@ export const ImageUpload = ({ maxSize = 5, hasDelete = true, requirements = null, + caption = null, csvAcceptFormats = "image/png,image/jpeg", onChange, onDelete, @@ -41,6 +42,7 @@ export const ImageUpload = ({ }; const hasRequirements = requirements?.trim().length > 0; + const hasCaption = caption?.trim().length > 0; return (
@@ -73,12 +75,12 @@ export const ImageUpload = ({ Delete - Upload New Picture + {hasCaption ? caption.trim() : "Upload New Photo"} ) : ( - {src ? "Replace Photo" : "Upload New Photo"} + {hasCaption ? caption.trim() : src ? "Replace Photo" : "Upload New Photo"} )}
diff --git a/src/stories/Media/ImageUpload.stories.js b/src/stories/Media/ImageUpload.stories.js index 9ee9eb5c0..7e4ddc6a9 100644 --- a/src/stories/Media/ImageUpload.stories.js +++ b/src/stories/Media/ImageUpload.stories.js @@ -20,6 +20,7 @@ const ImageUploadStories = { size: "medium", maxSize: 5, hasDelete: true, + caption: "", requirements: "", }, argTypes: { @@ -43,6 +44,14 @@ const ImageUploadStories = { defaultValue: { summary: "medium" }, }, }, + csvAcceptFormats: { + description: "The caption to show on the upload button", + control: { type: "text" }, + table: { + type: { summary: null }, + defaultValue: { summary: "Upload New Photo" }, + }, + }, isLoading: { control: { type: "boolean" }, table: { @@ -82,6 +91,7 @@ export const Default = ({ src: source, size = "small", maxSize, + caption, csvAcceptFormats, hasDelete, requirements, @@ -112,6 +122,7 @@ export const Default = ({ size={size} isLoading={isLoading} maxSize={maxSize} + caption={caption} hasDelete={hasDelete} requirements={requirements} onChange={onChange}