@@ -5,12 +5,10 @@ import React, { useCallback, useEffect, useMemo, useRef } from "react";
55import type { TypographyStyle } from "@/lib/constants/typography" ;
66import { DEFAULT_FONT_FAMILY , LEGEND_TYPOGRAPHY_DEFAULTS } from "@/lib/constants/typography" ;
77import { rgbToHex } from "@/lib/utils/helpers" ;
8- import { getLegendColorMap } from "@/lib/utils/map/legend" ;
98import type { RGBColor } from "@/types/map/color" ;
109import type { ProjectLayer } from "@/lib/validations/project" ;
1110import type { ReportElement } from "@/lib/validations/reportLayout" ;
1211
13- import { ICON_NAME , Icon } from "@p4b/ui/components/Icon" ;
1412import { LayerIcon } from "@/components/map/panels/layer/legend/LayerIcon" ;
1513import { LayerLegendPanel } from "@/components/map/panels/layer/legend/LayerLegend" ;
1614
@@ -317,31 +315,6 @@ interface LayerLegendItemProps {
317315 onTextSave ?: ( key : string , text : string ) => void ;
318316}
319317
320- /**
321- * Small gradient swatch icon for complex (classified) layers.
322- * Shows a horizontal gradient of the layer's classification colors.
323- */
324- const GradientSwatch : React . FC < { colors : string [ ] } > = ( { colors } ) => {
325- if ( colors . length === 0 ) return null ;
326- const bg = colors . length === 1
327- ? colors [ 0 ]
328- : `linear-gradient(to right, ${ colors . join ( ", " ) } )` ;
329- return (
330- < svg height = "20" width = "20" style = { { display : "block" , flexShrink : 0 } } >
331- < defs >
332- < linearGradient id = { `grad-${ colors . join ( "-" ) . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, "" ) } ` } x1 = "0" x2 = "1" y1 = "0" y2 = "0" >
333- { colors . map ( ( c , i ) => (
334- < stop key = { i } offset = { `${ ( i / Math . max ( colors . length - 1 , 1 ) ) * 100 } %` } stopColor = { c } />
335- ) ) }
336- </ linearGradient >
337- </ defs >
338- < rect
339- x = "4" y = "4" width = "12" height = "12" rx = "2"
340- fill = { colors . length === 1 ? bg : `url(#grad-${ colors . join ( "-" ) . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, "" ) } )` }
341- />
342- </ svg >
343- ) ;
344- } ;
345318
346319const LayerLegendItem : React . FC < LayerLegendItemProps > = ( {
347320 layer,
@@ -369,15 +342,6 @@ const LayerLegendItem: React.FC<LayerLegendItemProps> = ({
369342 ( ( rasterStyle . style_type === "categories" && Array . isArray ( rasterStyle . categories ) && rasterStyle . categories . length > 0 ) ||
370343 ( rasterStyle . style_type === "color_range" && Array . isArray ( rasterStyle . color_map ) && rasterStyle . color_map . length > 0 ) ) ;
371344
372- // Collect gradient colors for complex layers
373- const gradientColors = useMemo ( ( ) => {
374- if ( ! hasComplexLegend ) return [ ] ;
375- const colorMap = getLegendColorMap ( props , "color" ) ;
376- const strokeMap = getLegendColorMap ( props , "stroke_color" ) ;
377- const colors = ( colorMap . length > 1 ? colorMap : strokeMap ) . map ( ( item ) => item . color ) . filter ( Boolean ) ;
378- return colors ;
379- } , [ hasComplexLegend , props ] ) ;
380-
381345 // Simple icon props (same logic as ProjectLayerTree lines 813-842)
382346 const baseColor : string = props . color
383347 ? Array . isArray ( props . color ) && ( props . color as number [ ] ) . length >= 3
@@ -399,18 +363,13 @@ const LayerLegendItem: React.FC<LayerLegendItemProps> = ({
399363 { /* Layer name with icon */ }
400364 { showLayerName && ( ( ) => {
401365 const isComplex = hasComplexLegend || hasRasterLegend ;
402- const hasColors = gradientColors . length > 0 ;
403- const showMarkerIcon = isComplex && ! hasColors && ! ! props . marker_field && ! ! props . custom_marker ;
404- const showGeometryIcon = ! isComplex || ( isComplex && ! hasColors && ! showMarkerIcon ) ;
405- const showGradient = isComplex && hasColors ;
366+ const layerNameKey = `layer_ ${ layer . id } ` ;
367+ const layerNameCleared = editable && textOverrides ?. [ layerNameKey ] != null && ! textOverrides [ layerNameKey ] . trim ( ) ;
368+ // Hide the layer name row entirely when user has cleared the text
369+ if ( layerNameCleared ) return null ;
406370 return (
407371 < Stack direction = "row" alignItems = "center" spacing = { 0.5 } sx = { { mb : 0.5 } } >
408- { showMarkerIcon && (
409- < Box sx = { { flexShrink : 0 , width : 20 , height : 20 , display : "flex" , justifyContent : "center" , alignItems : "center" } } >
410- < Icon iconName = { ICON_NAME . LOCATION_MARKER } style = { { fontSize : "14px" , color : "#999" } } />
411- </ Box >
412- ) }
413- { showGeometryIcon && (
372+ { ! isComplex && (
414373 < Box sx = { { flexShrink : 0 } } >
415374 < LayerIcon
416375 type = { geomType }
@@ -430,9 +389,6 @@ const LayerLegendItem: React.FC<LayerLegendItemProps> = ({
430389 />
431390 </ Box >
432391 ) }
433- { showGradient && (
434- < GradientSwatch colors = { gradientColors } />
435- ) }
436392 < EditableText
437393 text = { editable && textOverrides ?. [ `layer_${ layer . id } ` ] ? textOverrides [ `layer_${ layer . id } ` ] : layer . name }
438394 editable = { editable }
0 commit comments