UNPKG

ni-clock

Version:
52 lines (47 loc) 9.74 kB
import { Component, Input, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; // source: https://cssanimation.rocks/clocks/ class NiClockComponent { constructor() { this.time = new Date(); this.auto = true; } ngOnInit() { if (this.auto) { setInterval(() => this.time = new Date(), 1000); } } get hours() { return this.time.getHours(); } get minutes() { return this.time.getMinutes(); } get seconds() { return this.time.getSeconds(); } get zHour() { return `rotateZ(${this.hours * 30 + (this.minutes * 0.5)}deg)`; } get zMinute() { return `rotateZ(${this.minutes * 6 + (this.seconds * 0.1)}deg)`; } get zSecond() { return `rotateZ(${this.seconds * 6}deg)`; } } NiClockComponent.decorators = [ { type: Component, args: [{ // tslint:disable-next-line: component-selector selector: 'ni-clock', template: "<!-- source: https://cssanimation.rocks/clocks/ -->\n<div class=\"clock\">\n <div class=\"hours-container\" [ngStyle]=\"{ 'transform': zHour }\"\n [ngClass]=\"{ 'fix-flicker-at-0': hours == 0 }\">\n <div class=\"hours\"></div>\n </div>\n <div class=\"minutes-container\" [ngStyle]=\"{ 'transform': zMinute }\"\n [ngClass]=\"{ 'fix-flicker-at-0': minutes == 0 }\">\n <div class=\"minutes\"></div>\n </div>\n <div class=\"seconds-container\" [ngStyle]=\"{ 'transform': zSecond }\"\n [ngClass]=\"{ 'fix-flicker-at-0': seconds == 0 }\">\n <div class=\"seconds\"></div>\n </div>\n</div>\n", styles: [".clock{display:inline-block;position:relative;width:160px;height:160px;border-radius:50%;opacity:1;background:#fff url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 226.6 233.8'%3E%3Cpath d='M105.5 22.7V6.4h-5.9V4.3c.8 0 1.5-.1 2.2-.2.7-.1 1.4-.3 2-.7.6-.3 1.1-.8 1.5-1.3.4-.6.7-1.3.8-2.1h2.1v22.7h-2.7zM114.1 4.8c.3-1 .8-1.8 1.4-2.5.6-.7 1.4-1.3 2.4-1.7.9-.4 2-.6 3.2-.6 1 0 1.9.1 2.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%3C/svg%3E\") no-repeat 50%;background-size:88%}.clock:before{background:#000;width:6%;height:6%;z-index:0}.clock:after,.clock:before{border-radius:50%;content:\"\";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}.clock:after{background:red;width:2%;height:2%;z-index:10}.hours-container,.minutes-container,.seconds-container{position:absolute;top:0;right:0;bottom:0;left:0;transition:transform .2s cubic-bezier(.4,2.08,.55,.44)}.fix-flicker-at-0{transition-duration:0s!important}.hours{border-radius:85%/10%;height:20%;top:30%}.hours,.minutes{background:#000;position:absolute;width:2%;left:49%;transform-origin:50% 100%}.minutes{border-radius:150%/10%;height:35%;top:15%}.seconds{background:red;height:30%;width:1%;position:absolute;top:20%;left:49.5%;z-index:8;border-radius:200%/10%;transform-origin:50% 100%}@-webkit-keyframes rotate{to{transform:rotate(1turn)}}@keyframes rotate{to{transform:rotate(1turn)}}"] },] } ]; NiClockComponent.ctorParameters = () => []; NiClockComponent.propDecorators = { time: [{ type: Input }], auto: [{ type: Input }] }; class NiClockModule { } NiClockModule.decorators = [ { type: NgModule, args: [{ declarations: [NiClockComponent], imports: [CommonModule], exports: [NiClockComponent] },] } ]; /** * Generated bundle index. Do not edit. */ export { NiClockComponent, NiClockModule }; //# sourceMappingURL=ni-clock.js.map