Styleguide entry for Progress Bar

This commit is contained in:
Michael Lange
2018-07-03 13:54:00 -07:00
parent e17592edab
commit 9a56423bab
3 changed files with 113 additions and 0 deletions

View File

@@ -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');
}),
});

View File

@@ -0,0 +1,77 @@
{{#freestyle-usage "progress-bar" title="Progress Bar"}}
<div class="inline-chart tooltip" aria-label="5 / 15">
<progress
class="progress is-primary is-small"
value="0.33"
max="1">
0.33
</progress>
</div>
{{/freestyle-usage}}
{{#freestyle-usage "progress-bar-colors" title="Progress Bar Colors"}}
<div class="columns">
<div class="column">
<div class="inline-chart tooltip" aria-label="5 / 15">
<progress
class="progress is-info is-small"
value="0.33"
max="1">
0.33
</progress>
</div>
</div>
<div class="column">
<div class="inline-chart tooltip" aria-label="5 / 15">
<progress
class="progress is-success is-small"
value="0.33"
max="1">
0.33
</progress>
</div>
</div>
<div class="column">
<div class="inline-chart tooltip" aria-label="5 / 15">
<progress
class="progress is-warning is-small"
value="0.33"
max="1">
0.33
</progress>
</div>
</div>
<div class="column">
<div class="inline-chart tooltip" aria-label="5 / 15">
<progress
class="progress is-danger is-small"
value="0.33"
max="1">
0.33
</progress>
</div>
</div>
</div>
{{/freestyle-usage}}
{{#freestyle-usage "progress-bar-live" title="Progress Bar Live Updates"}}
<div class="columns">
<div class="column is-one-third">
<div class="inline-chart tooltip" aria-label="{{numerator}} / {{denominator}}">
<progress
class="progress is-primary is-small"
value="{{percentage}}"
max="1">
{{percentage}}
</progress>
</div>
</div>
</div>
{{/freestyle-usage}}
{{#freestyle-annotation}}
<div class="boxed-section">
<div class="boxed-section-body is-dark">
{{json-viewer json=liveDetails}}
</div>
</div>
{{/freestyle-annotation}}

View File

@@ -98,6 +98,7 @@
{{/section.subsection}}
{{#section.subsection name="Progress Bar"}}
{{freestyle/sg-progress-bar}}
{{/section.subsection}}
{{/freestyle-section}}
{{/freestyle-guide}}