Skip to content

Commit

Permalink
refactor(upload): rename Error component to ErrorComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBielecAriane committed Oct 23, 2024
1 parent 754daed commit 182fad2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
18 changes: 17 additions & 1 deletion packages/react-kit/src/components/form/Field.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export type FileUploadWrapperTheme = Partial<{
}>;
export const FileUploadWrapper = styled.div<{
$error: unknown;
$v2?: boolean;
theme: FileUploadWrapperTheme | undefined;
}>`
position: relative;
Expand Down Expand Up @@ -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 }) =>
Expand Down
5 changes: 4 additions & 1 deletion packages/react-kit/src/components/form/Upload/BaseUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function BaseUpload({
removeFile,
saveButtonTheme,
errorComponent,
v2,
theme,
...props
}: UploadPropsWithNoIpfs & WithUploadToIpfsProps) {
Expand Down Expand Up @@ -220,6 +221,7 @@ function BaseUpload({
handleLoading(true);
try {
const files = await saveToIpfs(efiles, true);
setErrorMessage(undefined);
if (files) {
setFiles(files);
} else {
Expand Down Expand Up @@ -272,8 +274,8 @@ function BaseUpload({
}}
/>
)}
{errorMesage && errorComponent?.(errorMesage)}
<FieldFileUploadWrapper {...wrapperProps} $disabled={!!disabled}>
{errorMesage && errorComponent?.(errorMesage)}
<FieldInput
{...props}
hidden
Expand Down Expand Up @@ -317,6 +319,7 @@ function BaseUpload({
data-disabled={disabled}
onClick={handleChooseFile}
$error={errorMessage}
$v2={v2}
style={style}
theme={theme?.triggerTheme}
>
Expand Down
1 change: 1 addition & 0 deletions packages/react-kit/src/components/form/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export type UploadProps = BaseProps & {
width?: number;
height?: number;
errorComponent?: (errorMessage: string) => React.ReactNode;
v2?: boolean;
imgPreviewStyle?: Pick<CSSProperties, "objectFit">;
theme?: Partial<{ triggerTheme: FileUploadWrapperTheme }>;
} & (
Expand Down
3 changes: 2 additions & 1 deletion packages/react-kit/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const theme = {
cyan: "#00FFFF",
lightArrowColor: "#dedfe3",
darkGreyTimeStamp: "#E8EAF1",
lightGrey2: "#eff0f7"
lightGrey2: "#eff0f7",
greyText: "rgba(28, 13, 24, 0.75)"
}
},
mobile: "768px",
Expand Down

0 comments on commit 182fad2

Please sign in to comment.