1
0
Fork 0
mirror of https://github.com/voltbonn/profile-picture-generator.git synced 2024-12-23 00:05:09 +00:00
profile.volt.link/static/js/main.8c2fdff3.chunk.js
2021-01-21 22:03:42 +00:00

2 lines
No EOL
4.8 KiB
JavaScript

(this["webpackJsonpprofile-picture-generator"]=this["webpackJsonpprofile-picture-generator"]||[]).push([[0],{20:function(e,t,r){},24:function(e,t,r){var a={"./ProfileFrame B&G Bars.png":[26,4],"./ProfileFrame Blue Bars.png":[27,5],"./ProfileFrame Green Bars.png":[28,6],"./ProfileFrame Mixed Bars.png":[29,7],"./ProfileFrame Purple.png":[30,8],"./ProfileFrame R&Y Bars.png":[31,9],"./ProfileFrame Red Bars.png":[32,10],"./ProfileFrame White Bars.png":[33,11],"./ProfileFrame Yellow Bars.png":[34,12]};function n(e){if(!r.o(a,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=a[e],n=t[0];return r.e(t[1]).then((function(){return r(n)}))}n.keys=function(){return Object.keys(a)},n.id=24,e.exports=n},25:function(e,t,r){"use strict";r.r(t);var a=r(1),n=r(0),c=r.n(n),o=r(11),s=r.n(o),i=r(10),l=r(9),u=r(3),f=(r(20),r(14)),j=r(5),h=r.n(j),b=r(8);var d=function(e){var t=e.onFrameChange,c=Object(n.useState)([]),o=Object(u.a)(c,2),s=o[0],i=o[1],l=Object(n.useState)(null),f=Object(u.a)(l,2),j=f[0],d=f[1];Object(n.useEffect)((function(){function e(){return(e=Object(b.a)(h.a.mark((function e(){return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Promise.all(["ProfileFrame Purple","ProfileFrame Yellow Bars","ProfileFrame Red Bars","ProfileFrame Blue Bars","ProfileFrame Green Bars","ProfileFrame White Bars","ProfileFrame Mixed Bars","ProfileFrame R&Y Bars","ProfileFrame B&G Bars"].map(function(){var e=Object(b.a)(h.a.mark((function e(t){return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,r(24)("./".concat(t,".png"));case 3:return e.t1=e.sent,e.abrupt("return",{name:e.t0,src:e.t1});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())).then((function(e){i(e),d(e[0].src.default)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[]);var m=Object(n.useCallback)((function(e){d(e.target.dataset.src)}),[d]);return Object(n.useEffect)((function(){t(j)}),[t,j]),Object(a.jsxs)("div",{className:"FrameChooser",children:[Object(a.jsx)("h2",{children:"Choose a frame:"}),s.map((function(e){var t=e.src.default,r=j===t;return Object(a.jsx)("img",{alt:e.name,"data-src":t,src:t,className:r?"frame choosen":"frame",onClick:m},t)}))]})},m=r.p+"static/media/HeaderImage.1f39a672.svg",p=r(13),O=1080;var g=function(){var e=Object(n.useState)(null),t=Object(u.a)(e,2),r=t[0],c=t[1],o=Object(n.useState)(null),s=Object(u.a)(o,2),j=s[0],h=s[1],b=Object(n.useState)(null),g=Object(u.a)(b,2),v=g[0],F=g[1],P=Object(n.useState)(null),x=Object(u.a)(P,2),B=x[0],w=x[1],C=Object(n.useCallback)((function(e){c(e)}),[c]),y=Object(n.useCallback)((function(e){if(e){var t=new FileReader;t.onload=function(e){var t=new Image;t.onload=function(){var e=document.createElement("canvas");e.width=O,e.height=O;var r,a,n=e.getContext("2d",{alpha:!0});t.width<t.height?(a=t.height/t.width*O,r=O):(a=O,r=t.width/t.height*O),n.drawImage(t,(O-r)/2,(O-a)/2,r,a);var c=e.toDataURL();F(c)},t.src=e.target.result,h(e.target.result)},t.readAsDataURL(e)}}),[]),k=Object(n.useCallback)((function(e){y(e.target.files[0])}),[y]),D=Object(n.useCallback)((function(e){y(e[0])}),[y]),N=Object(f.a)({onDrop:D,accept:"image/*",maxFiles:1,noKeyboard:!0}),I=N.isDragActive,R=N.getRootProps;return Object(n.useEffect)((function(){Object(p.a)([].concat(Object(l.a)(v?[v]:[]),Object(l.a)(r?[r]:[]))).then((function(e){return w(e)}))}),[v,r]),Object(a.jsxs)("div",Object(i.a)(Object(i.a)({className:"App"},R()),{},{children:[Object(a.jsx)("img",{src:m,className:"HeaderImage",alt:"Volt Logo"}),Object(a.jsx)("div",{className:I?"droparea active":"droparea",children:"Drop your photo here ..."}),Object(a.jsx)("h2",{children:"Choose your Photo:"}),Object(a.jsx)("p",{children:"It should best be a square image or your face in the middle. The photo is not saved and never leaves your computer."}),Object(a.jsxs)("label",{className:"labelButton",tabIndex:"0",style:{outline:"none"},children:[v?Object(a.jsx)("img",{src:j,alt:"Preview"}):null,Object(a.jsx)("span",{children:v?"Change Photo":"Load Photo"}),Object(a.jsx)("input",{onChange:k,type:"file",accept:"image/*",style:{display:"none"}})]}),Object(a.jsx)(d,{onFrameChange:C}),Object(a.jsx)("h2",{children:"Download your Photo:"}),Object(a.jsx)("img",{src:B,className:"FinishedFrame",alt:"Finished Frame"}),Object(a.jsx)("a",{download:"volt-profile-picture.png",href:B,target:"_blank",rel:"noreferrer",children:Object(a.jsx)("button",{children:"Download Profile Picture"})})]}))},v=function(e){e&&e instanceof Function&&r.e(3).then(r.bind(null,35)).then((function(t){var r=t.getCLS,a=t.getFID,n=t.getFCP,c=t.getLCP,o=t.getTTFB;r(e),a(e),n(e),c(e),o(e)}))};s.a.render(Object(a.jsx)(c.a.StrictMode,{children:Object(a.jsx)(g,{})}),document.getElementById("root")),v()}},[[25,1,2]]]);
//# sourceMappingURL=main.8c2fdff3.chunk.js.map