Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(groups): Add the labelClassName prop to groups #263

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading