UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

24 lines (23 loc) 950 B
import { jsx as n } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import { useState as p, useRef as y, useEffect as N } from "../../../external/preact/hooks/dist/hooks.module.js"; import E from "classnames"; /* empty css */ function L(s) { const { backgroundUrl: a = "", className: c = "", classNameModifiers: m = [], src: l = "", alt: d = "", showOnError: f = !1 } = s, [i, o] = p(!1), r = y(null), u = () => { o(!0); }, g = () => { o(f); }, t = E( [c], "adyen-pe-image", { "adyen-pe-image--loaded": i }, ...m.map((e) => `adyen-pe-image--${e}`) ); return N(() => { const e = a ? new Image() : r.current; e && (e.src = a || l, e.onload = u), o(!!(e != null && e.complete)); }, []), a ? /* @__PURE__ */ n("div", { style: { backgroundUrl: a }, ...s, className: t }) : /* @__PURE__ */ n("img", { ...s, alt: d, ref: r, className: t, onError: g }); } export { L as default };