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

improve image overlay #106

Merged
merged 1 commit into from
Jan 9, 2025
Merged
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
77 changes: 42 additions & 35 deletions src/components/exercise-view/CropImageOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,50 @@ export function CropImageOverlay() {
<>Bild wird verarbeitet ...</>
) : (
<>
Wähle deinen Bereich aus.{' '}
<button
onClick={() => {
// TODO
// call action to upload image and handle response in client
const cropper = cropperRef.current?.cropper
if (cropper) {
ExerciseViewStore.update(s => {
s.chatHistory[s.navIndicatorPosition].resultPending = true
})
setTimeout(() => {
<p className="mb-3">Wähle deinen Bereich aus.</p>
<div className="flex justify-center">
<button
className="px-2 py-0.5 bg-green-200 hover:bg-green-300 rounded"
onClick={() => {
// TODO
// call action to upload image and handle response in client
const cropper = cropperRef.current?.cropper
if (cropper) {
ExerciseViewStore.update(s => {
s.chatHistory[s.navIndicatorPosition].entries.push({
type: 'image',
image: (s.checks[s.navIndicatorPosition].croppedImage =
cropper.getCroppedCanvas().toDataURL()),
description: '',
})
s.cropImage = false
s.chatOverlay = 'chat'
s.chatHistory[s.navIndicatorPosition].resultPending = true
})
void analyseLastInput()
}, 200)
}
}}
>
[Fertig]
</button>{' '}
<button
onClick={() => {
ExerciseViewStore.update(s => {
s.cropImage = false
})
}}
>
[Schließen]
</button>
setTimeout(() => {
ExerciseViewStore.update(s => {
s.chatHistory[s.navIndicatorPosition].entries.push({
type: 'image',
image: (s.checks[
s.navIndicatorPosition
].croppedImage = cropper
.getCroppedCanvas()
.toDataURL()),
description: '',
})
s.cropImage = false
s.chatOverlay = 'chat'
})
void analyseLastInput()
}, 200)
}
}}
>
Fertig
</button>{' '}
<button
className="px-2 py-0.5 bg-gray-200 hover:bg-gray-300 rounded ml-6"
onClick={() => {
ExerciseViewStore.update(s => {
s.cropImage = false
})
}}
>
Schließen
</button>
</div>
</>
)}
</div>
Expand Down