UNPKG

simple-ad-component

Version:

10 lines (9 loc) 2.03 kB
(function(r,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],i):(r=typeof globalThis<"u"?globalThis:r||self,i(r.SimpleAdComponent=r.SimpleAdComponent||{},r.React))})(this,function(r,i){"use strict";var a={exports:{}},f={};/** * @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 m=i,_=Symbol.for("react.element"),x=Symbol.for("react.fragment"),v=Object.prototype.hasOwnProperty,b=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function y(s,t,u){var e,n={},d=null,o=null;u!==void 0&&(d=""+u),t.key!==void 0&&(d=""+t.key),t.ref!==void 0&&(o=t.ref);for(e in t)v.call(t,e)&&!h.hasOwnProperty(e)&&(n[e]=t[e]);if(s&&s.defaultProps)for(e in t=s.defaultProps,t)n[e]===void 0&&(n[e]=t[e]);return{$$typeof:_,type:s,key:d,ref:o,props:n,_owner:b.current}}f.Fragment=x,f.jsx=y,f.jsxs=y,a.exports=f;var p=a.exports;const j=({imageUrl:s,targetUrl:t,altText:u="Advertisement",width:e="auto",height:n=250,className:d="",onImpression:o,onClick:c})=>{i.useEffect(()=>{o==null||o()},[o]);const O=l=>{c==null||c(),window.open(t,"_blank","noopener,noreferrer")};return p.jsx("div",{className:d,style:{display:"inline-block",overflow:"hidden",width:typeof e=="number"?`${e}px`:e,height:typeof n=="number"?`${n}px`:n},children:p.jsx("button",{onClick:O,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:p.jsx("img",{src:s,alt:u,style:{width:"100%",height:"100%",objectFit:"cover"},loading:"lazy"})})})};r.Ad=j,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});