Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,24 @@ export const StyledLine = styled.div<{ $isVertical: boolean; $selected: boolean;
transition: border-color 0.2s ease-in-out;
`;

export const StyledLabel = styled.div<{ $position: Position; $backgroundColor: string }>`
export const StyledLabel = styled.div<{
$position: Position;
$backgroundColor: string;
$shouldTruncate?: boolean;
}>`
position: absolute;
background-color: ${(p) => p.$backgroundColor};
padding: 2px 6px;
border-radius: 4px;
z-index: 1;
white-space: nowrap;
user-select: none;
${(p) =>
p.$shouldTruncate &&
css`
max-width: 50px;
overflow: hidden;
`}

${(p) =>
p.$position === Position.Top &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ const ButtonHandleBase = ({
const markAsHovered = useCallback(() => setIsHovered(true), []);
const unmarkAsHovered = useCallback(() => setIsHovered(false), []);

const shouldTruncateLabel = useMemo(() => {
return showButton && !!onAction && type === 'source' && !isVertical;
}, [showButton, onAction, type, isVertical]);

return (
<StyledHandle
type={type}
Expand All @@ -162,12 +166,25 @@ const ButtonHandleBase = ({
onMouseDown={unmarkAsHovered}
>
{label && (
<StyledLabel $position={position} $backgroundColor={labelBackgroundColor}>
<StyledLabel
$position={position}
$backgroundColor={labelBackgroundColor}
$shouldTruncate={shouldTruncateLabel}
>
<Row align="center" gap={4}>
{labelIcon}
<ApTypography
color="var(--uix-canvas-foreground-de-emp)"
variant={FontVariantToken.fontSizeSBold}
sx={
shouldTruncateLabel
? {
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}
: undefined
}
>
{label}
</ApTypography>
Expand Down
Loading