UNPKG

@codex-storage/marketplace-ui-components

Version:
48 lines (47 loc) 1.67 kB
import { jsxs as c, jsx as s } from "react/jsx-runtime"; import * as m from "react"; import { useState as d, useRef as p, useEffect as h } from "react"; import { attributes as w } from "../utils/attributes.js"; import { S } from "../../success-circle-CzSa4439.js"; import { S as v } from "../../close-BypPN932.js"; import '../../assets/Toast.css';const g = (t) => /* @__PURE__ */ m.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", "data-testid": "icon-error", viewBox: "0 0 16 16", ...t }, /* @__PURE__ */ m.createElement("path", { fill: "#FB3748", d: "M8 15.5a7.5 7.5 0 1 1 0-15 7.5 7.5 0 0 1 0 15m0-8.56L5.88 4.82 4.82 5.88 6.94 8l-2.12 2.12 1.06 1.06L8 9.06l2.12 2.12 1.06-1.06L9.06 8l2.12-2.12-1.06-1.06z" })); function j({ message: t, time: i, variant: e, className: u = "", duration: n = 3e3 }) { const [l, o] = d(t), r = p(null); h(() => { r.current && clearTimeout(r.current), o(t), t && (r.current = window.setTimeout(() => o(""), n)); }, [t, i, n]); const f = () => { r.current && clearTimeout(r.current), o(""); }, a = { success: S, error: g }[e]; return /* @__PURE__ */ c( "div", { className: `toast ${u} toast--${e}`, ...w({ "aria-hidden": i == 0 || l === "" }), children: [ /* @__PURE__ */ s(a, { width: 24 }), /* @__PURE__ */ c("div", { children: [ /* @__PURE__ */ c("b", { children: [ e, " ! " ] }), /* @__PURE__ */ s("span", { children: l }) ] }), /* @__PURE__ */ s(v, { width: 24, onClick: f }) ] } ); } export { j as Toast }; //# sourceMappingURL=Toast.js.map