about summary refs log tree commit diff
path: root/src/state/shell/drawer-open.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/shell/drawer-open.tsx')
-rw-r--r--src/state/shell/drawer-open.tsx24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/state/shell/drawer-open.tsx b/src/state/shell/drawer-open.tsx
new file mode 100644
index 000000000..a2322f680
--- /dev/null
+++ b/src/state/shell/drawer-open.tsx
@@ -0,0 +1,24 @@
+import React from 'react'
+
+type StateContext = boolean
+type SetContext = (v: boolean) => void
+
+const stateContext = React.createContext<StateContext>(false)
+const setContext = React.createContext<SetContext>((_: boolean) => {})
+
+export function Provider({children}: React.PropsWithChildren<{}>) {
+  const [state, setState] = React.useState(false)
+  return (
+    <stateContext.Provider value={state}>
+      <setContext.Provider value={setState}>{children}</setContext.Provider>
+    </stateContext.Provider>
+  )
+}
+
+export function useIsDrawerOpen() {
+  return React.useContext(stateContext)
+}
+
+export function useSetDrawerOpen() {
+  return React.useContext(setContext)
+}