mirror of
https://github.com/chartdb/chartdb.git
synced 2025-12-21 11:30:42 -06:00
fix: adjust relationship edge offset when cardinality is visible (#973)
This commit is contained in:
@@ -8,6 +8,7 @@ import { useLayout } from '@/hooks/use-layout';
|
|||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { getCardinalityMarkerId } from '../canvas-utils';
|
import { getCardinalityMarkerId } from '../canvas-utils';
|
||||||
import { useDiff } from '@/context/diff-context/use-diff';
|
import { useDiff } from '@/context/diff-context/use-diff';
|
||||||
|
import { useLocalConfig } from '@/hooks/use-local-config';
|
||||||
|
|
||||||
export type RelationshipEdgeType = Edge<
|
export type RelationshipEdgeType = Edge<
|
||||||
{
|
{
|
||||||
@@ -35,6 +36,7 @@ export const RelationshipEdge: React.FC<EdgeProps<RelationshipEdgeType>> =
|
|||||||
useLayout();
|
useLayout();
|
||||||
const { checkIfRelationshipRemoved, checkIfNewRelationship } =
|
const { checkIfRelationshipRemoved, checkIfNewRelationship } =
|
||||||
useDiff();
|
useDiff();
|
||||||
|
const { showCardinality } = useLocalConfig();
|
||||||
|
|
||||||
const { relationships } = useChartDB();
|
const { relationships } = useChartDB();
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ export const RelationshipEdge: React.FC<EdgeProps<RelationshipEdgeType>> =
|
|||||||
sourceSide === 'left' ? Position.Left : Position.Right,
|
sourceSide === 'left' ? Position.Left : Position.Right,
|
||||||
targetPosition:
|
targetPosition:
|
||||||
targetSide === 'left' ? Position.Left : Position.Right,
|
targetSide === 'left' ? Position.Left : Position.Right,
|
||||||
offset: (edgeNumber + 1) * 14,
|
offset: (edgeNumber + 1 + (showCardinality ? 1.5 : 0)) * 14,
|
||||||
});
|
});
|
||||||
return path;
|
return path;
|
||||||
}, [
|
}, [
|
||||||
@@ -157,6 +159,7 @@ export const RelationshipEdge: React.FC<EdgeProps<RelationshipEdgeType>> =
|
|||||||
sourceSide,
|
sourceSide,
|
||||||
targetSide,
|
targetSide,
|
||||||
edgeNumber,
|
edgeNumber,
|
||||||
|
showCardinality,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const sourceMarker = useMemo(
|
const sourceMarker = useMemo(
|
||||||
|
|||||||
Reference in New Issue
Block a user