go-bananas/web/src/components/use-admin-theme.ts
Daniel Noulet 951dd8d26b
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
initial commit
2026-10-07 15:11:35 +02:00

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
}