From 182fad2b113e70f5cf24170bd84c5864574d9fdf Mon Sep 17 00:00:00 2001 From: Adrian Bielec Date: Wed, 23 Oct 2024 09:58:32 +0200 Subject: [PATCH] refactor(upload): rename Error component to ErrorComponent --- .../src/components/form/Field.styles.ts | 18 +++++++++++++++++- .../src/components/form/Upload/BaseUpload.tsx | 5 ++++- .../react-kit/src/components/form/types.ts | 1 + packages/react-kit/src/theme.ts | 3 ++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/react-kit/src/components/form/Field.styles.ts b/packages/react-kit/src/components/form/Field.styles.ts index 0c0f1b955..59186b605 100644 --- a/packages/react-kit/src/components/form/Field.styles.ts +++ b/packages/react-kit/src/components/form/Field.styles.ts @@ -128,6 +128,7 @@ export type FileUploadWrapperTheme = Partial<{ }>; export const FileUploadWrapper = styled.div<{ $error: unknown; + $v2?: boolean; theme: FileUploadWrapperTheme | undefined; }>` position: relative; @@ -188,13 +189,28 @@ export const FileUploadWrapper = styled.div<{ cursor: not-allowed; opacity: 0.5; } + ${({ $v2 }) => + $v2 && + css` + aspect-ratio: 1/1; + padding-inline: 1.5rem; + background: ${colors.white}; + min-width: 9.375rem; + width: auto; + height: auto; + border-radius: 12px; + border: 2px solid ${theme.colors.light.border}; + color: ${theme.colors.light.greyText}; + `} `; export const FieldFileUpload = styled(FieldInput)` display: none; `; -export const FieldFileUploadWrapper = styled.div<{ $disabled: boolean }>` +export const FieldFileUploadWrapper = styled.div<{ + $disabled: boolean; +}>` position: relative; display: inline-block; ${({ $disabled }) => diff --git a/packages/react-kit/src/components/form/Upload/BaseUpload.tsx b/packages/react-kit/src/components/form/Upload/BaseUpload.tsx index bfc5f8ff2..0fd58b630 100644 --- a/packages/react-kit/src/components/form/Upload/BaseUpload.tsx +++ b/packages/react-kit/src/components/form/Upload/BaseUpload.tsx @@ -53,6 +53,7 @@ function BaseUpload({ removeFile, saveButtonTheme, errorComponent, + v2, theme, ...props }: UploadPropsWithNoIpfs & WithUploadToIpfsProps) { @@ -220,6 +221,7 @@ function BaseUpload({ handleLoading(true); try { const files = await saveToIpfs(efiles, true); + setErrorMessage(undefined); if (files) { setFiles(files); } else { @@ -272,8 +274,8 @@ function BaseUpload({ }} /> )} + {errorMesage && errorComponent?.(errorMesage)} - {errorMesage && errorComponent?.(errorMesage)}