-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from all commits
2641012
301b4ab
edb49fc
e9304d6
6b0a9be
c356f8c
ebe6cc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
.uploadButton_container { | ||
position: relative; | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: center; | ||
background-color: transparent; | ||
border-radius: 50%; | ||
height: 36px; | ||
width: 36px; | ||
margin-right: 16px; | ||
margin-left: 10px; | ||
margin-top: 5px; | ||
} | ||
|
||
.uploadButton { | ||
background: transparent; | ||
border: none; | ||
height: 36px; | ||
width: 36px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
} | ||
|
||
.uploadButton img { | ||
width: 24px; | ||
height: 24px; | ||
} | ||
|
||
.uploadButton:not(:disabled):hover { | ||
cursor: pointer; | ||
} | ||
|
||
.uploadButton:active { | ||
background-color: var(--grey-400); | ||
border-radius: 50%; | ||
} | ||
|
||
.uploadButton_container:has(.uploadButton:disabled) { | ||
color: var(--grey-900); | ||
opacity: 0.5; | ||
} | ||
|
||
.uploadButton_container:has(.uploadButton:not(:disabled)):hover { | ||
background-color: var(--grey-300); | ||
} | ||
|
||
.sendButtonContainer { | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: center; | ||
height: 100%; | ||
} | ||
|
||
.tooltip { | ||
position: absolute; | ||
bottom: 130%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
width: 220px; | ||
background-color: #333333; | ||
color: #f2f2f2; | ||
padding: 8px; | ||
border-radius: 8px; | ||
font-family: 'Roboto', sans-serif; | ||
font-size: 14px; | ||
line-height: 16px; | ||
text-align: left; | ||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); | ||
z-index: 10; | ||
} | ||
|
||
.tooltip p { | ||
margin: 0 0 8px 0; | ||
} | ||
|
||
.tooltip p:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
.tooltip::after { | ||
content: ''; | ||
position: absolute; | ||
top: 100%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
border-width: 8px; | ||
border-style: solid; | ||
border-color: #333333 transparent transparent transparent; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { ChangeEvent, useState } from 'react'; | ||
import styles from './fileUpload.module.css'; | ||
import UploadIcon from '../icons/upload.svg'; | ||
import UploadInProgressIcon from '../icons/upload-in-progress.svg'; | ||
import CheckCircleIcon from '../icons/check-circle.svg'; | ||
|
||
interface FileUploaderProps { | ||
onFileUpload: (file: File) => Promise<void>; | ||
uploadInProgress: boolean; | ||
disabled: boolean; | ||
} | ||
|
||
export const FileUpload = ({ | ||
onFileUpload, | ||
uploadInProgress, | ||
disabled, | ||
}: FileUploaderProps) => { | ||
const [showTooltip, setShowTooltip] = useState<boolean>(false); | ||
|
||
const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const file = event.target.files?.[0]; | ||
if (file) { | ||
onFileUpload(file); | ||
} | ||
}; | ||
|
||
const tooltipContent = disabled ? ( | ||
<> | ||
<p>You already uploaded one file.</p> | ||
<p>You can upload a different file by starting a new chat.</p> | ||
<p>Starting a new chat will reset your existing conversation history.</p> | ||
</> | ||
) : ( | ||
<p>You can only upload one .csv, .pdf or .txt file to this chat.</p> | ||
); | ||
|
||
return ( | ||
<div | ||
className={styles.uploadButton_container} | ||
onMouseEnter={() => setShowTooltip(true)} | ||
onMouseLeave={() => setShowTooltip(false)} | ||
> | ||
<label className={styles.uploadButton}> | ||
{uploadInProgress ? ( | ||
<img src={UploadInProgressIcon} alt="Uploading..." /> | ||
) : disabled ? ( | ||
<img src={CheckCircleIcon} alt="Upload Complete" /> | ||
) : ( | ||
<img src={UploadIcon} alt="Upload" /> | ||
)} | ||
<input | ||
type="file" | ||
accept=".csv, .pdf, .txt" | ||
onChange={handleFileChange} | ||
style={{ display: 'none' }} | ||
disabled={disabled} | ||
/> | ||
</label> | ||
{showTooltip && <div className={styles.tooltip}>{tooltipContent}</div>} | ||
</div> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.uploadedFileContainer { | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
height: 36px; | ||
margin-bottom: 4px; | ||
box-sizing: border-box; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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-200); | ||
padding: 8px 12px; | ||
border-radius: 8px; | ||
text-align: left; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
margin-right: 65px; | ||
} | ||
|
||
.attachmentIcon { | ||
width: 16px; | ||
height: 16px; | ||
margin-right: 8px; | ||
margin-bottom: -3px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import styles from './uploadedFileDisplay.module.css'; | ||
import AttachmentIcon from '../icons/attachment.svg'; | ||
|
||
interface UploadedFileDisplayProps { | ||
fileName: string; | ||
} | ||
|
||
export const UploadedFileDisplay = ({ fileName }: UploadedFileDisplayProps) => ( | ||
<div className={styles.uploadedFileContainer}> | ||
<span className={styles.uploadedFile}> | ||
<img | ||
src={AttachmentIcon} | ||
alt="Attachment" | ||
className={styles.attachmentIcon} | ||
/> | ||
{fileName} | ||
</span> | ||
</div> | ||
); |
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.
This matches design, but should probably be
You've
instead ofYou
.