File tree Expand file tree Collapse file tree 5 files changed +74
-9
lines changed Expand file tree Collapse file tree 5 files changed +74
-9
lines changed Original file line number Diff line number Diff line change 3
3
role =" region"
4
4
aria-label =" {{ _getAriaLabel }} "
5
5
part =" root" >
6
- {{ #if _hasHeader }}
7
- <div class =" ui5-card-header-root" >
8
- <slot name =" header" ></slot >
6
+ <ui5-busy-indicator
7
+ id =" {{ _id }} -busyIndicator"
8
+ delay =" {{ loadingDelay }} "
9
+ ?active =" {{ loading }} "
10
+ class =" ui5-card-busy-indicator"
11
+ >
12
+ <div class =" ui5-card-inner" >
13
+ {{ #if _hasHeader }}
14
+ <div class =" ui5-card-header-root" >
15
+ <slot name =" header" ></slot >
16
+ </div >
17
+ {{ /if }}
18
+ <div role =" group" aria-label =" {{ _ariaCardContentLabel }} " part =" content" >
19
+ <slot ></slot >
20
+ </div >
9
21
</div >
10
- {{ /if }}
11
- <div role =" group" aria-label =" {{ _ariaCardContentLabel }} " part =" content" >
12
- <slot ></slot >
13
- </div >
22
+ </ui5-busy-indicator >
14
23
</div >
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
8
8
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js" ;
9
9
import CardTemplate from "./generated/templates/CardTemplate.lit.js" ;
10
10
import Icon from "./Icon.js" ;
11
+ import BusyIndicator from "./BusyIndicator.js" ;
12
+
11
13
import {
12
14
ARIA_ROLEDESCRIPTION_CARD ,
13
15
ARIA_LABEL_CARD_CONTENT ,
@@ -45,7 +47,7 @@ import cardCss from "./generated/themes/Card.css.js";
45
47
renderer : litRender ,
46
48
template : CardTemplate ,
47
49
styles : cardCss ,
48
- dependencies : [ Icon ] ,
50
+ dependencies : [ Icon , BusyIndicator ] ,
49
51
} )
50
52
class Card extends UI5Element {
51
53
/**
@@ -85,6 +87,24 @@ class Card extends UI5Element {
85
87
@slot ( { type : HTMLElement , invalidateOnChildChange : true } )
86
88
header ! : Array < CardHeader > ;
87
89
90
+ /**
91
+ * Defines if a loading indicator would be displayed over the card.
92
+ * @default false
93
+ * @public
94
+ * @since 2.1.0
95
+ */
96
+ @property ( { type : Boolean } )
97
+ loading = false ;
98
+
99
+ /**
100
+ * Defines the delay in milliseconds, after which the loading indicator will show up for this card.
101
+ * @default 1000
102
+ * @public
103
+ * @since 2.1.0
104
+ */
105
+ @property ( { type : Number } )
106
+ loadingDelay = 1000 ;
107
+
88
108
static i18nBundle : I18nBundle ;
89
109
90
110
get classes ( ) {
Original file line number Diff line number Diff line change 19
19
box-sizing : border-box;
20
20
}
21
21
22
+ .ui5-card-busy-indicator {
23
+ width : 100% ;
24
+ height : 100% ;
25
+ border-radius : var (--_ui5_card_border-radius );
26
+ }
27
+
28
+ .ui5-card-inner {
29
+ width : 100% ;
30
+ height : 100% ;
31
+ }
32
+
22
33
.ui5-card-root .ui5-card--interactive : hover {
23
34
box-shadow : var (--_ui5_card_hover_box_shadow );
24
35
}
Original file line number Diff line number Diff line change 331
331
< div id ="cont " class ="myContent "> I am the content</ div >
332
332
</ ui5-card >
333
333
334
+ < ui5-card
335
+ id ="loadingCard "
336
+ loading
337
+ loading-delay ="500 "
338
+ accessible-name ="My Card ">
339
+ < ui5-card-header
340
+ id ="loadingCardHeader "
341
+ slot ="header "
342
+ interactive
343
+ title-text ="Interactive Header ">
344
+ < ui5-button slot ="action "> Header Button</ ui5-button >
345
+ </ ui5-card-header >
346
+ < div class ="myContent ">
347
+ < ui5-button > Content Button</ ui5-button >
348
+ </ div >
349
+ </ ui5-card >
350
+
334
351
< script >
335
352
function onClick ( event ) {
336
353
console . log ( event ) ;
337
354
field . value = `${ parseInt ( field . value ) + 1 } ` ;
338
355
}
339
356
340
- [ cardHeader , cardHeader2 , cardHeader3 ] . forEach ( function ( el ) {
357
+ [ cardHeader , cardHeader2 , cardHeader3 , loadingCardHeader ] . forEach ( function ( el ) {
341
358
el . addEventListener ( "ui5-click" , onClick ) ;
342
359
} ) ;
343
360
</ script >
Original file line number Diff line number Diff line change @@ -96,6 +96,14 @@ describe("Card general interaction", () => {
96
96
await cardHeaderTitle . setAttribute ( "aria-level" , 4 ) ;
97
97
assert . strictEqual ( await cardHeader . shadow$ ( ".ui5-card-header .ui5-card-header-title" ) . getAttribute ( "aria-level" ) , "4" ) ;
98
98
} ) ;
99
+
100
+ it ( "tests loading" , async ( ) => {
101
+ const card = await browser . $ ( "#loadingCard" ) ;
102
+ const busyIndicator = card . shadow$ ( "ui5-busy-indicator" ) ;
103
+
104
+ assert . ok ( await busyIndicator . hasAttribute ( "active" ) , "The busy indicator is active." ) ;
105
+ assert . strictEqual ( await busyIndicator . getAttribute ( "delay" ) , "500" , "The delay is correct." ) ;
106
+ } ) ;
99
107
} ) ;
100
108
101
109
describe ( "CardHeader" , ( ) => {
You can’t perform that action at this time.
0 commit comments