mirror of
https://github.com/voltbonn/profile-picture-generator.git
synced 2024-12-23 00:05:09 +00:00
2 lines
No EOL
4.5 KiB
JavaScript
2 lines
No EOL
4.5 KiB
JavaScript
(this["webpackJsonpprofile-picture-generator"]=this["webpackJsonpprofile-picture-generator"]||[]).push([[0],{17:function(e,t,r){},19:function(e,t,r){var a={"./ProfileFrame B&G Bars.png":[21,4],"./ProfileFrame Blue Bars.png":[22,5],"./ProfileFrame Green Bars.png":[23,6],"./ProfileFrame Mixed Bars.png":[24,7],"./ProfileFrame Purple.png":[25,8],"./ProfileFrame R&Y Bars.png":[26,9],"./ProfileFrame Red Bars.png":[27,10],"./ProfileFrame White Bars.png":[28,11],"./ProfileFrame Yellow Bars.png":[29,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=19,e.exports=n},20:function(e,t,r){"use strict";r.r(t);var a=r(0),n=r(1),c=r.n(n),o=r(9),s=r.n(o),i=r(8),l=r(2),u=(r(17),r(10)),f=r.n(u),h=r(4),d=r.n(h),m=r(7);var j=function(e){var t=e.onFrameChange,c=Object(n.useState)([]),o=Object(l.a)(c,2),s=o[0],i=o[1],u=Object(n.useState)(null),f=Object(l.a)(u,2),h=f[0],j=f[1];Object(n.useEffect)((function(){function e(){return(e=Object(m.a)(d.a.mark((function e(){return d.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(m.a)(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,r(19)("./".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){console.log(e),i(e),j(e[0].src.default)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[]);var b=Object(n.useCallback)((function(e){j(e.target.dataset.src)}),[j]);return Object(n.useEffect)((function(){t(h)}),[t,h]),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=h===t;return Object(a.jsx)("img",{alt:e.name,"data-src":t,src:t,className:r?"frame choosen":"frame",onClick:b},t)}))]})},b=r.p+"static/media/HeaderImage.f98423dd.svg",p=r(11),g=1080;var O=function(){var e=Object(n.useState)(null),t=Object(l.a)(e,2),r=t[0],c=t[1],o=Object(n.useState)(null),s=Object(l.a)(o,2),u=s[0],h=s[1],d=Object(n.useState)(null),m=Object(l.a)(d,2),O=m[0],F=m[1],P=Object(n.useState)(null),v=Object(l.a)(P,2),x=v[0],B=v[1],w=Object(n.useCallback)((function(e){c(e)}),[c]),C=Object(n.useCallback)((function(e){var t=new FileReader;t.onload=function(e){var t=new Image;t.onload=function(){var e=document.createElement("canvas");e.width=g,e.height=g;var r,a,n=e.getContext("2d",{alpha:!0});t.width<t.height?(a=t.height/t.width*g,r=g):(a=g,r=t.width/t.height*g),n.drawImage(t,(g-r)/2,(g-a)/2,r,a);var c=e.toDataURL();F(c)},t.src=e.target.result,h(e.target.result)},t.readAsDataURL(e.target.files[0])}),[F]);return Object(n.useEffect)((function(){Object(p.a)([].concat(Object(i.a)(O?[O]:[]),Object(i.a)(r?[r]:[]))).then((function(e){return B(e)}))}),[O,r]),Object(a.jsxs)("div",{className:"App",children:[Object(a.jsx)("img",{src:b,className:"HeaderImage",alt:"Volt Logo"}),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:[O?Object(a.jsx)("img",{src:u,alt:"Preview"}):null,Object(a.jsx)("span",{children:O?"Change Photo":"Load Photo"}),Object(a.jsx)("input",{onChange:C,type:"file",accept:"image/*",style:{display:"none"}})]}),Object(a.jsx)(j,{onFrameChange:w}),Object(a.jsx)("h2",{children:"Download your Photo:"}),Object(a.jsx)("img",{src:x,className:"FinishedFrame",alt:"Finished Frame"}),Object(a.jsx)("button",{onClick:function(){return f()(x,"volt-profile-picture.png","image/png")},children:"Download Profile Picture"})]})},F=function(e){e&&e instanceof Function&&r.e(3).then(r.bind(null,30)).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)(O,{})}),document.getElementById("root")),F()}},[[20,1,2]]]);
|
|
//# sourceMappingURL=main.f98f9ce2.chunk.js.map
|