Skip to content

Commit

Permalink
Merge pull request #263 from jenny-s51/iss255
Browse files Browse the repository at this point in the history
feat(groups): Add the labelClassName prop to groups
  • Loading branch information
dlabaj authored Dec 12, 2024
2 parents bd2cbfe + 68864a5 commit 059983d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/module/src/components/groups/DefaultGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface DefaultGroupProps {
secondaryLabel?: string;
/** Flag to show the label */
showLabel?: boolean; // Defaults to true
/** Additional classes to add to the label */
labelClassName?: string;
/** Flag to show the label when hovering (effects expanded only) */
showLabelOnHover?: boolean;
/** Position of the label, top or bottom. Defaults to element.getLabelPosition() or bottom */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type DefaultGroupCollapsedProps = {
badgeBorderColor?: string;
badgeClassName?: string;
badgeLocation?: BadgeLocation;
labelClassName?: string;
} & CollapsibleGroupProps &
WithDragNodeProps &
WithSelectionProps &
Expand Down Expand Up @@ -84,7 +85,8 @@ const DefaultGroupCollapsed: React.FunctionComponent<DefaultGroupCollapsedProps>
badgeLocation,
labelIconClass,
labelIcon,
labelIconPadding
labelIconPadding,
labelClassName
}) => {
const [hovered, hoverRef] = useHover();
const [labelHover, labelHoverRef] = useHover();
Expand Down Expand Up @@ -156,7 +158,7 @@ const DefaultGroupCollapsed: React.FunctionComponent<DefaultGroupCollapsedProps>
)}
{showLabel && (
<NodeLabel
className={styles.topologyGroupLabel}
className={css(styles.topologyGroupLabel, labelClassName)}
x={collapsedWidth / 2}
y={labelPosition === LabelPosition.top ? collapsedHeight / 2 - collapsedHeight : collapsedHeight + 6}
paddingX={8}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type DefaultGroupExpandedProps = {
badgeBorderColor?: string;
badgeClassName?: string;
badgeLocation?: BadgeLocation;
labelClassName?: string;
labelIconClass?: string; // Icon to show in label
labelIcon?: string;
labelPosition?: LabelPosition;
Expand Down Expand Up @@ -138,6 +139,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
badgeBorderColor,
badgeClassName,
badgeLocation,
labelClassName,
labelIconClass,
labelIcon,
labelPosition,
Expand Down Expand Up @@ -252,7 +254,7 @@ const DefaultGroupExpanded: React.FunctionComponent<DefaultGroupExpandedProps> =
(showLabel || (showLabelOnHover && isHover)) && (label || element.getLabel()) ? (
<g ref={labelHoverRef} transform={isHover ? `scale(${labelScale})` : undefined}>
<NodeLabel
className={styles.topologyGroupLabel}
className={css(styles.topologyGroupLabel, labelClassName)}
x={startX * labelPositionScale}
y={startY * labelPositionScale}
paddingX={8}
Expand Down

0 comments on commit 059983d

Please sign in to comment.