Skip to content

Commit 50008d0

Browse files
feat(ui5-progress-indicator): implement displayValue property (#3879)
Introducing new property "displayValue" with which we can set a custom text as value for the ProgressIndicator. Fixes: #3573 Closes: #3573
1 parent bb8629c commit 50008d0

File tree

6 files changed

+55
-1
lines changed

6 files changed

+55
-1
lines changed

packages/main/src/ProgressIndicator.hbs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
<ui5-icon name="{{valueStateIcon}}" class="ui5-progress-indicator-icon"></ui5-icon>
2525
{{/if}}
2626
{{#unless hideValue}}
27-
<span class="ui5-progress-indicator-value">{{validatedValue}}%</span>
27+
<span class="ui5-progress-indicator-value">
28+
{{#if displayValue}}
29+
{{displayValue}}
30+
{{else}}
31+
{{validatedValue}}%
32+
{{/if}}
33+
</span>
2834
{{/unless}}
2935
{{/inline}}

packages/main/src/ProgressIndicator.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ const metadata = {
5555
type: Integer,
5656
defaultValue: 0,
5757
},
58+
/**
59+
* Specifies the text value to be displayed in the bar.
60+
*
61+
* <b>Note:</b>
62+
* <ul>
63+
* <li>If there is no value provided or the value is empty, the default percentage value is shown.</li>
64+
* <li>If <code>hideValue</code> property is <code>true</code> both the <code>displayValue</code> and <code>value</code> property values are not shown.</li>
65+
* </ul>
66+
*
67+
* @type {string}
68+
* @public
69+
*/
70+
displayValue: {
71+
type: String,
72+
},
5873
/**
5974
* Defines the value state of the component.
6075
* <br><br>

packages/main/src/themes/ProgressIndicator.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@
6060
border-radius: 0 0.5rem 0.5rem 0;
6161
box-sizing: border-box;
6262
color: var(--_ui5_progress_indicator_color);
63+
overflow: hidden;
6364
}
6465

6566
.ui5-progress-indicator-value {
6667
margin: 0 0.375rem;
68+
white-space: nowrap;
69+
overflow: hidden;
70+
text-overflow: ellipsis;
6771
}
6872

6973
.ui5-progress-indicator-icon {

packages/main/test/pages/ProgressIndicator.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
<br />
9292
<ui5-progress-indicator disabled value="60"></ui5-progress-indicator>
9393
<br />
94+
Custom Display Value
95+
<br />
96+
<ui5-progress-indicator value="25" display-value="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."></ui5-progress-indicator>
97+
<br />
9498
Custom Size 1
9599
<br />
96100
<ui5-progress-indicator value="25" style="height: 50px; width: 200px;"></ui5-progress-indicator>

packages/main/test/samples/ProgressIndicator.sample.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ <h3>Basic Progress Indicator</h3>
3030
</xmp></pre>
3131
</section>
3232

33+
<section>
34+
<h3>Progress Indicator With Custom Display Value</h3>
35+
<div class="snippet">
36+
<ui5-progress-indicator value="25" display-value="Custom Display Value"></ui5-progress-indicator>
37+
</div>
38+
<pre class="prettyprint lang-html"><xmp>
39+
<ui5-progress-indicator value="25" display-value="Custom Display Value"></ui5-progress-indicator>
40+
</xmp></pre>
41+
</section>
42+
3343
<section>
3444
<h3>Progress Indicator With Value State</h3>
3545
<div class="snippet">

packages/main/test/specs/ProgressIndicator.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,19 @@ describe("API", () => {
2828
largerButton.click();
2929
assert.strictEqual(getValidatedValue(progressIndicator), 100, "The value is limited to 100 and it is validated correctly.");
3030
});
31+
32+
it("tests displayValue property", () => {
33+
const progressIndicator = $("#test-progress-indicator");
34+
const customDisplayValue = "Custom Display Value";
35+
const originalPercentageValue = getValidatedValue(progressIndicator);
36+
const valueShadowSpan = progressIndicator.shadow$(".ui5-progress-indicator-value");
37+
38+
progressIndicator.setAttribute("display-value", customDisplayValue);
39+
assert.strictEqual(valueShadowSpan.getText(), customDisplayValue,
40+
"The value span is showing the custom set text by the display-value attribute.");
41+
42+
progressIndicator.setAttribute("display-value", "");
43+
assert.strictEqual(valueShadowSpan.getText(), originalPercentageValue + "%",
44+
"The value is row backed to the originally shown percentage value after the display value is set to empty string.");
45+
});
3146
});

0 commit comments

Comments
 (0)