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