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

🚸 add glowing shadow filter and enhance highlight animation in RelationshipEdge component #361

Closed
wants to merge 6 commits into from
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.edge {
stroke: var(--pane-border-hover);
stroke-dasharray: 2;
--xy-edge-stroke: var(--pane-border-hover);

stroke-width: 1px;
transition: stroke 0.3s var(--default-timing-function);
}

Expand All @@ -14,5 +15,5 @@ marker {
}

.hovered {
stroke: var(--node-layout);
--xy-edge-stroke: var(--node-layout);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { BaseEdge, type EdgeProps, getBezierPath } from '@xyflow/react'

import clsx from 'clsx'
import type { FC } from 'react'
import styles from './RelationshipEdge.module.css'
import type { RelationshipEdgeType } from './type'

const PARTICLE_COUNT = 6
const ANIMATE_DURATION = 3

type Props = EdgeProps<RelationshipEdgeType>

export const RelationshipEdge: FC<Props> = ({
Expand Down Expand Up @@ -47,6 +49,42 @@ export const RelationshipEdge: FC<Props> = ({
}
className={clsx(styles.edge, data?.isHighlighted && styles.hovered)}
/>
<defs>
<radialGradient
id="myGradient"
cx="50%"
cy="50%"
r="50%"
fx="50%"
fy="50%"
>
<stop offset="0%" stopColor="var(--node-layout)" stopOpacity="1" />
<stop
offset="100%"
stopColor="var(--node-layout)"
stopOpacity="0.4"
/>
</radialGradient>
</defs>
{data?.isHighlighted &&
[...Array(PARTICLE_COUNT)].map((_, i) => (
<ellipse
key={`particle-${i}-${ANIMATE_DURATION}`}
rx="5"
ry="1.6"
fill="url(#myGradient)"
>
<animateMotion
begin={`${i * (ANIMATE_DURATION / PARTICLE_COUNT)}s`}
dur={`${ANIMATE_DURATION}s`}
repeatCount="indefinite"
rotate="auto"
path={edgePath}
calcMode="spline"
keySplines="0.42, 0, 0.58, 1.0"
/>
</ellipse>
))}
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const unhighlightNode = (node: TableNodeType): TableNodeType => ({

const highlightEdge = (edge: Edge): Edge => ({
...edge,
animated: true,
animated: false,
zIndex: zIndex.edgeHighlighted,
data: { ...edge.data, isHighlighted: true },
})
Expand Down
Loading