UNPKG

simple-ad-component

Version:

88 lines (87 loc) 2.53 kB
import y, { useEffect as _ } from "react"; var d = { exports: {} }, u = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var x = y, m = Symbol.for("react.element"), v = Symbol.for("react.fragment"), b = Object.prototype.hasOwnProperty, h = x.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 }; function c(n, r, i) { var e, t = {}, s = null, o = null; i !== void 0 && (s = "" + i), r.key !== void 0 && (s = "" + r.key), r.ref !== void 0 && (o = r.ref); for (e in r) b.call(r, e) && !j.hasOwnProperty(e) && (t[e] = r[e]); if (n && n.defaultProps) for (e in r = n.defaultProps, r) t[e] === void 0 && (t[e] = r[e]); return { $$typeof: m, type: n, key: s, ref: o, props: t, _owner: h.current }; } u.Fragment = v; u.jsx = c; u.jsxs = c; d.exports = u; var f = d.exports; const g = ({ imageUrl: n, targetUrl: r, altText: i = "Advertisement", width: e = "auto", height: t = 250, className: s = "", onImpression: o, onClick: a }) => { _(() => { o == null || o(); }, [o]); const p = (l) => { a == null || a(), window.open(r, "_blank", "noopener,noreferrer"); }; return /* @__PURE__ */ f.jsx( "div", { className: s, style: { display: "inline-block", overflow: "hidden", width: typeof e == "number" ? `${e}px` : e, height: typeof t == "number" ? `${t}px` : t }, children: /* @__PURE__ */ f.jsx( "button", { onClick: p, style: { width: "100%", height: "100%", padding: 0, border: "none", cursor: "pointer", background: "none", transition: "transform 0.2s ease-in-out", objectFit: "contain" }, onMouseOver: (l) => l.currentTarget.style.transform = "scale(1.02)", onMouseOut: (l) => l.currentTarget.style.transform = "scale(1)", children: /* @__PURE__ */ f.jsx( "img", { src: n, alt: i, style: { width: "100%", height: "100%", objectFit: "cover" }, loading: "lazy" } ) } ) } ); }; export { g as Ad };