aboutsummaryrefslogtreecommitdiff
path: root/packages/web-util/src/components/ShowLocalNotification.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/web-util/src/components/ShowLocalNotification.tsx')
-rw-r--r--packages/web-util/src/components/ShowLocalNotification.tsx43
1 files changed, 43 insertions, 0 deletions
diff --git a/packages/web-util/src/components/ShowLocalNotification.tsx b/packages/web-util/src/components/ShowLocalNotification.tsx
new file mode 100644
index 000000000..cb947e536
--- /dev/null
+++ b/packages/web-util/src/components/ShowLocalNotification.tsx
@@ -0,0 +1,43 @@
+import { h, Fragment, VNode } from "preact";
+import { Attention } from "./Attention.js";
+import { Notification } from "../index.browser.js";
+// import { useSettings } from "../hooks/settings.js";
+
+export function ShowLocalNotification({ notification }: { notification?: Notification }): VNode {
+ if (!notification) return <Fragment />
+ switch (notification.message.type) {
+ case "error":
+ return <div class="relative">
+ <div class="fixed top-0 left-0 right-0 z-20 w-full p-4">
+ <Attention type="danger" title={notification.message.title} onClose={() => {
+ notification.remove()
+ }}>
+ {notification.message.description &&
+ <div class="mt-2 text-sm text-red-700">
+ {notification.message.description}
+ </div>
+ }
+ {/* <MaybeShowDebugInfo info={notification.message.debug} /> */}
+ </Attention>
+ </div>
+ </div>
+ case "info":
+ return <div class="relative">
+ <div class="fixed top-0 left-0 right-0 z-20 w-full p-4">
+ <Attention type="success" title={notification.message.title} onClose={() => {
+ notification.remove();
+ }} /></div></div>
+ }
+}
+
+
+// function MaybeShowDebugInfo({ info }: { info: any }): VNode {
+// const [settings] = useSettings()
+// if (settings.showDebugInfo) {
+// return <pre class="whitespace-break-spaces ">
+// {info}
+// </pre>
+// }
+// return <Fragment />
+// }
+