@cerberus-design/react
Version:
The Cerberus Design React component library.
70 lines (68 loc) • 1.85 kB
JavaScript
import {
MatchNotificationIcon
} from "./chunk-JHCKXQEK.js";
import {
ToastCloseTrigger
} from "./chunk-JVAGLLOA.js";
import {
NotificationParts
} from "./chunk-L4KBNOWP.js";
import {
Button
} from "./chunk-JIEN2PM7.js";
import {
Show
} from "./chunk-NUXMADXV.js";
// src/components/notifications/center.tsx
import {
createToaster,
Toaster
} from "@ark-ui/react/toast";
import { Box } from "styled-system/jsx";
import { jsx, jsxs } from "react/jsx-runtime";
var toaster = createToaster({
gap: 16,
overlap: true,
placement: "top-end"
});
function NotificationCenter() {
return /* @__PURE__ */ jsx(Toaster, { toaster, children: (toast) => /* @__PURE__ */ jsxs(NotificationParts.Root, { children: [
/* @__PURE__ */ jsx(
MatchNotificationIcon,
{
type: toast.type
}
),
/* @__PURE__ */ jsxs(Box, { flex: "1", paddingBlock: "sm", children: [
/* @__PURE__ */ jsx(NotificationParts.Heading, { children: toast.title }),
/* @__PURE__ */ jsx(NotificationParts.Description, { children: toast.description }),
/* @__PURE__ */ jsx(Show, { when: toast.action, children: /* @__PURE__ */ jsx(NotificationParts.ActionTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
Button,
{
palette: toast.type,
usage: "ghost",
size: "sm",
children: toast.action?.label
}
) }) })
] }),
/* @__PURE__ */ jsx(ToastCloseTrigger, {})
] }, toast.id) });
}
function useNotificationCenter() {
function notify(options) {
toaster.create({
title: options.heading,
description: options.description,
type: options.palette,
action: options.action
});
}
return { ...toaster, notify };
}
export {
toaster,
NotificationCenter,
useNotificationCenter
};
//# sourceMappingURL=chunk-LY6ULD43.js.map