diff --git a/packages/base/src/dialogs/symbology/components/color_ramp/ColorRamp.tsx b/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampControls.tsx similarity index 80% rename from packages/base/src/dialogs/symbology/components/color_ramp/ColorRamp.tsx rename to packages/base/src/dialogs/symbology/components/color_ramp/ColorRampControls.tsx index 008bec47b..0d2d7050b 100644 --- a/packages/base/src/dialogs/symbology/components/color_ramp/ColorRamp.tsx +++ b/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampControls.tsx @@ -1,13 +1,32 @@ +/** + * @module ColorRampControls + * + * This component provides the main UI controls for classifying raster layers + * using different color ramps and classification modes. + * + * Allows users to: + * - Select a color ramp (`ColorRampSelector`) + * - Choose classification mode and number of classes (`ModeSelectRow`) + * - Run classification via `classifyFunc`, with loading state (`LoadingIcon`) + * + * Props: + * - `modeOptions`: Available classification modes. + * - `layerParams`: Layer symbology state. + * - `classifyFunc`: Callback for classification. + * - `showModeRow`: Toggle for mode selector. + * - `showRampSelector`: Toggle for ramp selector. + */ + import { IDict } from '@jupytergis/schema'; import { Button } from '@jupyterlab/ui-components'; import React, { useEffect, useState } from 'react'; import { LoadingIcon } from '@/src/shared/components/loading'; -import CanvasSelectComponent from './CanvasSelectComponent'; +import ColorRampSelector from './ColorRampSelector'; import ModeSelectRow from './ModeSelectRow'; import { COLOR_RAMP_DEFAULTS, ColorRampName } from '../../colorRampUtils'; -interface IColorRampProps { +interface IColorRampControlsProps { modeOptions: string[]; layerParams: IDict; classifyFunc: ( @@ -20,13 +39,13 @@ interface IColorRampProps { showRampSelector: boolean; } -export type ColorRampOptions = { +export type ColorRampControlsOptions = { selectedRamp: string; numberOfShades: string; selectedMode: string; }; -const ColorRamp: React.FC = ({ +const ColorRampControls: React.FC = ({ layerParams, modeOptions, classifyFunc, @@ -99,7 +118,7 @@ const ColorRamp: React.FC = ({ {showRampSelector && (
- @@ -144,4 +163,4 @@ const ColorRamp: React.FC = ({ ); }; -export default ColorRamp; +export default ColorRampControls; diff --git a/packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx b/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampSelector.tsx similarity index 77% rename from packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx rename to packages/base/src/dialogs/symbology/components/color_ramp/ColorRampSelector.tsx index 31877b530..3cb958cdb 100644 --- a/packages/base/src/dialogs/symbology/components/color_ramp/CanvasSelectComponent.tsx +++ b/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampSelector.tsx @@ -1,20 +1,33 @@ +/** + * @module ColorRampSelector + * + * Dropdown component for selecting a color ramp. + * - Displays the currently selected ramp as a preview on a canvas. + * - Expands to show a list of available ramps (`ColorRampSelectorEntry`). + * - Updates the preview and notifies parent via `setSelected` when a ramp is chosen. + * + * Props: + * - `selectedRamp`: Name of the currently selected color ramp. + * - `setSelected`: Callback fired with the new ramp when selected. + */ + import { Button } from '@jupyterlab/ui-components'; import React, { useEffect, useRef, useState } from 'react'; import { useColorMapList } from '@/src/dialogs/symbology/colorRampUtils'; -import ColorRampEntry from './ColorRampEntry'; +import ColorRampSelectorEntry from './ColorRampSelectorEntry'; export interface IColorMap { name: string; colors: string[]; } -interface ICanvasSelectComponentProps { +interface IColorRampSelectorProps { selectedRamp: string; setSelected: (item: any) => void; } -const CanvasSelectComponent: React.FC = ({ +const ColorRampSelector: React.FC = ({ selectedRamp, setSelected, }) => { @@ -108,11 +121,15 @@ const CanvasSelectComponent: React.FC = ({ className={`jp-gis-color-ramp-dropdown ${isOpen ? 'jp-gis-open' : ''}`} > {colorMaps.map((item, index) => ( - + ))}
); }; -export default CanvasSelectComponent; +export default ColorRampSelector; diff --git a/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampEntry.tsx b/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampSelectorEntry.tsx similarity index 64% rename from packages/base/src/dialogs/symbology/components/color_ramp/ColorRampEntry.tsx rename to packages/base/src/dialogs/symbology/components/color_ramp/ColorRampSelectorEntry.tsx index 80f3a1e86..4bcaf4615 100644 --- a/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampEntry.tsx +++ b/packages/base/src/dialogs/symbology/components/color_ramp/ColorRampSelectorEntry.tsx @@ -1,14 +1,26 @@ +/** + * @module ColorRampSelectorEntry + * + * Represents a single selectable color ramp option in the `ColorRampSelector`. + * Renders a preview ColorRamp on a canvas and triggers `onClick` when selected. + * + * Props: + * - `index`: Unique index for canvas ID. + * - `colorMap`: Ramp definition including name and colors. + * - `onClick`: Callback fired with the ramp name when clicked. + */ + import React, { useEffect } from 'react'; -import { IColorMap } from './CanvasSelectComponent'; +import { IColorMap } from './ColorRampSelector'; -interface IColorRampEntryProps { +interface IColorRampSelectorEntryProps { index: number; colorMap: IColorMap; onClick: (item: any) => void; } -const ColorRampEntry: React.FC = ({ +const ColorRampSelectorEntry: React.FC = ({ index, colorMap, onClick, @@ -57,4 +69,4 @@ const ColorRampEntry: React.FC = ({ ); }; -export default ColorRampEntry; +export default ColorRampSelectorEntry; diff --git a/packages/base/src/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.tsx b/packages/base/src/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.tsx index 0cc58f61d..f72ae8a71 100644 --- a/packages/base/src/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.tsx +++ b/packages/base/src/dialogs/symbology/tiff_layer/types/SingleBandPseudoColor.tsx @@ -5,9 +5,9 @@ import { ExpressionValue } from 'ol/expr/expression'; import React, { useEffect, useRef, useState } from 'react'; import { GeoTiffClassifications } from '@/src/dialogs/symbology/classificationModes'; -import ColorRamp, { - ColorRampOptions, -} from '@/src/dialogs/symbology/components/color_ramp/ColorRamp'; +import ColorRampControls, { + ColorRampControlsOptions, +} from '@/src/dialogs/symbology/components/color_ramp/ColorRampControls'; import StopRow from '@/src/dialogs/symbology/components/color_stops/StopRow'; import useGetBandInfo, { IBandRow, @@ -50,13 +50,13 @@ const SingleBandPseudoColor: React.FC = ({ const [selectedFunction, setSelectedFunction] = useState('linear'); const [colorRampOptions, setColorRampOptions] = useState< - ColorRampOptions | undefined + ColorRampControlsOptions | undefined >(); const stopRowsRef = useRef(); const bandRowsRef = useRef([]); const selectedFunctionRef = useRef(); - const colorRampOptionsRef = useRef(); + const colorRampOptionsRef = useRef(); const selectedBandRef = useRef(); useEffect(() => { @@ -404,7 +404,7 @@ const SingleBandPseudoColor: React.FC = ({ {bandRows.length > 0 && ( - = ({ )}
- = ({ const symbologyTabRef = useRef(); const colorStopRowsRef = useRef([]); const radiusStopRowsRef = useRef([]); - const colorRampOptionsRef = useRef(); + const colorRampOptionsRef = useRef(); const [selectedAttribute, setSelectedAttribute] = useState(''); const [colorStopRows, setColorStopRows] = useState([]); const [radiusStopRows, setRadiusStopRows] = useState([]); const [colorRampOptions, setColorRampOptions] = useState< - ColorRampOptions | undefined + ColorRampControlsOptions | undefined >(); const [colorManualStyle, setColorManualStyle] = useState({ strokeColor: '#3399CC', @@ -381,7 +381,7 @@ const Graduated: React.FC = ({
)} - = ({ @@ -99,7 +99,7 @@ const Heatmap: React.FC = ({

Represent features based on their density using a heatmap.

-