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 progress-bar-striped
{{if this.active 'progress-bar-animated'}}"
style={{barStyle}}
></div>
<div class="progress-bar {{if this.active 'active'}}">
<div class="progress-bar-inner" style={{this.barStyle}}></div>
</div>

View File

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

View File

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

View File

@ -90,9 +90,20 @@
}
}
div.progress {
margin-top: 20px;
margin-bottom: 20px;
.progress-bar {
background: var(--primary-100);
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 {