ember-assembly
Version:
A collection of beautiful UI components built by Goods
51 lines (42 loc) • 1.19 kB
text/typescript
import Component from '@ember/component';
//@ts-ignore
import template from './template';
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/template';
export default class UiProgressRing extends Component {
layout = template;
tagName: string = '';
progress?: number = 0;
stroke?: number = 4;
size?: number = 60;
appearance?: 'default' | 'strong' | 'subtle' = 'default';
('appearance')
get appearanceClass(): string {
return `appearance-${this.appearance}`;
}
('size')
get radius() {
// @ts-ignore
return this.size / 2;
}
('radius', 'stroke')
get normalizedRadius() {
// @ts-ignore
return this.radius - this.stroke;
}
('normalizedRadius')
get circumference(): number {
return this.normalizedRadius * 2 * Math.PI;
}
('progress', 'radius', 'stroke')
get ringStyle() {
let offset =
// @ts-ignore
this.circumference - (this.progress / 100) * this.circumference;
return htmlSafe(`stroke-dashoffset: ${offset}`);
}
('size')
get contentStyle() {
return htmlSafe(`width: ${this.size}px; height: ${this.size}px;`);
}
}