Skip to content

Commit 5f86b6c

Browse files
committed
container: Add icons to widget containers
1 parent 13bdd69 commit 5f86b6c

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

js/container.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { LitWidget } from "./lit_widget";
77
import { materialStyles } from "./styles";
88

99
export interface ContainerModel {
10+
icon: string;
1011
title: string;
1112
collapsed: boolean;
1213
hide_close_button: boolean;
@@ -27,6 +28,14 @@ export class Container extends LitWidget<ContainerModel, Container> {
2728
padding: 4px;
2829
}
2930
31+
.icon {
32+
align-items: center;
33+
display: flex;
34+
font-size: 20px;
35+
height: 28px;
36+
justify-content: center;
37+
}
38+
3039
.widget-container {
3140
padding: 4px;
3241
}
@@ -43,18 +52,20 @@ export class Container extends LitWidget<ContainerModel, Container> {
4352
4453
.header-text {
4554
align-content: center;
46-
padding-left: 4px;
47-
padding-right: 4px;
55+
flex-grow: 1;
56+
padding-right: 12px;
4857
}
4958
`,
5059
];
5160

61+
@property({ type: String }) icon: string = "";
5262
@property({ type: String }) title: string = "";
5363
@property({ type: Boolean }) collapsed: boolean = false;
5464
@property({ type: Boolean }) hideCloseButton: boolean = false;
5565

5666
modelNameToViewName(): Map<keyof ContainerModel, keyof Container | null> {
5767
return new Map([
68+
["icon", "icon"],
5869
["collapsed", "collapsed"],
5970
["title", "title"],
6071
["hide_close_button", "hideCloseButton"],
@@ -64,14 +75,15 @@ export class Container extends LitWidget<ContainerModel, Container> {
6475
render() {
6576
return html`
6677
<div class="header">
67-
${this.renderCloseButton()}
78+
<span class="icon material-symbols-outlined">${this.icon}</span>
79+
${this.renderTitle()}
6880
<button
6981
class="legacy-button header-button"
7082
@click="${this.onCollapseToggled}"
7183
>
7284
${this.renderCollapseButtonIcon()}
7385
</button>
74-
${this.renderTitle()}
86+
${this.renderCloseButton()}
7587
</div>
7688
<div class="widget-container ${this.collapsed ? "hidden" : ""}">
7789
<slot></slot>
@@ -93,11 +105,8 @@ export class Container extends LitWidget<ContainerModel, Container> {
93105
`;
94106
}
95107

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>`;
101110
}
102111

103112
private onCloseButtonClicked(): void {

js/inspector.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export class Inspector extends LitWidget<InspectorModel, Inspector> {
7373
render() {
7474
return html`
7575
<widget-container
76+
icon="search"
77+
title="Inspector"
7678
.hideCloseButton="${this.hideCloseButton}"
7779
@close-clicked="${this.onCloseButtonClicked}"
7880
>

js/legend.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ export class Legend extends LitWidget<LegendModel, Legend> {
101101
render() {
102102
return this.addHeader ? html`
103103
<widget-container
104-
.hideCloseButton="${!this.showCloseButton}"
105104
.title="${this.title}"
105+
.hideCloseButton="${!this.showCloseButton}"
106106
@close-clicked="${this.onCloseButtonClicked}">
107107
${this.renderLegend("")}
108108
</widget-container>` : this.renderLegend(this.title);

0 commit comments

Comments
 (0)