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

feat: ability to add alt text to images #421

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: image creation logic
Sembauke committed Feb 2, 2024
commit bcd36e5fa26fb3810ae60e92e0fae79817153abf
21 changes: 18 additions & 3 deletions apps/frontend/src/components/add-image-modal.jsx
Original file line number Diff line number Diff line change
@@ -34,6 +34,14 @@ export default function ImageModal({
const handleImagePreview = (event) => {
setCurrentImage(URL.createObjectURL(event.target.files[0]));
setSubmitableImage(event.target.files);
setCurrentAlt("");
};

const removeOrCancel = () => {
setCurrentImage(null);
setSubmitableImage(null);
setCurrentAlt("");
setCurrentCaption("");
};

const handleImageSubmit = async (event) => {
@@ -66,6 +74,7 @@ export default function ImageModal({
});

setCurrentImage(null);
setSubmitableImage(null);
setCurrentAlt("");
setCurrentCaption("");

@@ -139,7 +148,7 @@ export default function ImageModal({
<Button
colorScheme="red"
width="100%"
onClick={() => setCurrentImage(null)}
onClick={() => removeOrCancel()}
>
Remove Image
</Button>
@@ -152,26 +161,32 @@ export default function ImageModal({
onChange={(event) => {
setCurrentAlt(event.target.value);
}}
value={currentAlt}
required
/>
<Spacer height="1rem" width="100%" />
<Input
type="text"
placeholder="Caption"
value={currentCaption}
onChange={(event) => {
setCurrentCaption(event.target.value);
}}
/>
</ModalBody>
<ModalFooter>
<Button colorScheme="blue" type="submit" disabled={true}>
<Button
colorScheme="blue"
type="submit"
isDisabled={!submitableImage || !currentAlt}
>
Save
</Button>
<Button
colorScheme="red"
ml={3}
onClick={() => {
setCurrentImage(null);
removeOrCancel();
onClose();
}}
>