Refactor: Improve readability and maintainability of Crane Visualizer panel #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit applies a series of refactorings to the crane visualizer panel to enhance code clarity, structure, and ease of future maintenance.
Key changes include:
SVG Interaction Hook:
CraneVisualizer
into a reusableusePanZoom
custom hook (src/hooks/usePanZoom.ts
).Centralized Configuration Management:
usePanelConfig
custom hook (src/hooks/usePanelConfig.ts
) nowmanages the panel's configuration state (background color, viewBox
width, namespace visibility).
PanelConfig
andNamespaceConfig
.Settings Panel Utilities:
createNamespaceFields
) and handlingsettings actions (
handleSettingsAction
) moved tosrc/settings_utils.ts
.PanelConfig
,NamespaceConfig
) also centralized here.Readability Enhancements in
CraneVisualizer
:DEFAULT_TOPIC
,DEFAULT_VIEWBOX_ASPECT_RATIO
) insrc/constants.ts
.clarify complex logic and hook dependencies.
InfoDisplay
component).recv_num
toreceivedMessageCount
).Code Cleanup:
usePanZoom
).handleCheckboxChange
function fromCraneVisualizer
as namespace visibility is now solely managed by the settings panel.
These changes aim to make the codebase more modular, easier to understand, and more robust for future development.