UNPKG

instant-photo

Version:

<img src="./images/example-46mm.png" alt="Example screenshot" width="20%"/>

34 lines (29 loc) 3.25 kB
var C=Object.defineProperty;var c=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var f=(t,o,e)=>o in t?C(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,i=(t,o)=>{for(var e in o||(o={}))w.call(o,e)&&f(t,e,o[e]);if(c)for(var e of c(o))v.call(o,e)&&f(t,e,o[e]);return t};import s,{useMemo as a}from"react";var u="e64fc67ad4d5d5df57b105932ebcc5a25aad4b54a430d262372e0701b3896485",q=`._photo_1hekq_1 { box-shadow: inset 0 0 2px #000000; position: absolute; border-radius: 1px; } ._photoFilter_1hekq_7 { background-image: url("https://imagedelivery.net/_c4jAFjxf-vVYrGvQV8G2A/847f481e-b6bf-43da-8ce6-39313c19b600/inlinelarge"); background-size: cover; opacity: 80%; } ._photoBackground_1hekq_13 { background-color: #2d3436; background-image: linear-gradient(315deg, #2d3436 0%, #000000 74%); } ._frame_1hekq_18 { opacity: 1; background-image: url("https://www.transparenttextures.com/patterns/absurdity.png"), linear-gradient(#f0f0f0, ghostwhite); background-color: #f0f0f0; box-shadow: 0 0.2rem 1.2rem rgba(0, 0, 0, 0.2); position: relative; border-radius: 2px; } ._footer_1hekq_28 { position: absolute; bottom: 0; left: 0; } `;(function(){if(!document.getElementById(u)){var t=document.createElement("style");t.id=u,t.textContent=q,document.head.appendChild(t)}})();var r={photo:"_photo_1hekq_1",photoFilter:"_photoFilter_1hekq_7",photoBackground:"_photoBackground_1hekq_13",frame:"_frame_1hekq_18",footer:"_footer_1hekq_28"};var _={"46mm":{small:{photo:{margin:"12px 18px 60px",top:"15px",width:"207px",height:"288px"},frame:{width:"243px",height:"378px",minWidth:"243px",minWeight:"378px"}},large:{photo:{margin:"16px 24px 80px",top:"20px",width:"276px",height:"384px"},frame:{width:"324px",height:"504px",minWidth:"324px",minWeight:"504px"}}},"99mm":{small:{photo:{margin:"12px 18px 60px",position:"absolute",top:"15px",width:"445.5px",height:"288px"},frame:{width:"486px",height:"378px",minWidth:"486px",minHeight:"378px"}},large:{photo:{margin:"16px 24px 80px",position:"absolute",top:"20px",width:"594px",height:"384px"},frame:{width:"648px",height:"504px",minWidth:"648px",minHeight:"504px"}}}};var b={polaroid:"contrast(250%) brightness(90%) grayscale(70%)",vintage:"contrast(180%) brightness(70%) grayscale(20%) sepia(90%)",bloom:"contrast(200%) brightness(80%) grayscale(20%) ",greyscale:"contrast(190%) brightness(70%) grayscale(100%)",none:void 0};var F=({image:t,alt:o,variant:e,size:m,rotation:p,style:n,photoStyle:S,footer:d,filter:l,showArtefacts:k,key:y})=>{let g=a(()=>_[e][m],[e,m]),P=a(()=>i(i({transform:`rotate(${p}deg)`},g.frame),n),[n,p]),h=a(()=>i(i({filter:b[l]},g.photo),S),[n,p]),x=a(()=>`${r.photo} ${r.photoBackground}`,[]);return s.createElement("div",{style:P,className:`${r.frame} ${r.frame}`},t?s.createElement("img",{key:y,style:h,className:x,src:t,alt:o}):s.createElement("div",{style:h,className:x}),d&&s.createElement("div",{className:r.footer},d),l!=="none"&&k&&s.createElement("div",{style:h,className:`${r.photo} ${r.photoFilter}`}))};F.defaultProps={variant:"46mm",size:"large",alt:"instant photo",style:{},photoStyle:{},rotation:0,filter:"polaroid",showArtefacts:!0};export{F as InstantPhoto};