Open History to see the last commit
1import { createSignal } from 'solid-js'
2import { DevtoolsStateContext } from '../contexts/DevtoolsStateContext'
3import type { ParentProps } from 'solid-js'
4import type { DevtoolsState } from '../contexts/types'
5β
6/**
7 * Provides the selected query and mutation and the panel width to its children.
8 * @param props - The `children` to render.
9 * @returns The `children`, wrapped in the context provider.
10 */
11export function DevtoolsStateProvider(props: ParentProps) {
12 const [selectedQueryHash, setSelectedQueryHash] = createSignal<string | null>(
13 null,
14 )
15 const [selectedMutationId, setSelectedMutationId] = createSignal<
16 number | null
17 >(null)
18 const [panelWidth, setPanelWidth] = createSignal(0)
19β
20 const state: DevtoolsState = {
21 selectedQueryHash,
22 setSelectedQueryHash,
23 selectedMutationId,
24 setSelectedMutationId,
25 panelWidth,
26 setPanelWidth,
27 }
28 return (
29 <DevtoolsStateContext.Provider value={state}>
30 {props.children}
31 </DevtoolsStateContext.Provider>
32 )
33}