igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
76 lines (75 loc) • 3.5 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var IgcCircularProgressComponent_1;
import { html, svg } from 'lit';
import { queryAssignedElements } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
import { themes } from '../../theming/theming-decorator.js';
import { registerComponent } from '../common/definitions/register.js';
import { createCounter, partNameMap } from '../common/util.js';
import { IgcProgressBaseComponent } from './base.js';
import IgcCircularGradientComponent from './circular-gradient.js';
import { styles } from './themes/circular/circular.progress.base.css.js';
import { styles as shared } from './themes/circular/shared/circular.progress.common.css.js';
import { all } from './themes/circular/themes.js';
let IgcCircularProgressComponent = IgcCircularProgressComponent_1 = class IgcCircularProgressComponent extends IgcProgressBaseComponent {
constructor() {
super(...arguments);
this._gradientId = `circular-progress-${IgcCircularProgressComponent_1.increment()}`;
}
static register() {
registerComponent(IgcCircularProgressComponent_1, IgcCircularGradientComponent);
}
renderSvg() {
const parts = { indeterminate: this.indeterminate, track: true };
const styles = {
stroke: `url(#${this._gradientId})`,
'--percentage': `${this.progress}`,
'--duration': `${this.animationDuration}ms`,
};
const gradients = this._assignedGradients.length
? this._assignedGradients.map(({ offset, color, opacity }) => svg `<stop offset=${offset} stop-color=${color} stop-opacity=${opacity}/>`)
: svg `
<stop offset="0%" part="gradient_start" />
<stop offset="100%" part="gradient_end" />
`;
return svg `
<circle part=${partNameMap(parts)}/>
<circle style=${styleMap(styles)} part="fill"/>
<defs>
<linearGradient id=${this._gradientId} gradientTransform="rotate(90)">
${gradients}
</linearGradient>
</defs>
`;
}
renderWrapper() {
const parts = {
svg: true,
indeterminate: this.indeterminate,
};
return html `
<svg part=${partNameMap(parts)}>${this.renderSvg()}</svg>
<slot name="gradient"></slot>
${this.renderDefaultSlot()}
`;
}
render() {
return this.renderWrapper();
}
};
IgcCircularProgressComponent.tagName = 'igc-circular-progress';
IgcCircularProgressComponent.styles = [styles, shared];
IgcCircularProgressComponent.increment = createCounter();
__decorate([
queryAssignedElements({ slot: 'gradient' })
], IgcCircularProgressComponent.prototype, "_assignedGradients", void 0);
IgcCircularProgressComponent = IgcCircularProgressComponent_1 = __decorate([
themes(all)
], IgcCircularProgressComponent);
export default IgcCircularProgressComponent;
//# sourceMappingURL=circular-progress.js.map