notification
aomi/notificationFreeComponent
Notification toaster wired to the runtime notification store.
Install it
npx shadcn@latest add https://aomi.dev/r/notification.jsonSource
1"use client";23import { useEffect, useRef } from "react";4import { toast } from "sonner";56import { useNotification } from "@aomi-labs/react";7import type { Notification } from "@aomi-labs/react";89import { NotificationIcon } from "./notification-icon";10import { Toaster } from "./sonner";1112export function NotificationToaster() {13 const { notifications, dismissNotification } = useNotification();14 const shownRef = useRef<Set<string>>(new Set());1516 useEffect(() => {17 const activeIds = new Set(18 notifications.map((notification) => notification.id),19 );20 for (const id of shownRef.current) {21 if (!activeIds.has(id)) {22 shownRef.current.delete(id);23 }24 }2526 for (const notification of notifications) {27 if (notification.kind === "payment_required") continue;28 if (shownRef.current.has(notification.id)) continue;29 shownRef.current.add(notification.id);30 showToast(notification, dismissNotification);31 }32 }, [notifications, dismissNotification]);3334 return (35 <Toaster36 position="top-right"37 offset={{ top: 72, right: 16 }}38 mobileOffset={{ top: 68, right: 16, left: 16 }}39 />40 );41}4243function showToast(44 notification: Notification,45 dismissNotification: (id: string) => void,46) {47 const options = {48 id: notification.id,49 duration: notification.duration ?? 6000,50 unstyled: true,51 onDismiss: () => dismissNotification(notification.id),52 onAutoClose: () => dismissNotification(notification.id),53 };5455 toast.custom(56 () => (57 <div className="border-aomi-border bg-aomi-surface-2 text-aomi-fg group relative flex w-[22rem] max-w-[calc(100vw-2rem)] items-start gap-2.5 rounded-2xl border p-3.5 shadow-2xl">58 <NotificationIcon type={notification.type} />59 <div className="min-w-0 flex-1 pt-0.5 text-left">60 <div className="pr-7 text-sm font-semibold leading-5">61 {notification.title}62 </div>63 {notification.message &&64 notification.message !== notification.title && (65 <div className="text-aomi-muted mt-0.5 pr-7 text-sm leading-5">66 {notification.message}67 </div>68 )}69 </div>70 <button71 type="button"72 aria-label="Close notification"73// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from aomi
All 34 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | aomi | Components | Free | 2 deps | |
| alertalert | aomi | Components | Free | 1 dep | |
| aomi-frameaomi-frame | aomi | Components | Free | 1 dep | |
| aomi-para-provideraomi-para-provider | aomi | Components | Free | 9 deps · 27 files | |
| aomi-privy-provideraomi-privy-provider | aomi | Components | Free | 7 deps · 15 files | |
| aomi-wallet-kitaomi-wallet-kit | aomi | Components | Free | 8 deps · 59 files | |
| aomi-widgetaomi-widget | aomi | Components | Free | 2 deps | |
| assistant-threadassistant-thread | aomi | Components | Free | 6 deps · 23 files |
