Fix images not setting properly

This commit is contained in:
jude 2024-02-28 16:58:44 +00:00
parent b0e37b56c0
commit 328127c55e
4 changed files with 18 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { JSX } from "preact"; import {JSX} from "preact";
import { createPortal } from "preact/compat"; import {createPortal} from "preact/compat";
type Props = { type Props = {
setModalOpen: (open: boolean) => never; setModalOpen: (open: boolean) => never;
@ -9,7 +9,7 @@ type Props = {
children: string | JSX.Element | JSX.Element[] | (() => JSX.Element); children: string | JSX.Element | JSX.Element[] | (() => JSX.Element);
}; };
export const Modal = ({ setModalOpen, title, onSubmit, onSubmitText, children }: Props) => { export const Modal = ({setModalOpen, title, onSubmit, onSubmitText, children}: Props) => {
const body = document.querySelector("body"); const body = document.querySelector("body");
return createPortal( return createPortal(
@ -34,7 +34,7 @@ export const Modal = ({ setModalOpen, title, onSubmit, onSubmitText, children }:
<section class="modal-card-body">{children}</section> <section class="modal-card-body">{children}</section>
{onSubmit && ( {onSubmit && (
<footer class="modal-card-foot"> <footer class="modal-card-foot">
<button class="button is-success" onInput={onSubmit}> <button class="button is-success" onClick={onSubmit}>
{onSubmitText || "Save"} {onSubmitText || "Save"}
</button> </button>
<button <button

View File

@ -16,7 +16,7 @@ export const Author = ({ name, icon, setReminder }: Props) => {
class="is-rounded embed_author_url" class="is-rounded embed_author_url"
url={icon} url={icon}
alt="Image for embed author" alt="Image for embed author"
setImage={(url) => { setImage={(url: string) => {
setReminder((reminder) => ({ setReminder((reminder) => ({
...reminder, ...reminder,
embed_author_url: url, embed_author_url: url,

View File

@ -65,7 +65,12 @@ export const Embed = () => {
class="embed_thumbnail_url" class="embed_thumbnail_url"
url={reminder.embed_thumbnail_url} url={reminder.embed_thumbnail_url}
alt="Square thumbnail embedded image" alt="Square thumbnail embedded image"
setImage={() => {}} setImage={(url: string) =>
setReminder((reminder: Reminder) => ({
...reminder,
embed_thumbnail_url: url || null,
}))
}
/> />
</p> </p>
</div> </div>
@ -76,7 +81,12 @@ export const Embed = () => {
class="embed_image_url" class="embed_image_url"
url={reminder.embed_image_url} url={reminder.embed_image_url}
alt="Large embedded image" alt="Large embedded image"
setImage={() => {}} setImage={(url: string) =>
setReminder((reminder: Reminder) => ({
...reminder,
embed_image_url: url || null,
}))
}
/> />
</p> </p>

View File

@ -33,6 +33,7 @@ const ImagePickerModal = ({ setModalOpen, setImage }) => {
title={"Enter Image URL"} title={"Enter Image URL"}
onSubmit={() => { onSubmit={() => {
setImage(value); setImage(value);
setModalOpen(false);
}} }}
onSubmitText={"Save"} onSubmitText={"Save"}
> >