@@ -7,6 +7,7 @@ import { LitWidget } from "./lit_widget";
7
7
import { materialStyles } from "./styles" ;
8
8
9
9
export interface ContainerModel {
10
+ icon : string ;
10
11
title : string ;
11
12
collapsed : boolean ;
12
13
hide_close_button : boolean ;
@@ -27,6 +28,14 @@ export class Container extends LitWidget<ContainerModel, Container> {
27
28
padding: 4px;
28
29
}
29
30
31
+ .icon {
32
+ align-items: center;
33
+ display: flex;
34
+ font-size: 20px;
35
+ height: 28px;
36
+ justify-content: center;
37
+ }
38
+
30
39
.widget-container {
31
40
padding: 4px;
32
41
}
@@ -43,18 +52,20 @@ export class Container extends LitWidget<ContainerModel, Container> {
43
52
44
53
.header-text {
45
54
align-content: center;
46
- padding-left: 4px ;
47
- padding-right: 4px ;
55
+ flex-grow: 1 ;
56
+ padding-right: 12px ;
48
57
}
49
58
` ,
50
59
] ;
51
60
61
+ @property ( { type : String } ) icon : string = "" ;
52
62
@property ( { type : String } ) title : string = "" ;
53
63
@property ( { type : Boolean } ) collapsed : boolean = false ;
54
64
@property ( { type : Boolean } ) hideCloseButton : boolean = false ;
55
65
56
66
modelNameToViewName ( ) : Map < keyof ContainerModel , keyof Container | null > {
57
67
return new Map ( [
68
+ [ "icon" , "icon" ] ,
58
69
[ "collapsed" , "collapsed" ] ,
59
70
[ "title" , "title" ] ,
60
71
[ "hide_close_button" , "hideCloseButton" ] ,
@@ -64,14 +75,15 @@ export class Container extends LitWidget<ContainerModel, Container> {
64
75
render ( ) {
65
76
return html `
66
77
< div class ="header ">
67
- ${ this . renderCloseButton ( ) }
78
+ < span class ="icon material-symbols-outlined "> ${ this . icon } </ span >
79
+ ${ this . renderTitle ( ) }
68
80
< button
69
81
class ="legacy-button header-button "
70
82
@click ="${ this . onCollapseToggled } "
71
83
>
72
84
${ this . renderCollapseButtonIcon ( ) }
73
85
</ button >
74
- ${ this . renderTitle ( ) }
86
+ ${ this . renderCloseButton ( ) }
75
87
</ div >
76
88
< div class ="widget-container ${ this . collapsed ? "hidden" : "" } ">
77
89
< slot > </ slot >
@@ -93,11 +105,8 @@ export class Container extends LitWidget<ContainerModel, Container> {
93
105
` ;
94
106
}
95
107
96
- private renderTitle ( ) : HTMLTemplateResult | typeof nothing {
97
- if ( this . title ) {
98
- return html `< span class ="legacy-text header-text "> ${ this . title } </ span > ` ;
99
- }
100
- return nothing ;
108
+ private renderTitle ( ) : HTMLTemplateResult {
109
+ return html `< span class ="legacy-text header-text "> ${ this . title } </ span > ` ;
101
110
}
102
111
103
112
private onCloseButtonClicked ( ) : void {
0 commit comments