diff --git a/ui/app/components/freestyle/sg-progress-bar.js b/ui/app/components/freestyle/sg-progress-bar.js new file mode 100644 index 000000000..613bc08e9 --- /dev/null +++ b/ui/app/components/freestyle/sg-progress-bar.js @@ -0,0 +1,35 @@ +import Component from '@ember/component'; +import { computed } from '@ember/object'; + +export default Component.extend({ + timerTicks: 0, + + startTimer: function() { + this.set( + 'timer', + setInterval(() => { + this.incrementProperty('timerTicks'); + }, 1000) + ); + }.on('init'), + + willDestroy() { + clearInterval(this.get('timer')); + }, + + denominator: computed('timerTicks', function() { + return Math.round(Math.random() * 1000); + }), + + percentage: computed('timerTicks', function() { + return Math.round(Math.random() * 100) / 100; + }), + + numerator: computed('denominator', 'percentage', function() { + return Math.round(this.get('denominator') * this.get('percentage') * 100) / 100; + }), + + liveDetails: computed('denominator', 'numerator', 'percentage', function() { + return this.getProperties('denominator', 'numerator', 'percentage'); + }), +}); diff --git a/ui/app/templates/components/freestyle/sg-progress-bar.hbs b/ui/app/templates/components/freestyle/sg-progress-bar.hbs new file mode 100644 index 000000000..24e34f00e --- /dev/null +++ b/ui/app/templates/components/freestyle/sg-progress-bar.hbs @@ -0,0 +1,77 @@ +{{#freestyle-usage "progress-bar" title="Progress Bar"}} +
+ + 0.33 + +
+{{/freestyle-usage}} + +{{#freestyle-usage "progress-bar-colors" title="Progress Bar Colors"}} +
+
+
+ + 0.33 + +
+
+
+
+ + 0.33 + +
+
+
+
+ + 0.33 + +
+
+
+
+ + 0.33 + +
+
+
+{{/freestyle-usage}} + +{{#freestyle-usage "progress-bar-live" title="Progress Bar Live Updates"}} +
+
+
+ + {{percentage}} + +
+
+
+{{/freestyle-usage}} +{{#freestyle-annotation}} +
+
+ {{json-viewer json=liveDetails}} +
+
+{{/freestyle-annotation}} diff --git a/ui/app/templates/freestyle.hbs b/ui/app/templates/freestyle.hbs index b0e1684ea..3e24d0147 100644 --- a/ui/app/templates/freestyle.hbs +++ b/ui/app/templates/freestyle.hbs @@ -98,6 +98,7 @@ {{/section.subsection}} {{#section.subsection name="Progress Bar"}} + {{freestyle/sg-progress-bar}} {{/section.subsection}} {{/freestyle-section}} {{/freestyle-guide}}