1 export interface ProgressBarOptions {
5 displayPercent?: boolean;
8 export function ProgressBar(current: number, max: number, id: string, opts: ProgressBarOptions) {
9 const endingColor = opts.endingColor ?? opts.startingColor;
10 const title = opts.title ?? '';
11 const display = [`${current}/${max}`];
15 percent = Math.floor((current / max) * 100);
18 if(opts.displayPercent) {
19 display.push(`${percent}%`);
22 return `<div class="progress-bar" id="${id}" style="background: linear-gradient(to right, ${opts.startingColor}, ${endingColor} ${percent}%, transparent ${percent}%, transparent)"
23 title="${title} ${display.join(" - ")}">${title} ${display.join(" - ")}</div>`;