Skip to content

Commit 4118c68

Browse files
authored
feat(ui5-busyindicator): implement text property (#1506)
1 parent 0e57d78 commit 4118c68

File tree

5 files changed

+74
-19
lines changed

5 files changed

+74
-19
lines changed

packages/main/src/BusyIndicator.hbs

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<div class="ui5-busyindicator-root">
2-
3-
{{#if active}}
4-
<div class="ui5-busyindicator-dynamic-content" tabindex="0" role="progressbar" aria-valuemin="0" aria-valuemax="100" title="{{ariaTitle}}">
5-
<div class="ui5-busyindicator-circle circle-animation-0"></div>
6-
<div class="ui5-busyindicator-circle circle-animation-1"></div>
7-
<div class="ui5-busyindicator-circle circle-animation-2"></div>
8-
</div>
9-
{{/if}}
2+
<div class="ui5-busyindicator-wrapper">
3+
{{#if active}}
4+
<div class="ui5-busyindicator-dynamic-content" tabindex="0" role="progressbar" aria-valuemin="0" aria-valuemax="100" title="{{ariaTitle}}">
5+
<div class="ui5-busyindicator-circle circle-animation-0"></div>
6+
<div class="ui5-busyindicator-circle circle-animation-1"></div>
7+
<div class="ui5-busyindicator-circle circle-animation-2"></div>
8+
</div>
9+
{{/if}}
10+
{{#if text}}
11+
<ui5-label class="ui5-busyindicator-text">
12+
{{text}}
13+
</ui5-label>
14+
{{/if}}
15+
</div>
1016

1117
<slot></slot>
1218
</div>

packages/main/src/BusyIndicator.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
33
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
44
import BusyIndicatorSize from "./types/BusyIndicatorSize.js";
5+
import Label from "./Label.js";
56

67
// Template
78
import BusyIndicatorTemplate from "./generated/templates/BusyIndicatorTemplate.lit.js";
@@ -30,6 +31,18 @@ const metadata = {
3031
},
3132
},
3233
properties: /** @lends sap.ui.webcomponents.main.BusyIndicator.prototype */ {
34+
35+
/**
36+
* Defines text to be displayed below the busy indicator. It can be used to inform the user of the current operation.
37+
* @type {String}
38+
* @public
39+
* @defaultvalue ""
40+
* @since 1.0.0-rc.7
41+
*/
42+
text: {
43+
type: String,
44+
},
45+
3346
/**
3447
* Defines the size of the <code>ui5-busyindicator</code>.
3548
* <br><br>
@@ -101,7 +114,10 @@ class BusyIndicator extends UI5Element {
101114
}
102115

103116
static async onDefine() {
104-
await fetchI18nBundle("@ui5/webcomponents");
117+
await Promise.all([
118+
fetchI18nBundle("@ui5/webcomponents"),
119+
Label.define(),
120+
]);
105121
}
106122

107123
get ariaTitle() {

packages/main/src/themes/BusyIndicator.css

+29-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
display: inline-block;
33
}
44

5+
:host(:not([active])) .ui5-busyindicator-wrapper {
6+
display: none;
7+
}
8+
59
:host([active]) {
610
color: var(--sapContent_IconColor);
711
pointer-events: none;
@@ -20,6 +24,10 @@
2024
min-height: .5rem;
2125
}
2226

27+
:host([size="Small"][text]:not([text=""])) .ui5-busyindicator-root {
28+
min-height: 1.75rem;
29+
}
30+
2331
:host([size="Small"]) .ui5-busyindicator-circle {
2432
width: .5rem;
2533
height: .5rem;
@@ -31,6 +39,11 @@
3139
min-height: 1rem;
3240
}
3341

42+
:host(:not([size])[text]:not([text=""])) .ui5-busyindicator-root,
43+
:host([size="Medium"][text]:not([text=""])) .ui5-busyindicator-root {
44+
min-height: 2.25rem;
45+
}
46+
3447
:host(:not([size])) .ui5-busyindicator-circle,
3548
:host([size="Medium"]) .ui5-busyindicator-circle {
3649
width: 1rem;
@@ -42,6 +55,10 @@
4255
min-height: 2rem;
4356
}
4457

58+
:host([size="Large"][text]:not([text=""])) .ui5-busyindicator-root {
59+
min-height: 3.25rem;
60+
}
61+
4562
:host([size="Large"]) .ui5-busyindicator-circle {
4663
width: 2rem;
4764
height: 2rem;
@@ -55,6 +72,12 @@
5572
background-color: inherit;
5673
}
5774

75+
.ui5-busyindicator-wrapper {
76+
position: absolute;
77+
z-index: 99;
78+
width: 100%;
79+
}
80+
5881
.ui5-busyindicator-circle {
5982
display: inline-block;
6083
background-color: currentColor;
@@ -69,9 +92,6 @@
6992
}
7093

7194
.ui5-busyindicator-dynamic-content {
72-
position: absolute;
73-
z-index: 99;
74-
width: 100%;
7595
height: 100%;
7696
display: flex;
7797
justify-content: center;
@@ -98,6 +118,12 @@
98118
animation-delay: 400ms;
99119
}
100120

121+
.ui5-busyindicator-text {
122+
width: 100%;
123+
margin-top: .25rem;
124+
text-align: center;
125+
}
126+
101127
@keyframes grow {
102128
0%, 50%, 100% {
103129
-webkit-transform: scale(0.5);

packages/main/src/themes/Label.css

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313

1414
:host(:not([wrap])) .ui5-label-root {
15+
width: 100%;
1516
font-weight: inherit;
1617
display: inline-block;
1718
white-space: nowrap;

packages/main/test/pages/BusyIndicator.html

+13-7
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,24 @@
2323
</head>
2424

2525
<body style="background-color: var(--sapBackgroundColor);">
26-
<ui5-title>Default (Large) ui5-busyindicator</ui5-title>
27-
<ui5-busyindicator active></ui5-busyindicator>
26+
<ui5-title>Large ui5-busyindicator</ui5-title>
27+
<ui5-busyindicator active size="Large"></ui5-busyindicator>
2828
<br/>
2929
<br/>
3030

31-
<ui5-title>Medium ui5-busyindicator</ui5-title>
31+
<ui5-title>Default Medium ui5-busyindicator</ui5-title>
3232
<ui5-busyindicator size="Medium" active id="indicator1"></ui5-busyindicator>
3333

3434
<br />
3535
<br />
3636
<ui5-busyindicator size="Medium" active id="indicator2"></ui5-busyindicator>
3737

38+
<ui5-title>ui5-busyindicator with text</ui5-title>
39+
40+
<br />
41+
<br />
42+
<ui5-busyindicator active id="indicator2" text="Loading" style="width: 10rem; border: 1px solid red"></ui5-busyindicator>
43+
3844
<br />
3945
<br />
4046

@@ -44,7 +50,7 @@
4450

4551
<br />
4652
<br />
47-
<ui5-busyindicator size="Medium" active>
53+
<ui5-busyindicator size="Medium" active text="Loading">
4854
<ui5-checkbox text="Hello World"></ui5-checkbox>
4955
</ui5-busyindicator>
5056

@@ -54,15 +60,15 @@
5460
<ui5-button id="fetch-btn" style="width: 120px;">Fetch List Data</ui5-button>
5561
<br>
5662
<br>
57-
<ui5-busyindicator id="busy-container" style="width: 520px" size="Medium">
63+
<ui5-busyindicator id="busy-container" style="width: 520px" size="Medium" text="Loading">
5864
<ui5-list id="fetch-list" no-data-text="No Data" header-text="Available Items" style="width: 100%"></ui5-list>
5965
</ui5-busyindicator>
6066

6167

6268
<br>
6369
<br>
6470
<br>
65-
<br>
71+
<br>
6672

6773
<ui5-busyindicator size="Medium" active style="width: 500px; margin-left: 100px">
6874
<ui5-list style="width: 100%; border: 1px solid black;">
@@ -72,7 +78,7 @@
7278
</ui5-list>
7379
</ui5-busyindicator>
7480

75-
<br>
81+
<br>
7682
<br>
7783
<br>
7884

0 commit comments

Comments
 (0)