mirror of
https://github.com/voltbonn/profile-picture-generator.git
synced 2024-12-23 00:05:09 +00:00
2 lines
No EOL
5.8 KiB
JavaScript
2 lines
No EOL
5.8 KiB
JavaScript
(this["webpackJsonpprofile-picture-generator"]=this["webpackJsonpprofile-picture-generator"]||[]).push([[0],{20:function(e,t,a){},24:function(e,t,a){var r={"./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(!a.o(r,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=r[e],n=t[0];return a.e(t[1]).then((function(){return a(n)}))}n.keys=function(){return Object.keys(r)},n.id=24,e.exports=n},25:function(e,t,a){"use strict";a.r(t);var r=a(1),n=a(0),c=a.n(n),o=a(11),i=a.n(o),s=a(10),l=a(9),u=a(3),f=(a(20),a(14)),h=a(5),b=a.n(h),d=a(8);var j=function(e){var t=e.onFrameChange,c=Object(n.useState)([]),o=Object(u.a)(c,2),i=o[0],s=o[1],l=Object(n.useState)(null),f=Object(u.a)(l,2),h=f[0],j=f[1];Object(n.useEffect)((function(){function e(){return(e=Object(d.a)(b.a.mark((function e(){return b.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(d.a)(b.a.mark((function e(t){return b.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,a(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){s(e),j(e[0].src.default)}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[]);var g=Object(n.useCallback)((function(e){j(e.target.dataset.src)}),[j]);return Object(n.useEffect)((function(){t(h)}),[t,h]),Object(r.jsxs)("div",{className:"FrameChooser",children:[Object(r.jsx)("h2",{children:"Choose a frame:"}),i.map((function(e){var t=e.src.default,a=h===t;return Object(r.jsx)("img",{alt:e.name,"data-src":t,src:t,className:a?"frame choosen":"frame",onClick:g},t)}))]})},g=a.p+"static/media/HeaderImage.1f39a672.svg",m=a(13),p=1080;var O=function(){var e=Object(n.useState)(null),t=Object(u.a)(e,2),a=t[0],c=t[1],o=Object(n.useState)(null),i=Object(u.a)(o,2),h=i[0],b=i[1],d=Object(n.useState)(null),O=Object(u.a)(d,2),v=O[0],P=O[1],F=Object(n.useState)(null),w=Object(u.a)(F,2),x=w[0],B=w[1],k=Object(n.useCallback)((function(e){c(e)}),[c]),y=Object(n.useCallback)((function(e){if(e){var t=new FileReader;t.onload=function(t){var a=new Image;a.onload=function(){var t=document.createElement("canvas");t.width=p,t.height=p;var r,n,c=t.getContext("2d",{alpha:!0});a.width<a.height?(n=a.height/a.width*p,r=p):(n=p,r=a.width/a.height*p),function(e,t){var a=new FileReader;a.onload=function(e){var a=new DataView(e.target.result);if(65496!==a.getUint16(0,!1))return t(-2);for(var r=a.byteLength,n=2;n<r;){var c=a.getUint16(n,!1);if(n+=2,65505===c){if(1165519206!==a.getUint32(n+=2,!1))return t(-1);var o=18761===a.getUint16(n+=6,!1);n+=a.getUint32(n+4,o);var i=a.getUint16(n,o);n+=2;for(var s=0;s<i;s++)if(274===a.getUint16(n+12*s,o))return t(a.getUint16(n+12*s+8,o))}else{if(65280!==(65280&c))break;n+=a.getUint16(n,!1)}}return t(-1)},a.readAsArrayBuffer(e.slice(0,65536))}(e,(function(e){switch(e){case 2:c.translate(t.width,0),c.scale(-1,1);break;case 3:c.translate(t.width,t.height),c.rotate(Math.PI);break;case 4:c.translate(0,t.height),c.scale(1,-1);break;case 5:c.rotate(.5*Math.PI),c.scale(1,-1);break;case 6:c.rotate(.5*Math.PI),c.translate(0,-t.height);break;case 7:c.rotate(.5*Math.PI),c.translate(t.width,-t.height),c.scale(-1,1);break;case 8:c.rotate(-.5*Math.PI),c.translate(-t.width,0)}c.drawImage(a,(p-r)/2,(p-n)/2,r,n);var o=t.toDataURL();P(o)}))},a.src=t.target.result,b(t.target.result)},t.readAsDataURL(e)}}),[]),C=Object(n.useCallback)((function(e){y(e.target.files[0])}),[y]),I=Object(n.useCallback)((function(e){y(e[0])}),[y]),U=Object(f.a)({onDrop:I,accept:"image/*",maxFiles:1,noKeyboard:!0}),D=U.isDragActive,M=U.getRootProps;return Object(n.useEffect)((function(){Object(m.a)([].concat(Object(l.a)(v?[v]:[]),Object(l.a)(a?[a]:[]))).then((function(e){return B(e)}))}),[v,a]),Object(r.jsxs)("div",Object(s.a)(Object(s.a)({className:"App"},M()),{},{children:[Object(r.jsx)("img",{src:g,className:"HeaderImage",alt:"Volt Logo"}),Object(r.jsx)("div",{className:D?"droparea active":"droparea",children:"Drop your photo here ..."}),Object(r.jsx)("h2",{children:"Choose your Photo:"}),Object(r.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(r.jsxs)("label",{className:"labelButton",tabIndex:"0",style:{outline:"none"},children:[v?Object(r.jsx)("img",{src:h,alt:"Preview"}):null,Object(r.jsx)("span",{children:v?"Change Photo":"Load Photo"}),Object(r.jsx)("input",{onChange:C,type:"file",accept:"image/*",style:{display:"none"}})]}),Object(r.jsx)(j,{onFrameChange:k}),Object(r.jsx)("h2",{children:"Download your Photo:"}),Object(r.jsx)("img",{src:x,className:"FinishedFrame",alt:"Finished Frame"}),Object(r.jsx)("a",{download:"volt-profile-picture.png",href:x,target:"_blank",rel:"noreferrer",children:Object(r.jsx)("button",{children:"Download Profile Picture"})})]}))},v=function(e){e&&e instanceof Function&&a.e(3).then(a.bind(null,35)).then((function(t){var a=t.getCLS,r=t.getFID,n=t.getFCP,c=t.getLCP,o=t.getTTFB;a(e),r(e),n(e),c(e),o(e)}))};i.a.render(Object(r.jsx)(c.a.StrictMode,{children:Object(r.jsx)(O,{})}),document.getElementById("root")),v()}},[[25,1,2]]]);
|
|
//# sourceMappingURL=main.67e708c3.chunk.js.map
|