diff --git a/src/components/FileUpload/FileMultiUpload.tsx b/src/components/FileUpload/FileMultiUpload.tsx index b20b722d..93891c8a 100644 --- a/src/components/FileUpload/FileMultiUpload.tsx +++ b/src/components/FileUpload/FileMultiUpload.tsx @@ -61,9 +61,17 @@ const FileUploadTitle = styled(Title)<{ $isNotSupported: boolean }>` : theme.click.fileUpload.color.title.default}; `; -const FileUploadDescription = styled(Text)` +const FileName = styled(Text)` font: ${({ theme }) => theme.click.fileUpload.typography.description.default}; - color: ${({ theme }) => theme.click.fileUpload.color.description.default}; + color: ${({ theme }) => theme.click.fileUpload.color.title.default}; +`; + +const FileUploadDescription = styled(Text)<{ $isError?: boolean }>` + font: ${({ theme }) => theme.click.fileUpload.typography.description.default}; + color: ${({ theme, $isError }) => + $isError + ? theme.click.fileUpload.color.title.error + : theme.click.fileUpload.color.description.default}; `; const UploadIcon = styled(Icon)` @@ -106,7 +114,7 @@ const FileItem = styled.div<{ $isError?: boolean }>` props.$isError && css` background-color: ${({ theme }) => theme.click.fileUpload.color.background.error}; - border: none; + border-color: transparent; `} `; @@ -118,20 +126,6 @@ const DocumentIcon = styled(Icon)` } `; -const FileInfoHeader = styled.div` - display: flex; - align-items: center; - gap: ${({ theme }) => theme.click.fileUpload.sm.space.gap}; - width: 100%; -`; - -const FileInfo = styled.div` - display: flex; - flex-direction: column; - gap: ${({ theme }) => theme.click.fileUpload.hasFile.header.space.gap}; - flex: 1; -`; - const FileDetails = styled.div` display: flex; gap: ${({ theme }) => theme.click.fileUpload.md.space.gap}; @@ -145,23 +139,17 @@ const FileActions = styled.div` gap: 0; `; -const ProgressContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - width: 100%; -`; - -const ProgressBarContainer = styled.div` - width: 100%; +const FileContentContainer = styled.div` flex: 1; + display: flex; + flex-direction: column; + justify-content: center; + min-height: 24px; `; -const ProgressPercentage = styled(Text)` - min-width: ${({ theme }) => theme.sizes[10]}; - text-align: right; - padding-right: ${({ theme }) => theme.click.fileUpload.md.space.gap}; +const ProgressBarWrapper = styled.div` + margin-top: ${({ theme }) => theme.click.fileUpload.md.space.gap}; + margin-bottom: 9px; `; const formatFileSize = (sizeInBytes: number): string => { @@ -376,71 +364,56 @@ export const FileMultiUpload = ({ key={file.id} $isError={file.status === "error"} > - - - - - {truncateFilename(file.name)} - {(file.status === "success" || file.status === "uploading") && ( - - {formatFileSize(file.size)} - - )} - {file.status === "error" && ( - - {file.errorMessage || "Upload failed"} - - )} - {file.status === "success" && ( - - )} - - - - {file.status === "error" && ( - handleRetryUpload(file.id)} - /> - )} - handleRemoveFile(file.id)} + + + + {truncateFilename(file.name)} + {file.status === "uploading" && ( + {file.progress}% + )} + {file.status === "error" && ( + + {file.errorMessage || "Upload failed"} + + )} + {file.status === "success" && ( + - - - + )} + {file.status === "uploading" && ( - - - - - - {file.progress}% - - + + + + )} + {(file.status === "success" || file.status === "error") && ( + + {formatFileSize(file.size)} + + )} + + + {file.status === "error" && ( + handleRetryUpload(file.id)} + /> )} - + handleRemoveFile(file.id)} + /> + ))} diff --git a/src/components/FileUpload/FileUpload.tsx b/src/components/FileUpload/FileUpload.tsx index 4d2f1fbf..819de8e3 100644 --- a/src/components/FileUpload/FileUpload.tsx +++ b/src/components/FileUpload/FileUpload.tsx @@ -43,6 +43,10 @@ const UploadArea = styled.div<{ $hasFile || $size === "sm" ? `${theme.click.fileUpload.sm.space.y} ${theme.click.fileUpload.sm.space.x}` : `${theme.click.fileUpload.md.space.y} ${theme.click.fileUpload.md.space.x}`}; + min-height: ${({ theme, $size }) => + $size === "sm" + ? `calc(${theme.click.fileUpload.sm.space.y} * 2 + ${theme.sizes[6]})` + : "auto"}; display: flex; flex-direction: ${props => props.$hasFile ? "row" : props.$size === "sm" ? "row" : "column"}; @@ -74,7 +78,7 @@ const UploadArea = styled.div<{ props.$isError && css` background-color: ${({ theme }) => theme.click.fileUpload.color.background.error}; - border: none; + border-color: transparent; `} `; @@ -86,16 +90,24 @@ const FileUploadTitle = styled(Title)<{ $isNotSupported: boolean }>` : theme.click.fileUpload.color.title.default}; `; -const FileUploadDescription = styled(Text)` +const FileName = styled(Text)` font: ${({ theme }) => theme.click.fileUpload.typography.description.default}; - color: ${({ theme }) => theme.click.fileUpload.color.description.default}; + color: ${({ theme }) => theme.click.fileUpload.color.title.default}; +`; + +const FileUploadDescription = styled(Text)<{ $isError?: boolean }>` + font: ${({ theme }) => theme.click.fileUpload.typography.description.default}; + color: ${({ theme, $isError }) => + $isError + ? theme.click.fileUpload.color.title.error + : theme.click.fileUpload.color.description.default}; `; const DocumentIcon = styled(Icon)` svg { - width: ${({ theme }) => theme.click.fileUpload.sm.icon.size.width}; - height: ${({ theme }) => theme.click.fileUpload.sm.icon.size.height}; - color: ${({ theme }) => theme.click.fileUpload.sm.color.icon.default}; + width: ${({ theme }) => theme.click.fileUpload.md.icon.size.width}; + height: ${({ theme }) => theme.click.fileUpload.md.icon.size.height}; + color: ${({ theme }) => theme.click.fileUpload.md.color.icon.default}; } `; @@ -126,18 +138,10 @@ const UploadText = styled.div<{ $size: "sm" | "md"; $hasFile: boolean }>` `} `; -const FileInfoHeader = styled.div` - display: flex; - align-items: center; - gap: ${({ theme }) => theme.click.fileUpload.sm.space.gap}; - width: 100%; -`; - const FileInfo = styled.div` display: flex; - flex-direction: column; + flex-direction: row; gap: ${({ theme }) => theme.click.fileUpload.hasFile.header.space.gap}; - flex: 1; `; const FileDetails = styled.div` @@ -153,23 +157,17 @@ const FileActions = styled.div` gap: 0; `; -const ProgressContainer = styled.div` - display: flex; - flex-direction: row; - align-items: center; - justify-content: space-between; - width: 100%; -`; - -const ProgressBarContainer = styled.div` - width: 100%; +const FileContentContainer = styled.div<{ $size: "sm" | "md" }>` flex: 1; + display: flex; + flex-direction: column; + justify-content: center; + min-height: ${({ $size }) => ($size === "sm" ? "24px" : "auto")}; `; -const ProgressPercentage = styled(Text)` - min-width: ${({ theme }) => theme.sizes[10]}; - text-align: right; - padding-right: ${({ theme }) => theme.click.fileUpload.md.space.gap}; +const ProgressBarWrapper = styled.div` + margin-top: ${({ theme }) => theme.click.fileUpload.md.space.gap}; + margin-bottom: 9px; `; const formatFileSize = (sizeInBytes: number): string => { @@ -393,26 +391,16 @@ export const FileUpload = ({ ) : ( - - - + <> + + - {truncateFilename(file.name)} - {(showSuccess || showProgress) && ( - - {formatFileSize(file.size)} - + {truncateFilename(file.name)} + {showProgress && !showSuccess && ( + {progress}% )} {!showProgress && !showSuccess && ( - - {failureMessage} - + {failureMessage} )} {showSuccess && ( )} - - - {!showProgress && !showSuccess && ( - - )} - - - - - {showProgress && ( - - + {showProgress && !showSuccess && ( + - - + )} + {(showSuccess || !showProgress) && ( + {formatFileSize(file.size)} + )} + + + {!showProgress && !showSuccess && ( + - {progress}% - - - )} - + icon={"refresh"} + type={"ghost"} + onClick={handleRetryUpload} + /> + )} + + + )}