-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add much more customisable FileUpload component #713
base: main
Are you sure you want to change the base?
Conversation
better clarity
/** | ||
* @deprecated Use `FileInput` component instead, as that is much more customisable. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean next time, folks who only want the default options got to use all those FileInput.*
elements?
@@ -119,6 +119,9 @@ export type AttachmentProps<Multiple extends boolean> = | |||
onRejection?: (rejections: FileRejection[]) => void | |||
} & AttachmentValueProp<Multiple> | |||
|
|||
/** | |||
* @deprecated Use `FileInput` component instead, as that is much more customisable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @deprecated Use `FileInput` component instead, as that is much more customisable. | |
* @deprecated Use `FileUpload` component instead, as that is much more customisable. |
|
||
return ( | ||
<chakra.div __css={styles.errorText} {...rest} ref={ref}> | ||
<Icon as={BxsErrorCircle} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all Icon
have aria-hidden
? Saw you had it for FileUploadDropzoneIcon
const apiRef = useRef<Api<PropTypes>>() | ||
const api = connect(state, send, normalizeProps) | ||
apiRef.current = api | ||
return api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does apiRef
get utilised / referred to if it isn't returned here?
return errorMessage | ||
} | ||
case 'FILE_TOO_SMALL': { | ||
let errorMessage = 'This file is too small.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does this scenario happen...?
* @param fileSizeInBytes the size of the file in bytes to be converted to a readable string | ||
* @returns the human-readable file size string | ||
*/ | ||
export const getReadableFileSize = (fileSizeInBytes: number): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I suppose technology is not that advanced yet - 1000 TB gives 1 undefined
return ( | ||
<FileUploadRoot | ||
{...props} | ||
maxFiles={maxFiles} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component (in storybook) silently rejects files when there are more number of files than allowed. Is this expected?
This PR adds a new
FileUpload
component that is designed to supersede theAttachment
component. This component is much more customisable if needed, and contains a few prop changes as compared toAttachment
.Closes #586 (above and beyond?)
Example usages can be seen in the stories, but replicated here for convenience:
Default usage (with rhf)
With parts ownself modify