fcc-challenges/pomodoro-clock-react/build/static/js/main.157adc9f.chunk.js

2 lines
15 KiB
JavaScript

(this["webpackJsonppomodoro-clock-react"]=this["webpackJsonppomodoro-clock-react"]||[]).push([[0],{20:function(e,t,n){e.exports=n.p+"static/media/BeepSound.049fe0d0.ogg"},21:function(e,t,n){e.exports=n(34)},30:function(e,t,n){},34:function(e,t,n){"use strict";n.r(t);var o=n(0),i=n.n(o),r=n(13),s=n.n(r),a=n(4),c=n(11),h=function(e){return{type:"SETBREAKLENGTH",breakLength:e}},u=function(e){return{type:"SETSESSIONLENGTH",sessionLength:e}},l=function(e){return{type:"SETCLOCK",time:e}},p=Object(c.b)({innerWindowWidth:function(e,t){switch(e||(e=window.innerWidth),t.type){case"SETWINDOWINNERWIDTH":return t.windowInnerWidth;default:return e}},innerWindowHeight:function(e,t){switch(e||(e=window.innerHeight),t.type){case"SETWINDOWINNERHEIGHT":return t.windowInnerHeight;default:return e}},breakLength:function(e,t){switch(e||(e=5),t.type){case"SETBREAKLENGTH":return t.breakLength;default:return e}},sessionLength:function(e,t){switch(e||(e=25),t.type){case"SETSESSIONLENGTH":return t.sessionLength;default:return e}},timer:function(e,t){switch(e||(e="Session"),t.type){case"SETTIMER":return t.timer;default:return e}},clock:function(e,t){switch(e||(e="25:00"),t.type){case"SETCLOCK":return t.time;default:return e}},clockIsRunning:function(e,t){switch(e||(e=!1),t.type){case"SETCLOCKISRUNNING":return t.clockIsRunning;default:return e}},zeroTime:function(e,t){switch(e||(e=0),t.type){case"SETZEROTIME":return t.zeroTime;default:return e}}}),d=Object(c.c)(p),m=(n(30),n(5)),f=n(6),w=n(2),v=n(8),E=n(7),y=n(9),g="#0b3c5d",b="#328cc1",k="#d9b310",S="#1d2731",M=function(e){var t=e%60,n=Math.floor(e/60);return(n>9?n.toString():"0"+n.toString())+":"+(t>9?t.toString():"0"+t.toString())},A=n(10),C=n(3),O=function(e){Object(v.a)(n,e);var t=Object(E.a)(n);function n(e){var o;return Object(m.a)(this,n),(o=t.call(this,e)).handleDownArrowMouseEvent=o.handleDownArrowMouseEvent.bind(Object(w.a)(o)),o.handleUpArrowMouseEvent=o.handleUpArrowMouseEvent.bind(Object(w.a)(o)),o.incrementBreak=o.incrementBreak.bind(Object(w.a)(o)),o.decrementBreak=o.decrementBreak.bind(Object(w.a)(o)),o.state={downColor:S,upColor:S},o}return Object(f.a)(n,[{key:"incrementBreak",value:function(){if(this.props.breakLength<60){var e=this.props.breakLength+1;this.props.clockIsRunning?"Session"===this.props.timer&&this.props.breakLengthAction(e):(this.props.breakLengthAction(e),"Break"===this.props.timer&&this.props.clockAction(M(60*e)))}}},{key:"decrementBreak",value:function(){if(this.props.breakLength>1){var e=this.props.breakLength-1;this.props.clockIsRunning?"Session"===this.props.timer&&this.props.breakLengthAction(e):(this.props.breakLengthAction(e),"Break"===this.props.timer&&this.props.clockAction(M(60*e)))}}},{key:"handleDownArrowMouseEvent",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({downColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({downColor:S})}},{key:"handleUpArrowMouseEvent",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({upColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({upColor:S})}},{key:"render",value:function(){var e={color:this.state.downColor},t={color:this.state.upColor};return i.a.createElement("div",{style:{height:"50%",width:"75%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",marginRight:"25%",fontSize:32}},i.a.createElement("div",{id:"break-decrement",style:e,onClick:this.decrementBreak,onTouchStart:this.handleDownArrowMouseEvent,onTouchEnd:this.handleDownArrowMouseEvent,onMouseDown:this.handleDownArrowMouseEvent,onMouseUp:this.handleDownArrowMouseEvent},i.a.createElement(A.a,{icon:C.a})),i.a.createElement("p",{id:"break-length",style:{width:50}},this.props.breakLength),i.a.createElement("div",{id:"break-increment",style:t,onClick:this.incrementBreak,onTouchStart:this.handleUpArrowMouseEvent,onTouchEnd:this.handleUpArrowMouseEvent,onMouseDown:this.handleUpArrowMouseEvent,onMouseUp:this.handleUpArrowMouseEvent},i.a.createElement(A.a,{icon:C.b})))}}]),n}(i.a.Component),j=Object(a.b)((function(e){return Object(y.a)({},e)}),(function(e){return{breakLengthAction:function(t){return e(h(t))},clockAction:function(t){return e(l(t))}}}))(O),T=function(){var e={height:"50%",width:"90%",display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"right",marginRight:"10%",color:k};return i.a.createElement("div",{style:{height:"100%",width:"50%"}},i.a.createElement("div",{id:"break-label",style:e},"Break Length"),i.a.createElement(j,null))},I=function(e){Object(v.a)(n,e);var t=Object(E.a)(n);function n(e){var o;return Object(m.a)(this,n),(o=t.call(this,e)).handleDownArrowMouseEvent=o.handleDownArrowMouseEvent.bind(Object(w.a)(o)),o.handleUpArrowMouseEvent=o.handleUpArrowMouseEvent.bind(Object(w.a)(o)),o.incrementSession=o.incrementSession.bind(Object(w.a)(o)),o.decrementSession=o.decrementSession.bind(Object(w.a)(o)),o.state={downColor:S,upColor:S},o}return Object(f.a)(n,[{key:"incrementSession",value:function(){if(this.props.sessionLength<60){var e=this.props.sessionLength+1;this.props.clockIsRunning?"Break"===this.props.timer&&this.props.sessionLengthAction(e):(this.props.sessionLengthAction(e),"Session"===this.props.timer&&this.props.clockAction(M(60*e)))}}},{key:"decrementSession",value:function(){if(this.props.sessionLength>1){var e=this.props.sessionLength-1;this.props.clockIsRunning?"Break"===this.props.timer&&this.props.sessionLengthAction(e):(this.props.sessionLengthAction(e),"Session"===this.props.timer&&this.props.clockAction(M(60*e)))}}},{key:"handleDownArrowMouseEvent",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({downColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({downColor:S})}},{key:"handleUpArrowMouseEvent",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({upColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({upColor:S})}},{key:"render",value:function(){var e={color:this.state.downColor},t={color:this.state.upColor};return i.a.createElement("div",{style:{height:"50%",width:"75%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-start",marginLeft:"25%",fontSize:32}},i.a.createElement("div",{id:"session-decrement",style:e,onClick:this.decrementSession,onTouchStart:this.handleDownArrowMouseEvent,onTouchEnd:this.handleDownArrowMouseEvent,onMouseDown:this.handleDownArrowMouseEvent,onMouseUp:this.handleDownArrowMouseEvent},i.a.createElement(A.a,{icon:C.a})),i.a.createElement("p",{id:"session-length",style:{width:50}},this.props.sessionLength),i.a.createElement("div",{id:"session-increment",style:t,onClick:this.incrementSession,onTouchStart:this.handleUpArrowMouseEvent,onTouchEnd:this.handleUpArrowMouseEvent,onMouseDown:this.handleUpArrowMouseEvent,onMouseUp:this.handleUpArrowMouseEvent},i.a.createElement(A.a,{icon:C.b})))}}]),n}(i.a.Component),L=Object(a.b)((function(e){return Object(y.a)({},e)}),(function(e){return{sessionLengthAction:function(t){return e(u(t))},clockAction:function(t){return e(l(t))}}}))(I),R=function(){var e={height:"50%",width:"90%",display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"left",marginLeft:"10%",color:k};return i.a.createElement("div",{style:{height:"100%",width:"50%"}},i.a.createElement("div",{id:"session-label",style:e},"Session Length"),i.a.createElement(L,null))},D=function(){return i.a.createElement("div",{style:{height:"40%",width:"100%"}},i.a.createElement("div",{style:{height:"50%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",fontSize:48}},"Pomodoro Clock"),i.a.createElement("div",{style:{height:"50%",width:"100%",display:"flex"}},i.a.createElement(T,null),i.a.createElement(R,null)))},W=function(e){Object(v.a)(n,e);var t=Object(E.a)(n);function n(){return Object(m.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){var e={height:"30%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"flex-end",color:k};return i.a.createElement("div",{style:{height:"40%",width:"100%"}},i.a.createElement("div",{id:"timer-label",style:e},this.props.timer),i.a.createElement("div",{id:"time-left",style:{height:"70%",width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",fontSize:96}},this.props.clock))}}]),n}(i.a.Component),x=Object(a.b)((function(e){return Object(y.a)({},e)}))(W),z=n(20),U=n.n(z),N=function(e){Object(v.a)(n,e);var t=Object(E.a)(n);function n(e){var o;return Object(m.a)(this,n),(o=t.call(this,e)).handleMouseEventPlay=o.handleMouseEventPlay.bind(Object(w.a)(o)),o.handleMouseEventPause=o.handleMouseEventPause.bind(Object(w.a)(o)),o.handleMouseEventReset=o.handleMouseEventReset.bind(Object(w.a)(o)),o.handlePlay=o.handlePlay.bind(Object(w.a)(o)),o.handleReset=o.handleReset.bind(Object(w.a)(o)),o.state={playColor:S,pauseColor:S,resetColor:S,sound:""},o}return Object(f.a)(n,[{key:"handlePlay",value:function(){if(this.props.clockIsRunning)this.props.clockIsRunningAction(!1);else{this.props.clockIsRunningAction(!0);var e=new Date,t=Math.floor(e.getTime()/1e3),n=this.props.clock.split(":"),o=60*parseInt(n[0])+parseInt(n[1]);this.props.zeroTimeAction(t+o);var i=this,r=setInterval((function(){if(i.props.clockIsRunning){var e=new Date,t=Math.floor(e.getTime()/1e3);if(t<=i.props.zeroTime){var n=i.props.zeroTime-t,o=M(n);o!==i.props.clock&&i.props.clockAction(o)}else{var s=60*i.props.breakLength;"Session"===i.props.timer?i.props.timerAction("Break"):(i.props.timerAction("Session"),s=60*i.props.sessionLength),i.props.zeroTimeAction(t+s),i.props.clockAction(M(s))}}else clearInterval(r)}),1e3)}}},{key:"handleReset",value:function(){this.props.clockIsRunning&&this.props.clockIsRunningAction(!1),"Break"===this.props.timer&&this.props.timerAction("Session"),25!==this.props.sessionLength&&this.props.sessionLengthAction(25),5!==this.props.breakLength&&this.props.breakLengthAction(5),"25:00"!==this.props.clock&&this.props.clockAction("25:00"),this.state.sound.pause(),this.state.sound.currentTime=0}},{key:"componentDidUpdate",value:function(e){"00:00"===this.props.clock&&this.state.sound.play()}},{key:"handleMouseEventPlay",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({playColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({playColor:S})}},{key:"handleMouseEventPause",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({pauseColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({pauseColor:S})}},{key:"handleMouseEventReset",value:function(e){"mousedown"===e.type||"touchstart"===e.type?this.setState({resetColor:k}):"mouseup"!==e.type&&"touchend"!==e.type||this.setState({resetColor:S})}},{key:"componentDidMount",value:function(){this.setState({sound:document.getElementById("beep")})}},{key:"render",value:function(){var e=this,t={color:this.state.playColor},n={color:this.state.pauseColor,width:150},o={color:this.state.resetColor};return i.a.createElement("div",{style:{height:"20%",width:"100%",display:"flex",justifyContent:"center",alignItems:"center",fontSize:48}},i.a.createElement("div",{id:"start_stop",style:t,onClick:this.handlePlay,onMouseDown:this.handleMouseEventPlay,onMouseUp:this.handleMouseEventPlay,onTouchStart:this.handleMouseEventPlay,onTouchEnd:this.handleMouseEventPlay},i.a.createElement(A.a,{icon:C.d})),i.a.createElement(A.a,{style:n,onMouseDown:this.handleMouseEventPause,onMouseUp:this.handleMouseEventPause,onTouchStart:this.handleMouseEventPause,onTouchEnd:this.handleMouseEventPause,onClick:function(){e.props.clockIsRunningAction(!1)},icon:C.c}),i.a.createElement("div",{id:"reset",style:o,onClick:this.handleReset,onMouseDown:this.handleMouseEventReset,onMouseUp:this.handleMouseEventReset,onTouchStart:this.handleMouseEventReset,onTouchEnd:this.handleMouseEventReset},i.a.createElement(A.a,{icon:C.e})),i.a.createElement("audio",{id:"beep",preload:"auto",src:U.a,type:"audio/ogg"}))}}]),n}(i.a.Component),H=Object(a.b)((function(e){return Object(y.a)({},e)}),(function(e){return{clockIsRunningAction:function(t){return e(function(e){return{type:"SETCLOCKISRUNNING",clockIsRunning:e}}(t))},zeroTimeAction:function(t){return e(function(e){return{type:"SETZEROTIME",zeroTime:e}}(t))},clockAction:function(t){return e(l(t))},timerAction:function(t){return e(function(e){return{type:"SETTIMER",timer:e}}(t))},sessionLengthAction:function(t){return e(u(t))},breakLengthAction:function(t){return e(h(t))}}}))(N),B=function(e){Object(v.a)(n,e);var t=Object(E.a)(n);function n(){return Object(m.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){var e=this.props.innerWindowWidth,t=this.props.innerWindowHeight,n=Math.round(.8*e),o=Math.round(.8*t),r={margin:"auto",border:"3px solid",borderColor:S,zIndex:"1",backgroundColor:b,borderRadius:10,height:o<500?o:500,width:n<800?n:800,display:"flex",flexDirection:"column",justifyContent:"center",fontSize:32,userSelect:"none",MozUserSelect:"none",WebkitUserSelect:"none"},s={height:"100%",width:"100%"};return e>t&&t<400?(r.height="96vh",r.width="75vw",r.margin="1vh auto 3vh auto",r.fontSize=24):t>e&&(r.height=Math.round(.75*t),r.maxHeight=500,s.height=e>r.height?r.height:e,s.maxHeight=500,r.width=e-6,r.maxWidth=800,r.fontSize=24),i.a.createElement("div",{style:r},i.a.createElement("div",{style:s},i.a.createElement(D,null),i.a.createElement(x,null),i.a.createElement(H,null)))}}]),n}(i.a.Component),P=Object(a.b)((function(e){return Object(y.a)({},e)}))(B),G=function(e){Object(v.a)(n,e);var t=Object(E.a)(n);function n(e){var o;return Object(m.a)(this,n),(o=t.call(this,e)).handleResize=o.handleResize.bind(Object(w.a)(o)),o}return Object(f.a)(n,[{key:"handleResize",value:function(){this.props.innerWindowWidthAction(window.innerWidth),this.props.innerWindowHeightAction(window.innerHeight)}},{key:"componentDidMount",value:function(){window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize)}},{key:"render",value:function(){var e=this.props.innerWindowHeight,t=this.props.innerWindowWidth,n={backgroundColor:g,border:"none",width:149,height:0,position:"absolute",right:0},o={position:"absolute",right:0,height:149,width:149},r={textAlign:"center",backgroundColor:g,height:"100vh",width:"100vw",display:"flex",flexDirection:"column",color:S,overFlow:"hidden",fontFamily:"Ubuntu sans-serif",fontSize:48};return(t>e&&e<400||e>t)&&(n.width=99,o.width=99,o.height=99),i.a.createElement("div",{style:r},i.a.createElement("a",{href:"https://github.com/TrentSPalmer/fcc-challenges/tree/gh-pages/pomodoro-clock-react",style:n,target:"_blank",rel:"noopener noreferrer"},i.a.createElement("img",{src:"https://github.blog/wp-content/uploads/2008/12/forkme_right_white_ffffff.png?resize=149%2C149",className:"size-full",style:o,alt:"Fork me on GitHub","data-recalc-dims":"1"})),i.a.createElement(P,null))}}]),n}(i.a.Component),K=Object(a.b)((function(e){return Object(y.a)({},e)}),(function(e){return{innerWindowWidthAction:function(t){return e(function(e){return{type:"SETWINDOWINNERWIDTH",windowInnerWidth:e}}(t))},innerWindowHeightAction:function(t){return e(function(e){return{type:"SETWINDOWINNERHEIGHT",windowInnerHeight:e}}(t))}}}))(G);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));s.a.render(i.a.createElement(a.a,{store:d},i.a.createElement(K,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[21,1,2]]]);
//# sourceMappingURL=main.157adc9f.chunk.js.map