mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
[web] Remove explicit dark mode component opt-in GitOrigin-RevId: b28603a9989bd046039c247ee2cf9f740c9feac0
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { createRoot } from 'react-dom/client'
|
|
import PdfPreview from './pdf-preview'
|
|
import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
|
|
import { ReactContextRoot } from '@/features/ide-react/context/react-context-root'
|
|
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
|
|
import { useEffect } from 'react'
|
|
|
|
function PdfPreviewDetachedRoot() {
|
|
const { isReady } = useWaitForI18n()
|
|
|
|
if (!isReady) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<ReactContextRoot>
|
|
<PdfPreviewDetachedRootContent />
|
|
</ReactContextRoot>
|
|
)
|
|
}
|
|
|
|
function PdfPreviewDetachedRootContent() {
|
|
const { activeOverallTheme } = useCompileContext()
|
|
useEffect(() => {
|
|
// NOTE: We cannot use useThemedPage here because we need to read the
|
|
// activeOverallTheme value from the compile context
|
|
document.body.dataset.theme =
|
|
activeOverallTheme === 'dark' ? 'default' : 'light'
|
|
}, [activeOverallTheme])
|
|
|
|
return <PdfPreview />
|
|
}
|
|
|
|
export default PdfPreviewDetachedRoot // for testing
|
|
|
|
const element = document.getElementById('pdf-preview-detached-root')
|
|
if (element) {
|
|
const root = createRoot(element)
|
|
root.render(<PdfPreviewDetachedRoot />)
|
|
}
|