From 6211dd8ac9d1a614c29a007d6136cbf801c07e95 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 20 Apr 2023 10:01:25 -0500 Subject: [PATCH] toaster --- src/components/Toaster.tsx | 55 ++++++++++++++++++++++++++++++++++++++ src/root.tsx | 2 ++ 2 files changed, 57 insertions(+) create mode 100644 src/components/Toaster.tsx diff --git a/src/components/Toaster.tsx b/src/components/Toaster.tsx new file mode 100644 index 0000000..7a95aed --- /dev/null +++ b/src/components/Toaster.tsx @@ -0,0 +1,55 @@ +import { Toast, toaster } from "@kobalte/core"; +import { Portal } from "solid-js/web"; +import close from "~/assets/icons/close.svg"; +import { SmallHeader } from "./layout"; + +export function Toaster() { + return ( + + + + + + ) +} + +type ToastArg = { title: string, description: string } | Error + +export function showToast(arg: ToastArg) { + if (arg instanceof Error) { + return toaster.show(props => ( + + )) + } else { + return toaster.show(props => ( + + )) + } +} + +export function ToastItem(props: { toastId: number, title: string, description: string, isError?: boolean }) { + return ( + +
+
+ + + {props.title} + + + +

+ {props.description} +

+
+
+ + Close + +
+ {/* + + */} +
+ ) +} \ No newline at end of file diff --git a/src/root.tsx b/src/root.tsx index a71b60a..a592b6b 100644 --- a/src/root.tsx +++ b/src/root.tsx @@ -14,6 +14,7 @@ import { } from "solid-start"; import "./root.css"; import { Provider as MegaStoreProvider } from "~/state/megaStore"; +import { Toaster } from "~/components/Toaster"; export default function Root() { return ( @@ -39,6 +40,7 @@ export default function Root() { +