angular2-spinner
Version:
Angular2 Spinner Indicator
64 lines (53 loc) • 1.39 kB
text/typescript
import { Component, HostBinding, Input, OnInit } from '@angular/core';
export class SpinnerComponent implements OnInit {
size = 25;
tickness = 2;
color = '#4f6aa7';
opacity = '.1';
secondColor = '';
ngOnInit(): void {
const c = this.hexToRgb(this.color);
this.secondColor = 'rgba(' + c.r + ',' + c.g + ',' + c.b + ', ' + this.opacity + ')';
}
private hexToRgb(hex: string) {
let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
}