Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

742 B
Raw Blame
import { createContext, useContext } from 'react'
import { create } from 'zustand'

export const OverlayDismissContext = createContext<{
    set: (key: string, close: (() => void) | null) => void
    close: (() => void) | null
} | null>(null)

export function useOverlayDismiss(): (() => void) | null {
    return useContext(OverlayDismissContext)?.close ?? null
}

export const useNavigationOverlayStore = create<{
    keys: string[]
    set: (key: string, visible: boolean) => void
}>()((set) => ({
    keys: [],
    set: (key, visible) =>
        set((state) => ({
            keys: visible
                ? [...state.keys.filter((item) => item !== key), key]
                : state.keys.filter((item) => item !== key),
        })),
}))