UNPKG

react-analog-clock

Version:
1 lines 9.72 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactSexyClock=t(require("react")):e.ReactSexyClock=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Themes=void 0;var o=n(4),u=i(o),a=n(1),s=r(a);t.Themes=s;t.default=u.default},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.light={background:"#fff",border:"#ececec",center:"#000",seconds:"#f56c6c",minutes:"#ccc",hour:"#000",tick:"#000",smallTickWidth:2,largeTickWidth:4,secondHandWidth:3,minuteHandWidth:6,hourHandWidth:8},t.dark={background:"#000",border:"#000",center:"#fff",seconds:"#fff",minutes:"#ccc",hour:"#fff",tick:"#fff",smallTickWidth:2,largeTickWidth:4,secondHandWidth:3,minuteHandWidth:6,hourHandWidth:8},t.aqua={background:"#eaeaea",border:"#3dd4c1",center:"#000",seconds:"#f56c6c",minutes:"#9c9c9c",hour:"#000",tick:"#000",smallTickWidth:2,largeTickWidth:4,secondHandWidth:3,minuteHandWidth:6,hourHandWidth:8},t.lime={background:"#a4f181",border:"#fff",center:"#ccc",seconds:"#fff",minutes:"#ccc",hour:"#fff",tick:"#fff",smallTickWidth:2,largeTickWidth:4,secondHandWidth:3,minuteHandWidth:6,hourHandWidth:8},t.sherbert={background:"linear-gradient(to left, #fee , #ddefbb)",border:"#fff",center:"#fff",seconds:"#fff",minutes:"#ccc",hour:"#fff",tick:"#fff",smallTickWidth:2,largeTickWidth:4,secondHandWidth:3,minuteHandWidth:6,hourHandWidth:8},t.navy={background:"linear-gradient(#2a70a0,#102d42)",border:"#fff",center:"#fff",seconds:"#fff",minutes:"#ccc",hour:"#fff",tick:"#fff",smallTickWidth:2,largeTickWidth:4,secondHandWidth:3,minuteHandWidth:6,hourHandWidth:8}},function(e,t,n){e.exports=n(10)()},function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;t.length>n;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(3),d=r(c),f=n(2),l=r(f),h=n(5),p=r(h),m=n(6),b=r(m),g=n(7),y=n(1),k=function(e){function t(e){i(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),r=n.initializeTime(e.gmtOffset);return n.state={seconds:r[2],minutes:r[1],hour:r[0]},n.styles=(0,g.cssTransform)(b.default,e),n}return u(t,e),s(t,[{key:"componentDidMount",value:function(){var e=this;this.interval=setInterval(function(){e.setState((0,g.updateTime)(e.state))},1e3)}},{key:"componentWillReceiveProps",value:function(e){this.styles=(0,g.cssTransform)(b.default,e)}},{key:"componentWillUnmount",value:function(){clearInterval(this.interval)}},{key:"initializeTime",value:function(e){var t=new Date;if(e&&"undefined"!==e){var n=new Date(t.valueOf()+1e3*parseFloat(e)*60*60);return[n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds()]}return[t.getHours(),t.getMinutes(),t.getSeconds()]}},{key:"render",value:function(){return d.default.createElement(p.default,a({},this.state,{styles:this.styles,showSmallTicks:this.props.showSmallTicks}))}}]),t}(c.Component);t.default=k,k.propTypes={theme:l.default.shape({background:l.default.string.isRequired,border:l.default.string.isRequired,center:l.default.string.isRequired,seconds:l.default.string.isRequired,minutes:l.default.string.isRequired,hour:l.default.string.isRequired,tick:l.default.string.isRequired}),width:l.default.number,gmtOffset:l.default.string,showSmallTicks:l.default.bool},k.defaultProps={theme:y.dark,width:400,showSmallTicks:!0}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){for(var n=e.smallTick,r=e.largeTick,i=[],o=0;60>o;o++){var u=Object.assign({},o%5===0?r:n,{transform:"translateX(-50%) translateY(-100%) rotate("+6*o+"deg)"});(o%5===0||t)&&i.push(a.default.createElement("span",{key:o,style:u}))}return i}function o(e){var t=e.hour,n=e.minutes,r=e.seconds,o=e.styles,u=e.showSmallTicks,s=Object.assign({},o.second,{transform:"translateX(-50%) translateY(-100%) rotate("+(6*r+1)+"deg)"}),c=Object.assign({},o.minute,{transform:"translateX(-50%) translateY(-100%) rotate("+(6*n+1)+"deg)"}),d=Object.assign({},o.hour,{transform:"translateX(-50%) translateY(-100%) rotate("+(30*t+1.5)+"deg)"});return a.default.createElement("div",{style:o.base},a.default.createElement("div",{"data-testid":"seconds",style:s}),a.default.createElement("div",{"data-testid":"minutes",style:c}),a.default.createElement("div",{"data-testid":"hour",style:d}),a.default.createElement("div",{style:o.center}),i(o,u))}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var u=n(3),a=r(u),s=n(2),c=r(s);o.propTypes={hour:c.default.number.isRequired,minutes:c.default.number.isRequired,seconds:c.default.number.isRequired,styles:c.default.shape({second:c.default.object.isRequired,minute:c.default.object.isRequired,hour:c.default.object.isRequired}).isRequired,showSmallTicks:c.default.bool.isRequired}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){return null===e||void 0===e?t:e},r={background:function(e){return e.theme.background},backgroundSize:"cover",backgroundPosition:"center",borderRadius:"100%",border:function(e){return e.width/20+"px solid "+e.theme.border},height:function(e){return e.width},position:"relative",width:function(e){return e.width}},i={background:function(e){return e.theme.center},borderRadius:"100%",height:"12px",left:"50%",position:"absolute",top:"50%",transform:"translateX(-50%) translateY(-50%)",width:"12px"},o={left:"50%",position:"absolute",top:"50%",transformOrigin:"50% 100%"},u=Object.assign({},o,{background:function(e){return e.theme.seconds},height:function(e){return Math.floor(.425*e.width)},width:function(e){return n(e.theme.secondHandWidth,3)}}),a=Object.assign({},o,{background:function(e){return e.theme.minutes},height:function(e){return Math.floor(.35*e.width)},width:function(e){return n(e.theme.minuteHandWidth,6)}}),s=Object.assign({},o,{background:function(e){return e.theme.hour},height:function(e){return Math.floor(.2*e.width)},width:function(e){return n(e.theme.hourHandWidth,8)}}),c={background:function(e){return e.theme.tick},height:6,left:"50%",position:"absolute",top:6,transformOrigin:function(e){return"0 "+Math.ceil(e.width/2)+"px"},width:function(e){return n(e.theme.smallTickWidth,2)}},d={background:function(e){return e.theme.tick},height:10,left:function(e){return Math.ceil(e.width/2)+2},position:"absolute",top:10,transformOrigin:function(e){return"0 "+Math.ceil(e.width/2)+"px"},width:function(e){return n(e.theme.largeTickWidth,4)}};t.default={base:r,center:i,second:u,minute:a,hour:s,smallTick:c,largeTick:d}},function(e,t){"use strict";function n(e,t){return Object.keys(e).reduce(function(n,r){var i=e[r];return n[r]=Object.keys(i).reduce(function(e,n){return e[n]="function"==typeof i[n]?i[n](t):i[n],e},{}),n},{})}function r(e){var t=e.seconds,n=e.minutes,r=e.hour;return t+=1,60===t&&(t=0,n+=1),60===n&&(n=0,r+=1),12===r&&(r=0),{seconds:t,minutes:n,hour:r}}Object.defineProperty(t,"__esModule",{value:!0}),t.cssTransform=n,t.updateTime=r},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,o,u,a,s){if(i(t),!e){var c;if(void 0===t)c=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var d=[n,r,o,u,a,s],f=0;c=Error(t.replace(/%s/g,function(){return d[f++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var i=function(e){};e.exports=r},function(e,t,n){"use strict";var r=n(8),i=n(9),o=n(11);e.exports=function(){function e(e,t,n,r,u,a){a!==o&&i(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n}])});