Skip to content

Commit

Permalink
added new <ProgressBar /> component
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Jul 19, 2024
1 parent 324b7f2 commit 1238f07
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addon/components/progress-bar.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div>
<div class="mb-2 flex justify-between items-center">
<h3 class="text-sm font-semibold text-gray-800 dark:text-white">{{@title}}</h3>
<span class="text-sm text-gray-800 dark:text-white">{{@percent}}%</span>
</div>
<div class="flex w-full h-2 bg-gray-200 rounded-full overflow-hidden dark:bg-neutral-700" role="progressbar" aria-valuenow={{@percent}} aria-valuemin="0" aria-valuemax="100">
<div
class="flex flex-col justify-center rounded-full overflow-hidden bg-blue-600 text-xs text-white text-center whitespace-nowrap transition duration-500 dark:bg-blue-500"
{{did-update this.setProgress @percent}}
></div>
</div>
</div>
8 changes: 8 additions & 0 deletions addon/components/progress-bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class ProgressBarComponent extends Component {
@action setProgress(el, [percent]) {
el.style.width = `${percent}%`;
}
}
1 change: 1 addition & 0 deletions app/components/progress-bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@fleetbase/ember-ui/components/progress-bar';
26 changes: 26 additions & 0 deletions tests/integration/components/progress-bar-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'dummy/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | progress-bar', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.set('myAction', function(val) { ... });

await render(hbs`<ProgressBar />`);

assert.dom().hasText('');

// Template block usage:
await render(hbs`
<ProgressBar>
template block text
</ProgressBar>
`);

assert.dom().hasText('template block text');
});
});

0 comments on commit 1238f07

Please sign in to comment.