mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
e61eb1b220
Improve calculations of empty state, mini state and sizes variables in review panel GitOrigin-RevId: 41bcb3b67c9f0019c11b4de0e4590b0407e04e66
33 lines
1 KiB
TypeScript
33 lines
1 KiB
TypeScript
import ReactDOM from 'react-dom'
|
|
import { useCodeMirrorViewContext } from '../../source-editor/components/codemirror-editor'
|
|
import { memo } from 'react'
|
|
import ReviewPanel from './review-panel'
|
|
import { useLayoutContext } from '@/shared/context/layout-context'
|
|
import { useRangesContext } from '../context/ranges-context'
|
|
import { useThreadsContext } from '@/features/review-panel-new/context/threads-context'
|
|
import { hasActiveRange } from '@/features/review-panel-new/utils/has-active-range'
|
|
|
|
function ReviewPanelContainer() {
|
|
const view = useCodeMirrorViewContext()
|
|
const ranges = useRangesContext()
|
|
const threads = useThreadsContext()
|
|
const { reviewPanelOpen } = useLayoutContext()
|
|
|
|
if (!view) {
|
|
return null
|
|
}
|
|
|
|
// the full-width review panel
|
|
if (reviewPanelOpen) {
|
|
return ReactDOM.createPortal(<ReviewPanel />, view.scrollDOM)
|
|
}
|
|
|
|
// the mini review panel
|
|
if (hasActiveRange(ranges, threads)) {
|
|
return ReactDOM.createPortal(<ReviewPanel mini />, view.scrollDOM)
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
export default memo(ReviewPanelContainer)
|