fix: add missing GameThemeContext file for themed navigation
The GameThemeContext.tsx file was referenced in layout.tsx but wasn't properly committed. This context enables games to declare their theming that flows through the navigation chrome. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
33
apps/web/src/contexts/GameThemeContext.tsx
Normal file
33
apps/web/src/contexts/GameThemeContext.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
'use client'
|
||||
|
||||
import { createContext, useContext, useState, ReactNode } from 'react'
|
||||
|
||||
export interface GameTheme {
|
||||
gameName: string
|
||||
backgroundColor: string
|
||||
}
|
||||
|
||||
interface GameThemeContextType {
|
||||
theme: GameTheme | null
|
||||
setTheme: (theme: GameTheme | null) => void
|
||||
}
|
||||
|
||||
const GameThemeContext = createContext<GameThemeContextType | undefined>(undefined)
|
||||
|
||||
export function GameThemeProvider({ children }: { children: ReactNode }) {
|
||||
const [theme, setTheme] = useState<GameTheme | null>(null)
|
||||
|
||||
return (
|
||||
<GameThemeContext.Provider value={{ theme, setTheme }}>
|
||||
{children}
|
||||
</GameThemeContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useGameTheme() {
|
||||
const context = useContext(GameThemeContext)
|
||||
if (context === undefined) {
|
||||
throw new Error('useGameTheme must be used within a GameThemeProvider')
|
||||
}
|
||||
return context
|
||||
}
|
||||
Reference in New Issue
Block a user