Commit 530acfcc authored by Ammar Alakkad's avatar Ammar Alakkad Committed by Paul Slaughter

Adjust StatisticsCard component

- Render progress bar with 0 value
- Remove margin classes from StatisticsCard
- Add help link property to StatisticsCard component
parent bf908bed
...@@ -22,6 +22,7 @@ Default.args = { ...@@ -22,6 +22,7 @@ Default.args = {
totalValue: '1,500', totalValue: '1,500',
description: 'Additional minutes used', description: 'Additional minutes used',
helpLink: 'dummy.com/link', helpLink: 'dummy.com/link',
helpLabel: 'Help link label, used for aria-label',
percentage: 84, percentage: 84,
}; };
...@@ -41,6 +42,7 @@ WithUnits.args = { ...@@ -41,6 +42,7 @@ WithUnits.args = {
totalUnit: 'GiB', totalUnit: 'GiB',
description: 'Storage used', description: 'Storage used',
helpLink: 'dummy.com/link', helpLink: 'dummy.com/link',
helpLabel: 'Help link label, used for aria-label',
percentage: 4, percentage: 4,
purchaseButtonLink: 'purchase.com/test', purchaseButtonLink: 'purchase.com/test',
purchaseButtonText: 'Purchase storage', purchaseButtonText: 'Purchase storage',
......
...@@ -35,6 +35,11 @@ export default { ...@@ -35,6 +35,11 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
helpLabel: {
type: String,
required: false,
default: null,
},
percentage: { percentage: {
type: Number, type: Number,
required: false, required: false,
...@@ -65,10 +70,10 @@ export default { ...@@ -65,10 +70,10 @@ export default {
data-testid="container" data-testid="container"
:class="cssClass" :class="cssClass"
> >
<div class="gl-display-flex gl-justify-content-space-between gl-mb-3"> <div class="gl-display-flex gl-justify-content-space-between">
<p <p
v-if="usageValue" v-if="usageValue"
class="gl-font-size-h-display gl-font-weight-bold" class="gl-font-size-h-display gl-font-weight-bold gl-mb-3"
data-testid="denominator" data-testid="denominator"
> >
{{ usageValue }} {{ usageValue }}
...@@ -95,7 +100,7 @@ export default { ...@@ -95,7 +100,7 @@ export default {
</gl-button> </gl-button>
</div> </div>
</div> </div>
<p v-if="description" class="gl-font-weight-bold gl-mt-3" data-testid="description"> <p v-if="description" class="gl-font-weight-bold" data-testid="description">
{{ description }} {{ description }}
<gl-link <gl-link
v-if="helpLink" v-if="helpLink"
...@@ -103,10 +108,11 @@ export default { ...@@ -103,10 +108,11 @@ export default {
target="_blank" target="_blank"
rel="noopener noreferrer nofollow" rel="noopener noreferrer nofollow"
class="gl-ml-2" class="gl-ml-2"
:aria-label="helpLabel"
> >
<gl-icon name="question-o" /> <gl-icon name="question-o" />
</gl-link> </gl-link>
</p> </p>
<gl-progress-bar v-if="percentage" :value="percentage" /> <gl-progress-bar v-if="percentage !== null" :value="percentage" />
</div> </div>
</template> </template>
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`StatisticsCard denominator block renders denominator block with all elements when all props are passed 1`] = ` exports[`StatisticsCard denominator block renders denominator block with all elements when all props are passed 1`] = `
"<p data-testid=\\"denominator\\" class=\\"gl-font-size-h-display gl-font-weight-bold\\"> "<p data-testid=\\"denominator\\" class=\\"gl-font-size-h-display gl-font-weight-bold gl-mb-3\\">
1,000 1,000
<span data-testid=\\"denominator-usage-unit\\" class=\\"gl-font-lg\\">MiB</span> <span data-testid=\\"denominator-total\\"> <span data-testid=\\"denominator-usage-unit\\" class=\\"gl-font-lg\\">MiB</span> <span data-testid=\\"denominator-total\\">
/ /
......
...@@ -139,12 +139,20 @@ describe('StatisticsCard', () => { ...@@ -139,12 +139,20 @@ describe('StatisticsCard', () => {
expect(wrapper.findComponent(GlProgressBar).exists()).toBe(false); expect(wrapper.findComponent(GlProgressBar).exists()).toBe(false);
}); });
it('renders progress bar if prop is passed', () => { it('renders progress bar if prop is greater than 0', () => {
const percentage = 99; const percentage = 99;
createComponent({ percentage }); createComponent({ percentage });
expect(findProgressBar().exists()).toBe(true); expect(findProgressBar().exists()).toBe(true);
expect(findProgressBar().attributes('value')).toBe(String(percentage)); expect(findProgressBar().attributes('value')).toBe(String(percentage));
}); });
it('renders the progress bar if prop is 0', () => {
const percentage = 0;
createComponent({ percentage });
expect(findProgressBar().exists()).toBe(true);
expect(findProgressBar().attributes('value')).toBe(String(percentage));
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment