style: restore blue accents for AI dialog components and standardize gold header

This commit is contained in:
Antigravity
2026-05-09 13:23:04 +00:00
parent 60a3fe5453
commit b0c2556a12
16 changed files with 274 additions and 280 deletions

View File

@@ -24,37 +24,32 @@ function updateDocumentDirection(lang: SupportedLanguage) {
document.documentElement.dir = RTL_LANGUAGES.includes(lang) ? 'rtl' : 'ltr'
}
/**
* Resolve the actual language to use:
* 1. If localStorage has a saved preference, use that (client only)
* 2. Otherwise fall back to the server-detected initialLanguage
*/
function resolveLanguage(fallback: SupportedLanguage): SupportedLanguage {
if (typeof window !== 'undefined') {
try {
const saved = localStorage.getItem('user-language') as SupportedLanguage
if (saved && SUPPORTED_LANGS.includes(saved)) return saved
} catch {}
}
return fallback
}
export function LanguageProvider({ children, initialLanguage = 'en', initialTranslations }: {
children: ReactNode
initialLanguage?: SupportedLanguage
initialTranslations?: Translations
}) {
// Resolve language synchronously from localStorage BEFORE any effect runs.
// This prevents the flash where initialLanguage ('en') overrides RTL.
const [language, setLanguageState] = useState<SupportedLanguage>(() => resolveLanguage(initialLanguage))
// Use server-provided initialLanguage for the first render to prevent hydration mismatch.
const [language, setLanguageState] = useState<SupportedLanguage>(initialLanguage)
// Start with server-provided translations or English fallback
const [translations, setTranslations] = useState<Translations>(
(initialTranslations || enTranslations) as unknown as Translations
)
const cacheRef = useRef<Map<SupportedLanguage, Translations>>(new Map())
const isFirstRender = useRef(true)
// Load saved preference from localStorage AFTER hydration
useEffect(() => {
const saved = localStorage.getItem('user-language') as SupportedLanguage
if (saved && SUPPORTED_LANGS.includes(saved) && saved !== initialLanguage) {
setLanguageState(saved)
}
}, [initialLanguage])
// Load translations when language changes (with caching)
// On first render, skip updateDocumentDirection since the inline script already set it.
useEffect(() => {