UNPKG

simple-ad-component

Version:

10 lines (9 loc) 1.79 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react");var c={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 _=f,b=Symbol.for("react.element"),v=Symbol.for("react.fragment"),x=Object.prototype.hasOwnProperty,m=_.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,j={key:!0,ref:!0,__self:!0,__source:!0};function y(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)x.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:b,type:n,key:s,ref:o,props:t,_owner:m.current}}u.Fragment=v;u.jsx=y;u.jsxs=y;c.exports=u;var d=c.exports;const O=({imageUrl:n,targetUrl:r,altText:i="Advertisement",width:e="auto",height:t=250,className:s="",onImpression:o,onClick:a})=>{f.useEffect(()=>{o==null||o()},[o]);const p=l=>{a==null||a(),window.open(r,"_blank","noopener,noreferrer")};return d.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:d.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:d.jsx("img",{src:n,alt:i,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy"})})})};exports.Ad=O;