@@ -2,6 +2,7 @@ import { buildGraphForReferences, getLayoutedElements } from "@/components/graph
2
2
import {
3
3
Background ,
4
4
BackgroundVariant ,
5
+ ColorMode ,
5
6
Controls ,
6
7
MiniMap ,
7
8
NodeProps ,
@@ -12,7 +13,7 @@ import {
12
13
useReactFlow ,
13
14
useUpdateNodeInternals
14
15
} from "@xyflow/react"
15
- import { ComponentType , useCallback , useEffect , useMemo , useRef } from "react"
16
+ import { ComponentType , useCallback , useEffect , useMemo , useRef , useState } from "react"
16
17
import "@xyflow/react/dist/style.css"
17
18
import { ResultViewWrapper } from "@/components/graph/ResultViewWrapper"
18
19
import { ResultViewProps } from "@elastic/react-search-ui-views"
@@ -23,6 +24,14 @@ import { RelationsGraphOptions } from "@/components/graph/RelationsGraphOptions"
23
24
* Renders an interactive graph for the specified results. Results will be fetched from cache via PID. Currently intended for internal use only.
24
25
*/
25
26
export function RelationsGraph ( props : { nodes : GraphNode [ ] ; options ?: RelationsGraphOptions ; resultView : ComponentType < ResultViewProps > } ) {
27
+ const [ colorMode , setColorMode ] = useState < ColorMode > ( "system" )
28
+
29
+ useEffect ( ( ) => {
30
+ const dark = document . querySelector ( "html" ) ?. classList . contains ( "dark" )
31
+ if ( dark === true ) setColorMode ( "dark" )
32
+ else setColorMode ( "light" )
33
+ } , [ ] )
34
+
26
35
const { initialEdges, initialNodes } = useMemo ( ( ) => {
27
36
return buildGraphForReferences ( props . nodes )
28
37
} , [ props . nodes ] )
@@ -77,6 +86,7 @@ export function RelationsGraph(props: { nodes: GraphNode[]; options?: RelationsG
77
86
onNodesChange = { onNodesChange }
78
87
onEdgesChange = { onEdgesChange }
79
88
proOptions = { { hideAttribution : true } }
89
+ colorMode = { colorMode }
80
90
>
81
91
< Background color = "hsl(var(--rfs-border))" variant = { BackgroundVariant . Lines } />
82
92
< Controls />
0 commit comments