* initial implementation of search modal * added hit and search suggestions * added support for multiple indices * updated sample env * added close when click outside dropdown * test for mobile * added mobile design * added shortcut * dark mode fixes * added search to docs * added plugins filter * added React import * moved filters to configurations * handled error on page load * change suggestion text * removed hits limit * handle select all * open link in current tab * change highlight colors * added support for shortcuts + auto focus * change header and footer * redesigned search ui
42 lines
887 B
TypeScript
42 lines
887 B
TypeScript
"use client"
|
|
|
|
import { createContext, useContext, useState } from "react"
|
|
|
|
type PageLoadingContextType = {
|
|
isLoading: boolean
|
|
setIsLoading: (value: boolean) => void
|
|
}
|
|
|
|
const PageLoadingContext = createContext<PageLoadingContextType | null>(null)
|
|
|
|
type PageLoadingProviderProps = {
|
|
children?: React.ReactNode
|
|
}
|
|
|
|
const PageLoadingProvider = ({ children }: PageLoadingProviderProps) => {
|
|
const [isLoading, setIsLoading] = useState(true)
|
|
|
|
return (
|
|
<PageLoadingContext.Provider
|
|
value={{
|
|
isLoading,
|
|
setIsLoading,
|
|
}}
|
|
>
|
|
{children}
|
|
</PageLoadingContext.Provider>
|
|
)
|
|
}
|
|
|
|
export default PageLoadingProvider
|
|
|
|
export const usePageLoading = (): PageLoadingContextType => {
|
|
const context = useContext(PageLoadingContext)
|
|
|
|
if (!context) {
|
|
throw new Error("usePageLoading must be used inside a PageLoadingProvider")
|
|
}
|
|
|
|
return context
|
|
}
|