Files
quote-machine/static/js/main.52e24b25.chunk.js
T
2021-01-25 15:28:11 +03:00

2 lines
3.5 KiB
JavaScript

(this["webpackJsonpquote-machine"]=this["webpackJsonpquote-machine"]||[]).push([[0],{17:function(t,e,n){},18:function(t,e,n){},21:function(t,e,n){},22:function(t,e,n){"use strict";n.r(e);var a=n(1),r=n(0),s=n.n(r),c=n(9),i=n.n(c),o=(n(17),n(2)),u=n(3),h=n(5),d=n(4),l=(n(18),n(7)),f=n.n(l),b=n(10),j=n(11),p=(n(20),function(t){return Object(a.jsx)(j.a,{variant:t.variant,href:t.href,target:t.target,onClick:t.click,children:t.text})}),x=(n(21),function(t){Object(h.a)(n,t);var e=Object(d.a)(n);function n(t){var a;return Object(o.a)(this,n),(a=e.call(this,t)).random=function(){return Math.floor(1600*Math.random())},a.random2=function(){return Math.floor(4*Math.random())},a.handleChange=function(){var t=a.random();a.setState({displayQuote:a.state.quotes[t].text,displayAuthor:a.state.quotes[t].author}),a.props.handler(a.state.backGroundApp[a.random2()])},a.state={quotes:null,displayQuote:null,displayAuthor:null,color:["#264653","#2a9d8f","#e76f51","#e63946","#bc6c25"],backGroundApp:["#ffadad","#ffd6a5","#caffbf","#9bf6ff","#a0c4ff","#ffc6ff"]},a}return Object(u.a)(n,[{key:"componentDidMount",value:function(){var t=Object(b.a)(f.a.mark((function t(){var e,n,a;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch("https://type.fit/api/quotes");case 2:return e=t.sent,t.next=5,e.json();case 5:n=t.sent,this.setState({quotes:n}),a=this.random(),this.setState({displayQuote:this.state.quotes[a].text,displayAuthor:this.state.quotes[a].author});case 9:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}()},{key:"render",value:function(){return this.state.quotes?Object(a.jsx)("div",{className:"wrapper",children:Object(a.jsxs)("div",{id:"quote-box",style:{transition:"background-color 0.3s ease",backgroundColor:this.state.color[this.random2()]},children:[Object(a.jsxs)("div",{className:"writing",children:[Object(a.jsx)("h3",{id:"text",children:this.state.displayQuote}),Object(a.jsx)("p",{id:"author",children:this.state.displayAuthor})]}),Object(a.jsx)("div",{id:"new-quote",children:Object(a.jsx)(p,{click:this.handleChange,text:"New Quote",variant:"success"})}),Object(a.jsx)("div",{id:"tweet",children:Object(a.jsx)(p,{href:"https://twitter.com/intent/tweet?text=".concat(this.state.displayQuote," \n \n ").concat(this.state.displayAuthor),target:"_blank",text:Object(a.jsx)("a",{id:"tweet-quote",target:"_blank",rel:"noreferrer",href:"https://twitter.com/intent/tweet?text=".concat(this.state.displayQuote," \n \n ").concat(this.state.displayAuthor),children:"Tweet"}),variant:"primary"})})]})}):Object(a.jsx)("div",{children:Object(a.jsx)("h1",{style:{textAlign:"center"},children:"Loading..."})})}}]),n}(s.a.Component)),O=function(t){Object(h.a)(n,t);var e=Object(d.a)(n);function n(){var t;return Object(o.a)(this,n),(t=e.call(this)).bgChange=function(e){t.setState({backG:e})},t.state={backG:"#2a9d8f"},t}return Object(u.a)(n,[{key:"render",value:function(){return Object(a.jsx)("div",{className:"App",style:{transition:"background-color 0.3s ease",backgroundColor:this.state.backG},children:Object(a.jsx)(x,{id:"quote",handler:this.bgChange})})}}]),n}(r.Component),v=function(t){t&&t instanceof Function&&n.e(3).then(n.bind(null,23)).then((function(e){var n=e.getCLS,a=e.getFID,r=e.getFCP,s=e.getLCP,c=e.getTTFB;n(t),a(t),r(t),s(t),c(t)}))};i.a.render(Object(a.jsx)(s.a.StrictMode,{children:Object(a.jsx)(O,{})}),document.getElementById("root")),v()}},[[22,1,2]]]);
//# sourceMappingURL=main.52e24b25.chunk.js.map