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

FS-93 Changes for the File Upload UI #36

Merged
merged 7 commits into from
Nov 27, 2024
Merged

Conversation

gaganahluwalia
Copy link
Collaborator

Description

These changes are to do the UI changes for File Upload, backend is already done.

Changelog

  • New Components for the File Upload Part
  • New CSS Files
  • Changes to existing input.tsx file

@gaganahluwalia gaganahluwalia changed the title Changes for the File Upload UI FS-93 Changes for the File Upload UI Nov 26, 2024
Copy link
Collaborator

@dianaPrahoveanu-SL dianaPrahoveanu-SL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 💯 I just got a couple small comments

}

.uploadButton:active {
background-color: var(--grey-400);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed when clicking the button the background has a square shape. I think that can be an easy fix by adding border-radius: 50%; here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

.uploadedFile {
font-size: 14px;
color: var(--grey-900);
background-color: var(--grey-100);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the background colour here should be --grey-200

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

overflow: hidden;
text-overflow: ellipsis;
margin-right: 65px;
border: 1px solid var(--grey-300);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a nit-pick but I don't think we should have a border on this card here as per the UX specs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

margin-bottom: 4px;
box-sizing: border-box;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed some extra spacing between the inputContainer and the uploadedFileContainer which I think can be easily fixed by removing the margin from the inputContainer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

@@ -8,7 +8,8 @@ import React, {
} from 'react';
import styles from './input.module.css';
import RightArrowIcon from '../icons/send.svg';
import UploadIcon from '../icons/upload.svg';
import { FileUploader } from './fileUploader';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call it FileUpload instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Comment on lines 9 to 10
isUploading: boolean;
isUploaded: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isUploading: boolean;
isUploaded: boolean;
uploadInProgress: boolean;
uploadComplete: boolean;

I would suggest these names are slightly nicer to read

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

const [isUploading, setIsUploading] = useState<boolean>(false);
const [isUploaded, setIsUploaded] = useState<boolean>(false);
// TODO: Add fileId to the state
// const [fileId, setFileId] = useState<string>('');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for future use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if we needed fileId, but there are other ways and depends upon the design to get that report, so I have removed it.

Comment on lines 66 to 76
const formData = new FormData();
formData.append('file', file);
const response = await fetch(`${process.env.BACKEND_URL}/uploadfile`, {
method: 'POST',
body: formData,
credentials: 'include',
});
if (!response.ok)
throw new Error(`Upload failed with status ${response.status}`);

const { filename, id } = await response.json();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this request and response bit to server.ts to match the other api calls?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

// setFileId(id);
setUploadedFile(file);
setIsUploading(false);
setIsUploaded(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the isUploaded state? We could maybe just use the fact the uploadedFile is set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Initially I used it for quick work, but then forgot to use the uploadedFile and remove it.

Copy link
Collaborator

@IMladjenovic IMladjenovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Haven't pulled it down since the changes and tested myself though

@gaganahluwalia gaganahluwalia merged commit fb4e3a9 into main Nov 27, 2024
4 checks passed
@gaganahluwalia gaganahluwalia deleted the FS-93/UI-File-Upload branch November 27, 2024 13:33

const tooltipContent = disabled ? (
<>
<p>You already uploaded one file.</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches design, but should probably be You've instead of You.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants