Skip to content

Commit 134500b

Browse files
committed
feat: add external link and copy icons, implement node and link click handlers in dashboard
1 parent 6fa43cd commit 134500b

7 files changed

Lines changed: 519 additions & 108 deletions

File tree

components/icons.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,41 @@ export function PauseIconSmall(props: { className?: string }) {
141141
</svg>
142142
);
143143
}
144+
145+
export function ExternalLinkIcon(props: { className?: string }) {
146+
return (
147+
<svg
148+
xmlns="http://www.w3.org/2000/svg"
149+
fill="none"
150+
viewBox="0 0 24 24"
151+
strokeWidth={2}
152+
stroke="currentColor"
153+
className={props.className || "w-4 h-4"}
154+
>
155+
<path
156+
strokeLinecap="round"
157+
strokeLinejoin="round"
158+
d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"
159+
/>
160+
</svg>
161+
);
162+
}
163+
164+
export function CopyIcon(props: { className?: string }) {
165+
return (
166+
<svg
167+
xmlns="http://www.w3.org/2000/svg"
168+
fill="none"
169+
viewBox="0 0 24 24"
170+
strokeWidth={2}
171+
stroke="currentColor"
172+
className={props.className || "w-4 h-4"}
173+
>
174+
<path
175+
strokeLinecap="round"
176+
strokeLinejoin="round"
177+
d="M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"
178+
/>
179+
</svg>
180+
);
181+
}

components/network-graph/network-graph-2d.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ export const NetworkGraph2d = React.memo(function NetworkGraph2d({
4545
linkDistance = DEFAULT_PHYSICS.linkDistance,
4646
centerGravity = DEFAULT_PHYSICS.centerGravity,
4747
animate = true,
48+
onNodeClick,
49+
onLinkClick,
4850
}: GraphComponentProps) {
4951
const [ForceGraph2D, setForceGraph2D] = useState<any>(null);
5052
const graphRef = useRef<any>(null);
@@ -80,9 +82,17 @@ export const NetworkGraph2d = React.memo(function NetworkGraph2d({
8082
cleanupPulses();
8183
}, [configureForces, cleanupPulses]);
8284

83-
const handleClick = useCallback((node: Nodes[0]) => {
84-
navigator.clipboard.writeText(node.id);
85-
}, []);
85+
const handleNodeClick = useCallback((node: Nodes[0]) => {
86+
if (onNodeClick) {
87+
onNodeClick(node);
88+
}
89+
}, [onNodeClick]);
90+
91+
const handleLinkClick = useCallback((link: Link) => {
92+
if (onLinkClick) {
93+
onLinkClick(link);
94+
}
95+
}, [onLinkClick]);
8696

8797
const nodeCanvasObject = useCallback(
8898
(node: any, ctx: CanvasRenderingContext2D, _globalScale: number) => {
@@ -186,7 +196,8 @@ export const NetworkGraph2d = React.memo(function NetworkGraph2d({
186196
nodeAutoColorBy={(n: Nodes[0]) => Object.keys(n.usedVouchers)[0]}
187197
backgroundColor={GRAPH_CONFIG.backgroundColor}
188198
graphData={displayedData}
189-
onNodeClick={handleClick}
199+
onNodeClick={handleNodeClick}
200+
onLinkClick={handleLinkClick}
190201
onEngineTick={handleEngineTick}
191202
linkAutoColorBy="contract_address"
192203
nodeCanvasObject={nodeCanvasObject}

0 commit comments

Comments
 (0)