Conversation
giswqs
commented
Nov 23, 2025
|
🚀 Deployed on https://69239e88bc6649f056d9f64b--opengeos.netlify.app |
There was a problem hiding this comment.
Pull request overview
This PR introduces responsive width behavior for legend controls in MapLibre, allowing legends to automatically adjust their width based on content while respecting min/max constraints. The changes include new parameters for auto-sizing, custom header styling, and enhanced CSS rules for better content layout.
- Adds responsive width functionality with
auto_panel_widthandresponsiveparameters - Introduces header customization with
header_bgandheader_text_coloroptions - Enhances CSS styling for improved legend item layout and text handling
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| anymap/static/maplibre_widget.js | Implements auto-width logic for widget panels, including display property management and dynamic width calculation via updateAutoWidth() method |
| anymap/static/maplibre_widget.css | Adds responsive styling rules for legend content, increases title font size, and adds widget-specific CSS for better text handling and overflow control |
| anymap/maplibre.py | Extends add_widget_control and add_legend methods with new parameters for responsive behavior and header styling, implements logic to determine width mode based on user preferences |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| auto_panel_width: bool = False, | ||
| header_bg: Optional[str] = None, | ||
| header_text_color: Optional[str] = None, |
There was a problem hiding this comment.
The new parameters auto_panel_width, header_bg, and header_text_color are not documented in the docstring. Please add documentation for these parameters following the existing format:
auto_panel_width: Whether to enable automatic panel width that adapts to content. When True, the panel width will be determined by content size within min/max constraints.header_bg: Optional background color for the panel header.header_text_color: Optional text color for the panel header.
| header_color: Optional[str] = None, | ||
| header_text_color: Optional[str] = None, | ||
| responsive: Optional[bool] = True, |
There was a problem hiding this comment.
The new parameters header_color, header_text_color, and responsive are not documented in the docstring. Please add documentation for these parameters in the Args section:
header_color: Optional background color for the legend header panel.header_text_color: Optional text color for the legend header panel.responsive: Whether to enable responsive width behavior. Defaults to True. When True, the legend width adapts to content size within min/max constraints. When False, a fixed width is used.
| .maplibregl-ctrl-widget-panel .widget-panel-content .widget-vbox { | ||
| width: fit-content !important; | ||
| max-width: 100% !important; | ||
| min-width: 0 !important; | ||
| display: block !important; /* Keep block display for proper vertical stacking */ | ||
| } | ||
|
|
||
| /* Ensure HTML widgets within legend size to content but stack vertically */ | ||
| .maplibregl-ctrl-widget-panel .widget-panel-content .widget-html { | ||
| width: fit-content !important; /* Size to content, not full width */ | ||
| max-width: 100% !important; | ||
| display: block !important; /* Block display for vertical stacking */ | ||
| box-sizing: border-box !important; | ||
| } | ||
|
|
||
| /* Ensure legend items stack vertically within the VBox */ | ||
| .maplibregl-ctrl-widget-panel .widget-panel-content .widget-vbox > .widget-html { | ||
| margin-bottom: 4px !important; /* Consistent spacing between items */ | ||
| } | ||
|
|
||
| .maplibregl-ctrl-widget-panel .widget-panel-content .widget-vbox > .widget-html:last-child { | ||
| margin-bottom: 0 !important; /* No margin on last item */ | ||
| } | ||
|
|
||
| /* Ensure the VBox itself doesn't force full width on children */ | ||
| .maplibregl-ctrl-widget-panel .widget-panel-content .widget-vbox { | ||
| flex-direction: column !important; /* Force vertical stacking */ | ||
| align-items: flex-start !important; /* Align items to start, not stretch */ | ||
| } |
There was a problem hiding this comment.
Duplicate CSS rule for .widget-vbox. This selector is defined at both lines 367-372 and 392-395. The second definition at lines 392-395 will override the first. Consider merging these rules to avoid confusion:
.maplibregl-ctrl-widget-panel .widget-panel-content .widget-vbox {
width: fit-content !important;
max-width: 100% !important;
min-width: 0 !important;
display: block !important;
flex-direction: column !important;
align-items: flex-start !important;
}| header_color: Optional[str] = None, | ||
| header_text_color: Optional[str] = None, | ||
| responsive: Optional[bool] = True, | ||
| **kwargs: Union[str, int, float], |
There was a problem hiding this comment.
The type annotation for **kwargs is overly restrictive. It only includes Union[str, int, float], but the code now passes bool values (specifically auto_panel_width). This should be updated to:
**kwargs: Union[str, int, float, bool]| **kwargs: Union[str, int, float], | |
| **kwargs: Union[str, int, float, bool], |