From 6daba1cec806a3ac9a75ebf98bdfcbf82291b7ea Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 9 Nov 2026 01:39:12 +0000 Subject: [PATCH] Refactor GCodePreview and GCodeLegend Components for Improved Rendering and Interaction - Updated GCodePreview to conditionally render the GCodeLegend based on line type, enhancing the user interface for different modes. - Simplified the loading overlay in GCodePreview for better visibility and responsiveness during loading states. - Replaced InputNumber with InputNumberCal in GCodeLegend for improved functionality and user experience. - Adjusted styles and layout in both components to ensure consistent presentation and interaction across different scenarios. --- .../Components/GCodePreview/GCodePreview.jsx | 75 ++++++++++--------- .../GCodePreview/GCodeViewer/GCodeLegend.jsx | 24 +++--- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/components/Components/GCodePreview/GCodePreview.jsx b/src/components/Components/GCodePreview/GCodePreview.jsx index aa76351a..d521f0aa 100644 --- a/src/components/Components/GCodePreview/GCodePreview.jsx +++ b/src/components/Components/GCodePreview/GCodePreview.jsx @@ -710,6 +710,22 @@ function GCodePreview(props) { const loadingLabel = loader.planning ? 'Calculating motion...' : `Parsing G-code... ${segmentCount.toLocaleString()} moves` + const isLineType = mode.kind === 'category' + const legend = + model && (ready || segmentCount > 0) ? ( + setShowTravel((prev) => !prev)} + range={displayRange} + autoRange={autoRange || displayRange} + onRangeChange={handleRangeChange} + /> + ) : null return ( ) : null} + {legend && !isLineType ? ( + + {legend} + + ) : null} - {model && (ready || segmentCount > 0) ? ( - setShowTravel((prev) => !prev)} - range={displayRange} - autoRange={autoRange || displayRange} - onRangeChange={handleRangeChange} - /> - ) : null} + {legend && isLineType ? legend : null}
- + - - {loadingLabel} - - + + + {loadingLabel} + + +
) : null} diff --git a/src/components/Components/GCodePreview/GCodeViewer/GCodeLegend.jsx b/src/components/Components/GCodePreview/GCodeViewer/GCodeLegend.jsx index d8319d22..28b0e2ec 100644 --- a/src/components/Components/GCodePreview/GCodeViewer/GCodeLegend.jsx +++ b/src/components/Components/GCodePreview/GCodeViewer/GCodeLegend.jsx @@ -1,7 +1,8 @@ import PropTypes from 'prop-types' -import { Button, Flex, InputNumber, Typography } from 'antd' +import { Button, Flex, Typography } from 'antd' import { FEATURE, FEATURE_INFO } from './featureTypes.js' import { TOOL_PALETTE, rampCss } from './colorModes.js' +import InputNumberCal from '../../../Dashboard/common/InputNumberCal.jsx' const { Text } = Typography @@ -151,21 +152,19 @@ function GCodeLegend({ autoRange != null && (range.min !== autoRange.min || range.max !== autoRange.max) const isDuration = mode.stat === 'layerTime' + const unitSuffix = mode.unit || undefined return ( - - {mode.label} - {isDuration ? ( {format(min)} ) : ( - Number.isFinite(value) && onRangeChange({ min: value, max }) } - style={{ width: 80 }} + suffix={unitSuffix} + style={{ width: 100 }} controls={false} /> )} @@ -180,21 +179,16 @@ function GCodeLegend({ {isDuration ? ( {format(max)} ) : ( - Number.isFinite(value) && onRangeChange({ min, max: value }) } - style={{ width: 80 }} + suffix={unitSuffix} + style={{ width: 100 }} controls={false} /> )} - {mode.unit ? ( - - {mode.unit} - - ) : null} {overridden ? (