Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
All services: admin-v2, studio-v2, website, ai-compliance-sdk, consent-service, klausur-service, voice-service, and infrastructure. Large PDFs and compiled binaries excluded via .gitignore.
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import { createContext, useContext, useState, useEffect, ReactNode } from 'react'
|
|
|
|
type Theme = 'dark' | 'light'
|
|
|
|
interface ThemeContextType {
|
|
theme: Theme
|
|
toggleTheme: () => void
|
|
isDark: boolean
|
|
}
|
|
|
|
const ThemeContext = createContext<ThemeContextType | null>(null)
|
|
|
|
const STORAGE_KEY = 'bp_theme'
|
|
|
|
export function ThemeProvider({ children }: { children: ReactNode }) {
|
|
const [theme, setTheme] = useState<Theme>('dark')
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
// Nach dem ersten Render: Theme aus localStorage laden
|
|
useEffect(() => {
|
|
const stored = localStorage.getItem(STORAGE_KEY) as Theme | null
|
|
if (stored && (stored === 'dark' || stored === 'light')) {
|
|
setTheme(stored)
|
|
}
|
|
setMounted(true)
|
|
}, [])
|
|
|
|
// Theme wechseln und speichern
|
|
const toggleTheme = () => {
|
|
const newTheme = theme === 'dark' ? 'light' : 'dark'
|
|
setTheme(newTheme)
|
|
localStorage.setItem(STORAGE_KEY, newTheme)
|
|
}
|
|
|
|
// Waehrend SSR: Default anzeigen
|
|
if (!mounted) {
|
|
return (
|
|
<ThemeContext.Provider
|
|
value={{
|
|
theme: 'dark',
|
|
toggleTheme: () => {},
|
|
isDark: true,
|
|
}}
|
|
>
|
|
{children}
|
|
</ThemeContext.Provider>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<ThemeContext.Provider
|
|
value={{
|
|
theme,
|
|
toggleTheme,
|
|
isDark: theme === 'dark',
|
|
}}
|
|
>
|
|
{children}
|
|
</ThemeContext.Provider>
|
|
)
|
|
}
|
|
|
|
export function useTheme() {
|
|
const context = useContext(ThemeContext)
|
|
if (!context) {
|
|
throw new Error('useTheme must be used within a ThemeProvider')
|
|
}
|
|
return context
|
|
}
|