blob: 3b0b18384cc908075b4957f0cf9e38b7338cbb01 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
"use client"
import { createContext, type ReactNode, useContext, useState } from "react"
type ActivePanel = "menu" | "chat" | null
interface MobilePanelContextType {
activePanel: ActivePanel
setActivePanel: (panel: ActivePanel) => void
}
const MobilePanelContext = createContext<MobilePanelContextType | undefined>(
undefined,
)
export function MobilePanelProvider({ children }: { children: ReactNode }) {
const [activePanel, setActivePanel] = useState<ActivePanel>(null)
return (
<MobilePanelContext.Provider value={{ activePanel, setActivePanel }}>
{children}
</MobilePanelContext.Provider>
)
}
export function useMobilePanel() {
const context = useContext(MobilePanelContext)
if (!context) {
throw new Error("useMobilePanel must be used within a MobilePanelProvider")
}
return context
}
|