ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
36 lines (30 loc) • 1.25 kB
text/typescript
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, ViewEncapsulation } from '@angular/core';
import { OhayoLocaleService } from '@ohayo/theme';
import { InputNumber, NumberInput, toNumber } from '@ohayo/util';
({
selector: 'g2-mini-progress',
exportAs: 'g2MiniProgress',
templateUrl: './mini-progress.component.html',
host: { '[class.g2-mini-progress]': 'true' },
preserveWhitespaces: false,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
})
export class G2MiniProgressComponent implements OnChanges {
static ngAcceptInputType_target: NumberInput;
static ngAcceptInputType_percent: NumberInput;
static ngAcceptInputType_strokeWidth: NumberInput;
() color = '#1890FF';
() () target: number;
() () percent: number;
() () strokeWidth: number;
constructor(public i18n: OhayoLocaleService, private cdr: ChangeDetectorRef) { }
private fixNum(value: number): number {
return Math.min(Math.max(toNumber(value), 0), 100);
}
ngOnChanges(): void {
this.target = this.fixNum(this.target);
this.percent = this.fixNum(this.percent);
this.cdr.detectChanges();
}
}