Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
naschmitz committed Dec 3, 2024
1 parent acdce3e commit d07a561
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
7 changes: 5 additions & 2 deletions geemap/map_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def _on_map_interaction(self, **kwargs: Any) -> None:
Args:
**kwargs (Any): The interaction event arguments.
"""
latlon = kwargs.get("coordinates")
latlon = kwargs.get("coordinates", [])
if kwargs.get("type") == "click":
self._on_map_click(latlon)

Expand All @@ -602,7 +602,10 @@ def _on_map_click(self, latlon: List[float]) -> None:
Args:
latlon (List[float]): The latitude and longitude of the click event.
"""
self._clear_inspector_output()
if not latlon or len(latlon) < 2:
return

self._clear_inspector_output()
self._host_map.default_style = {"cursor": "wait"}

self.point_info = self._point_info(latlon)
Expand Down
30 changes: 20 additions & 10 deletions js/container.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { RenderProps } from "@anywidget/types";
import { css, html, TemplateResult } from "lit";
import { property } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";

import { legacyStyles } from "./ipywidgets_styles";
import { LitWidget } from "./lit_widget";
Expand All @@ -24,11 +25,11 @@ export class Container extends LitWidget<ContainerModel, Container> {
.header {
display: flex;
gap: 4px;
margin: 4px;
padding: 4px;
}
.widget-container {
margin: 4px;
padding: 4px;
}
.hidden {
Expand Down Expand Up @@ -65,10 +66,12 @@ export class Container extends LitWidget<ContainerModel, Container> {
return html`
<div class="header">
<button
class="legacy-button primary header-button ${this
.hideCloseButton
? "hidden"
: ""}"
class=${classMap({
"legacy-button": true,
primary: true,
"header-button": true,
hidden: this.hideCloseButton,
})}
@click="${this.onCloseButtonClicked}"
>
<span class="material-symbols-outlined">&#xe5cd;</span>
Expand All @@ -80,14 +83,21 @@ export class Container extends LitWidget<ContainerModel, Container> {
${this.renderCollapseButtonIcon()}
</button>
<span
class="legacy-text header-text ${this.title
? ""
: "hidden"}"
class=${classMap({
"legacy-text": true,
"header-text": true,
hidden: !this.title,
})}
>
${this.title}
</span>
</div>
<div class="widget-container ${this.collapsed ? "hidden" : ""}">
<div
class=${classMap({
"widget-container": true,
hidden: this.collapsed,
})}
>
<slot></slot>
</div>
`;
Expand Down
12 changes: 6 additions & 6 deletions js/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Inspector extends LitWidget<InspectorModel, Inspector> {
.object-browser {
max-height: 300px;
min-width: 290px;
overflow: scroll;
overflow: auto;
}
input[type='checkbox'] {
Expand All @@ -50,10 +50,10 @@ export class Inspector extends LitWidget<InspectorModel, Inspector> {
`,
];

@property() hideCloseButton: boolean = false;
@property() expandPoints: boolean = false;
@property() expandPixels: boolean = true;
@property() expandObjects: boolean = false;
@property({ type: Boolean }) hideCloseButton: boolean = false;
@property({ type: Boolean }) expandPoints: boolean = false;
@property({ type: Boolean }) expandPixels: boolean = true;
@property({ type: Boolean }) expandObjects: boolean = false;
@property() pointInfo: Node = {};
@property() pixelInfo: Node = {};
@property() objectInfo: Node = {};
Expand Down Expand Up @@ -113,7 +113,7 @@ export class Inspector extends LitWidget<InspectorModel, Inspector> {
}

private renderNode(node: Node): TemplateResult | typeof nothing {
if ((node.children?.length ?? 0) > 0) {
if (node.children?.length) {
return html`<tree-node .node="${node}"></tree-node> `;
}
return nothing;
Expand Down
4 changes: 2 additions & 2 deletions js/tree_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class TreeNode extends LitElement {
];

@property() node: Node = {};
@property({ reflect: true }) expanded: boolean = false;
@property({ type: Boolean, reflect: true }) expanded: boolean = false;

updated(changedProperties: PropertyValues<TreeNode>): void {
super.updated(changedProperties);
Expand Down Expand Up @@ -86,7 +86,7 @@ export class TreeNode extends LitElement {
}

private hasChildren(): boolean {
return (this.node.children?.length ?? 0) > 0;
return !!this.node.children?.length;
}

private renderChildren(): TemplateResult | typeof nothing {
Expand Down

0 comments on commit d07a561

Please sign in to comment.