Some checks failed
ci / go (push) Has been cancelled
ci / admin-ui (push) Has been cancelled
ci / runtime-sdk (push) Has been cancelled
ci / helm (push) Has been cancelled
ci / openapi (push) Has been cancelled
ci / container (push) Has been cancelled
ci / release-config (push) Has been cancelled
ci / shared styling (push) Has been cancelled
ci / security (push) Has been cancelled
ci / all green (push) Has been cancelled
19 lines
646 B
TypeScript
19 lines
646 B
TypeScript
import { useContext } from 'react'
|
|
|
|
import { AdminThemeContextInstance, type AdminThemeValue } from './admin-theme-context'
|
|
|
|
/**
|
|
* Reads the admin theme context.
|
|
*
|
|
* Throws when used outside a provider rather than returning a default. A silent
|
|
* default would let a component render with the wrong theme and never report the
|
|
* mistake, which is exactly the class of bug this codebase's tooling exists to
|
|
* surface.
|
|
*/
|
|
export function useAdminTheme(): AdminThemeValue {
|
|
const value = useContext(AdminThemeContextInstance)
|
|
if (!value) {
|
|
throw new Error('useAdminTheme must be used inside an AdminThemeProvider')
|
|
}
|
|
return value
|
|
}
|