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

Enhancement: Remove Image Attachments and Fix Wide Aspect Ratio Image Previews #1212

Open
wants to merge 3 commits into
base: main
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
28 changes: 27 additions & 1 deletion frontend/src/components/QuestionInput/QuestionInput.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@
color: #424242;
}

.uploadedImage {
.uploadedImageContainer {
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin-right: 70px;
cursor: pointer;
}

.uploadedImage {
max-width: 108px;
max-height: 100%;
transition: filter 0.3s ease;
}

.uploadedImageContainer:hover .uploadedImage {
filter: grayscale(100%) brightness(80%);
}

.trashIcon {
position: absolute;
font-size: 20px;
color: red;
display: none;
}

.uploadedImageContainer:hover .trashIcon {
display: block;
}
16 changes: 13 additions & 3 deletions frontend/src/components/QuestionInput/QuestionInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ export const QuestionInput = ({ onSend, disabled, placeholder, clearOnSend, conv

if (file) {
await convertToBase64(file);
event.target.value = '';
}
};

const removeImage = () => {
setBase64Image(null);
};

const convertToBase64 = async (file: Blob) => {
try {
const resizedBase64 = await resizeImage(file, 800, 800);
setBase64Image(resizedBase64);
} catch (error) {
console.error('Error:', error);
removeImage();
}
};

Expand All @@ -50,11 +56,10 @@ export const QuestionInput = ({ onSend, disabled, placeholder, clearOnSend, conv

if (conversationId && questionTest !== undefined) {
onSend(questionTest, conversationId)
setBase64Image(null)
} else {
onSend(questionTest)
setBase64Image(null)
}
removeImage()

if (clearOnSend) {
setQuestion('')
Expand Down Expand Up @@ -103,7 +108,12 @@ export const QuestionInput = ({ onSend, disabled, placeholder, clearOnSend, conv
/>
</label>
</div>)}
{base64Image && <img className={styles.uploadedImage} src={base64Image} alt="Uploaded Preview" />}
{base64Image && (
<div className={styles.uploadedImageContainer} onClick={removeImage}>
<img className={styles.uploadedImage} src={base64Image} alt="Uploaded Preview" />
<FontIcon className={styles.trashIcon} iconName={'Delete'} />
</div>
)}
<div
className={styles.questionInputSendButtonContainer}
role="button"
Expand Down
52 changes: 26 additions & 26 deletions static/assets/index-c5246876.js → static/assets/index-8d046137.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/x-icon" href="{{ favicon }}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ title }}</title>
<script type="module" crossorigin src="/assets/index-c5246876.js"></script>
<link rel="stylesheet" href="/assets/index-65ec62ea.css">
<script type="module" crossorigin src="/assets/index-8d046137.js"></script>
<link rel="stylesheet" href="/assets/index-e27bb55a.css">
</head>
<body>
<div id="root"></div>
Expand Down