Skip to content
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

Add optional property labelAfter to set label after drop operation #50

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

report*
report*
/.vs
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default DragDrop;
| ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| name | string | the name for your form (if exist) | `"myFile"` |
| multiple | boolean | a boolean to determine whether the multiple files is enabled or not | `true OR false - false by default` |
| label | string | the label (text) for your form (if exist) inside the uploading box - first word underlined | `"Upload or drop a file right here"` |
| label | string | the label (text) for your form (if exist) inside the uploading box - first word underlined | `"Upload or drop a file right here"` |
| labelAfter | string | the label (text) for your form (if exist) inside the uploading box - After the drop operation is done - first word underlined | `"Uploaded Successfully!. Upload another?"` |
| disabled | boolean | this for disabled the input | `true OR false` |
| hoverTitle | string | text appears(hover) when trying to drop a file | `"Drop here"` |
| fileOrFiles | Array<File> or File or null | this mainly made because if you would like to remove uploaded file(s) pass null or pass another file as initial |
Expand Down
13 changes: 12 additions & 1 deletion src/FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Props = {
fileOrFiles?: Array<File> | File | null;
disabled?: boolean | false;
label?: string | undefined;
labelAfter?: string | undefined;
multiple?: boolean | false;
onSizeError?: (arg0: string) => void;
onTypeError?: (arg0: string) => void;
Expand All @@ -38,6 +39,7 @@ type Props = {
* @param typeError - boolean to check if the file has type errors
* @param disabled - boolean to check if input is disabled
* @param label - string to add custom label
* @param labelAfter - string to add custom label shown after drop completed
* @returns JSX Element
*
* @internal
Expand Down Expand Up @@ -71,7 +73,16 @@ const drawDescription = (
</>
) : (
<>
<span>Uploaded Successfully!.</span> Upload another?
{labelAfter ? (
<>
<span>{labelAfter.split(' ')[0]}</span>{' '}
{labelAfter.substr(labelAfter.indexOf(' ') + 1)}
</>
) : (
<>
<span>Uploaded Successfully!.</span> Upload another?
</>
)}
</>
)}
</Description>
Expand Down