DEV: Modernize progress-bar component

This commit is contained in:
Jarek Radosz 2023-01-18 18:44:12 +01:00
parent a6260a5270
commit 71de0a1ec7
4 changed files with 29 additions and 27 deletions

View File

@ -1,7 +1,3 @@
<div class="progress progress-striped {{if this.active 'active'}}"> <div class="progress-bar {{if this.active 'active'}}">
<div <div class="progress-bar-inner" style={{this.barStyle}}></div>
class="progress-bar progress-bar-striped
{{if this.active 'progress-bar-animated'}}"
style={{barStyle}}
></div>
</div> </div>

View File

@ -1,23 +1,18 @@
import Component from "@ember/component"; import Component from "@glimmer/component";
import { computed } from "@ember/object";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
export default Component.extend({ export default class ProgressBar extends Component {
tagName: "", get active() {
return parseInt(this.args.percent, 10) !== 100;
}
active: computed("percent", function () { get barStyle() {
return parseInt(this.get("percent"), 10) !== 100; let percent = parseInt(this.args.percent, 10);
}),
barStyle: computed("percent", function () { if (percent > 100) {
let percent = parseInt(this.get("percent"), 10); percent = 100;
if (percent > 0) {
if (percent > 100) {
percent = 100;
}
return htmlSafe("width: " + this.get("percent") + "%");
} }
return htmlSafe(""); return htmlSafe(`width: ${percent}%`);
}), }
}); }

View File

@ -1,6 +1,6 @@
<h3>Upgrade {{title}}</h3> <h3>Upgrade {{title}}</h3>
{{progress-bar percent=percent}} <ProgressBar @percent={{this.percent}} />
{{#if complete}} {{#if complete}}
<p>Upgrade completed successfully!</p> <p>Upgrade completed successfully!</p>

View File

@ -90,9 +90,20 @@
} }
} }
div.progress { .progress-bar {
margin-top: 20px; background: var(--primary-100);
margin-bottom: 20px; border: 1px solid var(--primary-200);
height: 1.5rem;
margin: 1rem 0;
&-inner {
background: var(--tertiary-400);
height: 100%;
}
&.active &-inner {
background: var(--tertiary-800);
}
} }
th { th {