From c8443340f426abb4fcdd424f9cc2d47093f5efd7 Mon Sep 17 00:00:00 2001 From: jude Date: Sun, 19 Nov 2023 15:54:37 +0000 Subject: [PATCH] Improve parity Portal modals to body. Pad timezone buttons. Add initial attachment support. Default username/avatar --- src/components/App/TimezoneProvider.tsx | 4 ++-- src/components/Modal/index.tsx | 8 +++++-- src/components/Reminder/Attachment.tsx | 31 +++++++++++++++++++++++-- src/components/Reminder/Message.tsx | 2 +- src/components/Reminder/TimeInput.tsx | 12 +++++----- src/components/Reminder/Username.tsx | 4 ++-- src/components/TimezonePicker/index.tsx | 16 +++++++++---- 7 files changed, 58 insertions(+), 19 deletions(-) diff --git a/src/components/App/TimezoneProvider.tsx b/src/components/App/TimezoneProvider.tsx index 46b696e..a67c77a 100644 --- a/src/components/App/TimezoneProvider.tsx +++ b/src/components/App/TimezoneProvider.tsx @@ -1,14 +1,14 @@ import { createContext } from "preact"; import { useContext } from "preact/compat"; import { useState } from "preact/hooks"; -import { SystemZone } from "luxon"; +import { DateTime } from "luxon"; type TTimezoneContext = [string, (tz: string) => void]; const TimezoneContext = createContext(["UTC", () => {}] as TTimezoneContext); export const TimezoneProvider = ({ children }) => { - const [timezone, setTimezone] = useState(SystemZone.name); + const [timezone, setTimezone] = useState(DateTime.now().zoneName); return ( diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index 26ab871..c1717b8 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -1,4 +1,5 @@ import { JSX } from "preact"; +import { createPortal } from "preact/compat"; type Props = { setModalOpen: (open: boolean) => never; @@ -9,7 +10,9 @@ type Props = { }; export const Modal = ({ setModalOpen, title, onSubmit, onSubmitText, children }: Props) => { - return ( + const body = document.querySelector("body"); + + return createPortal( , + body, ); }; diff --git a/src/components/Reminder/Attachment.tsx b/src/components/Reminder/Attachment.tsx index 6c2914b..1e6d48c 100644 --- a/src/components/Reminder/Attachment.tsx +++ b/src/components/Reminder/Attachment.tsx @@ -1,12 +1,39 @@ import { useReminder } from "./ReminderContext"; export const Attachment = () => { - const [{ attachment, attachment_name }, setReminder] = useReminder(); + const [{ attachment_name }, setReminder] = useReminder(); return (