@@ -54,6 +54,8 @@ const getStatusIcon = (status: NodeStatus) => {
5454} ;
5555
5656type BaseNodeProps = {
57+ children ?: React . ReactNode ;
58+ className ?: string ;
5759 element : Node ;
5860 droppable ?: boolean ;
5961 hover ?: boolean ;
@@ -66,9 +68,10 @@ type BaseNodeProps = {
6668 label ?: string ; // Defaults to element.getLabel()
6769 secondaryLabel ?: string ;
6870 showLabel ?: boolean ; // Defaults to true
69- labelPosition ?: LabelPosition ; // Defaults to bottom
71+ labelPosition ?: LabelPosition ; // Defaults to element.getLabelPosition()
7072 truncateLength ?: number ; // Defaults to 13
7173 labelIconClass ?: string ; // Icon to show in label
74+ labelIcon ?: React . ReactNode ;
7275 labelIconPadding ?: number ;
7376 badge ?: string ;
7477 badgeColor ?: string ;
@@ -82,7 +85,7 @@ type BaseNodeProps = {
8285 statusDecoratorTooltip ?: React . ReactNode ;
8386 onStatusDecoratorClick ?: ( event : React . MouseEvent < SVGGElement , MouseEvent > , element : GraphElement ) => void ;
8487 getCustomShape ?: ( node : Node ) => React . FC < ShapeProps > ;
85- getShapeDecoratorCenter ?: ( quadrant : TopologyQuadrant , node : Node , radius ?: number ) => { x : number ; y : number } ;
88+ getShapeDecoratorCenter ?: ( quadrant : TopologyQuadrant , node : Node ) => { x : number ; y : number } ;
8689} & Partial <
8790 WithSelectionProps &
8891 WithDragNodeProps &
@@ -96,6 +99,7 @@ type BaseNodeProps = {
9699// to support shadow / hover behaviors
97100
98101const BaseNode : React . FC < BaseNodeProps > = ( {
102+ className,
99103 element,
100104 selected,
101105 hover,
@@ -104,9 +108,11 @@ const BaseNode: React.FC<BaseNodeProps> = ({
104108 shadowed,
105109 highlighted,
106110 secondaryLabel,
107- labelPosition = LabelPosition . bottom ,
111+ labelPosition,
108112 truncateLength,
109113 labelIconClass,
114+ labelIcon,
115+ labelIconPadding,
110116 showStatusBackground,
111117 showStatusDecorator = false ,
112118 statusDecoratorTooltip,
@@ -149,8 +155,8 @@ const BaseNode: React.FC<BaseNodeProps> = ({
149155 }
150156
151157 const { x, y } = getShapeDecoratorCenter
152- ? getShapeDecoratorCenter ( StatusQuadrant , element , DEFAULT_DECORATOR_RADIUS )
153- : getDefaultShapeDecoratorCenter ( StatusQuadrant , element , DEFAULT_DECORATOR_RADIUS ) ;
158+ ? getShapeDecoratorCenter ( StatusQuadrant , element )
159+ : getDefaultShapeDecoratorCenter ( StatusQuadrant , element ) ;
154160
155161 const decorator = (
156162 < Decorator
@@ -191,8 +197,10 @@ const BaseNode: React.FC<BaseNodeProps> = ({
191197
192198 const groupClassName = css (
193199 styles . topologyNode ,
200+ className ,
194201 isHover && 'pf-m-hover' ,
195202 ( dragging || edgeDragging ) && 'pf-m-dragging' ,
203+ canDrop && 'pf-m-highlight' ,
196204 canDrop && dropTarget && 'pf-m-drop-target' ,
197205 selected && 'pf-m-selected' ,
198206 StatusModifier [ status ] ,
@@ -214,6 +222,8 @@ const BaseNode: React.FC<BaseNodeProps> = ({
214222 filter = createSvgIdUrl ( NODE_SHADOW_FILTER_ID_HOVER ) ;
215223 }
216224
225+ const nodeLabelPosition = labelPosition || element . getLabelPosition ( ) ;
226+
217227 return (
218228 < Layer id = { dragging || isHover || highlighted ? TOP_LAYER : undefined } >
219229 < g ref = { hoverRef as React . LegacyRef < SVGGElement > | undefined } className = { groupClassName } >
@@ -232,9 +242,9 @@ const BaseNode: React.FC<BaseNodeProps> = ({
232242 { showLabel && ( label || element . getLabel ( ) ) && (
233243 < NodeLabel
234244 className = { css ( styles . topologyNodeLabel ) }
235- x = { labelPosition === LabelPosition . right ? width + 8 : width / 2 }
236- y = { labelPosition === LabelPosition . right ? height / 2 : height + 6 }
237- position = { labelPosition }
245+ x = { nodeLabelPosition === LabelPosition . right ? width + 8 : width / 2 }
246+ y = { nodeLabelPosition === LabelPosition . right ? height / 2 : height + 6 }
247+ position = { nodeLabelPosition }
238248 paddingX = { 8 }
239249 paddingY = { 4 }
240250 secondaryLabel = { secondaryLabel }
@@ -250,6 +260,8 @@ const BaseNode: React.FC<BaseNodeProps> = ({
250260 contextMenuOpen = { contextMenuOpen ? true : false }
251261 hover = { isHover }
252262 labelIconClass = { labelIconClass }
263+ labelIcon = { labelIcon }
264+ labelIconPadding = { labelIconPadding }
253265 >
254266 { label || element . getLabel ( ) }
255267 </ NodeLabel >
0 commit comments