From 20030d1bf21ff0ce9a0a95885abe88b79a0b4d04 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 21 Mar 2021 15:56:14 +0100 Subject: new toast design in code --- components/notificationsArea.tsx | 4 ++- components/toast.tsx | 63 ++++++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 23 deletions(-) (limited to 'components') diff --git a/components/notificationsArea.tsx b/components/notificationsArea.tsx index 0a243e1..b427941 100644 --- a/components/notificationsArea.tsx +++ b/components/notificationsArea.tsx @@ -25,7 +25,9 @@ export function NotificationsArea(props: { useEffect(() => { if(messages > previousMessages) { - toast("Je hebt nieuwe meldingen!", "confirmation", ); + toast({ message: "Je hebt nieuwe meldingen!", + type: "confirmation", + icon: }); } setPreviousMessages(messages); diff --git a/components/toast.tsx b/components/toast.tsx index d774c96..91e67f7 100644 --- a/components/toast.tsx +++ b/components/toast.tsx @@ -23,6 +23,7 @@ function ToastArea(props: { function Toast(props: { text?: string + description?: string icon?: ReactNode children?: ReactNode type?: "normal"|"confirmation"|"error" @@ -35,7 +36,7 @@ function Toast(props: { return visible &&
{ props.children || -
+
{props.icon}
-

{props.text}

+

{props.text}

+

{props.description}

+
+
setVisibility(false)}> - +
}
} -export type toastType = (message: string, type: "confirmation"|"normal"|"error", icon?: ReactNode ) => void; +export type toastSettings = { + message: string, + description?: string, + type: "confirmation"|"normal"|"error", + icon?: ReactNode +} +export type toastType = (settings: toastSettings) => void; export var ToastContext = createContext<{ toast?: toastType }>({}); var toasts: Array = []; export function ToastContextWrapper(props: { children?: ReactNode }) { var [dummyState, rerender] = useState(false); - return { - toasts.push(); + return { + toasts.push(); rerender(!dummyState); } }}> { props.children } -- cgit v1.2.3