Skip to content

Commit b59995c

Browse files
committed
feat(web): add prominent direction indicators to relationship items
- Add color-coded badges for Incoming (green) and Outgoing (blue) relationships - Include arrow icons (left arrow for incoming, right arrow for outgoing) - Add tooltips explaining direction meaning - Improve self-reference badge styling - Enhance entity name typography with bold weight - Improve layout with proper spacing and wrapping Makes relationship navigation more intuitive by clearly showing the direction of connections at a glance.
1 parent b697380 commit b59995c

File tree

1 file changed

+50
-12
lines changed

1 file changed

+50
-12
lines changed

apps/web/src/components/relationship/RelationshipItem.tsx

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
* @see specs/016-entity-relationship-viz/data-model.md
66
*/
77

8-
import { Anchor, Group, Stack, Text } from '@mantine/core';
8+
import { Anchor, Badge, Group, Stack, Text, Tooltip } from '@mantine/core';
9+
import { IconArrowDownLeft, IconArrowRight } from '@tabler/icons-react';
910
import { useNavigate } from '@tanstack/react-router';
1011
import React from 'react';
1112

13+
import { ICON_SIZE } from '@/config/style-constants';
1214
import type { RelationshipItem as RelationshipItemType } from '@/types/relationship';
1315
import { decodeHtmlEntities } from '@/utils/decode-html-entities';
1416
import { formatMetadata } from '@/utils/formatMetadata';
@@ -72,25 +74,61 @@ export const RelationshipItem: React.FC<RelationshipItemProps> = ({ item }) => {
7274
// Otherwise, let the browser handle it (opens in new tab, etc.)
7375
};
7476

77+
// Direction indicator configuration
78+
const getDirectionBadge = () => {
79+
const isOutbound = item.direction === 'outbound';
80+
81+
return (
82+
<Tooltip
83+
label={isOutbound ? 'This entity references the related entity' : 'The related entity references this one'}
84+
position="top"
85+
>
86+
<Badge
87+
size="xs"
88+
variant="light"
89+
color={isOutbound ? 'blue' : 'green'}
90+
leftSection={
91+
isOutbound ? (
92+
<IconArrowRight size={ICON_SIZE.XS} />
93+
) : (
94+
<IconArrowDownLeft size={ICON_SIZE.XS} />
95+
)
96+
}
97+
>
98+
{isOutbound ? 'Outgoing' : 'Incoming'}
99+
</Badge>
100+
</Tooltip>
101+
);
102+
};
103+
75104
return (
76105
<Stack gap="xs" data-testid={`relationship-item-${item.id}`}>
77-
<Group gap="xs">
78-
<Anchor href={entityUrl} onClick={handleClick} size="sm">
79-
{decodeHtmlEntities(item.displayName || cleanEntityId)}
80-
</Anchor>
81-
{item.isSelfReference && (
82-
<Text size="xs" c="dimmed">
83-
(self-reference)
84-
</Text>
85-
)}
106+
<Group gap="sm" justify="space-between" align="start" wrap="nowrap">
107+
<Group gap="xs" style={{ flex: 1, minWidth: 0 }}>
108+
{getDirectionBadge()}
109+
<Anchor
110+
href={entityUrl}
111+
onClick={handleClick}
112+
size="sm"
113+
fw={500}
114+
style={{ wordBreak: 'break-word' }}
115+
>
116+
{decodeHtmlEntities(item.displayName || cleanEntityId)}
117+
</Anchor>
118+
{item.isSelfReference && (
119+
<Badge size="xs" variant="outline" color="gray">
120+
Self
121+
</Badge>
122+
)}
123+
</Group>
86124
</Group>
87125
{item.subtitle && (
88-
<Text size="xs" c="dimmed" data-testid="relationship-subtitle">
126+
<Text size="xs" c="dimmed" data-testid="relationship-subtitle" ml={4}>
89127
{decodeHtmlEntities(item.subtitle)}
90128
</Text>
91129
)}
92130
{item.metadata && (
93-
<Text size="xs" c="dimmed" data-testid="relationship-metadata">
131+
<Text size="xs" c="dimmed" data-testid="relationship-metadata" ml={4}>
94132
{formatMetadata(item.metadata)}
95133
</Text>
96134
)}

0 commit comments

Comments
 (0)