mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 06:39:02 +02:00
b7f5344859
* moving files from ide-redesign/components/editor-tour to features/editor-tour moving files from ide-redesign/components/integrations-panel to features/integrations-panel fixing imports Revert "moving files from ide-redesign/components/editor-tour to features/editor-tour" This reverts commit 9e4dcd4e001ffa4bfdb1053fb8824c1e8521ab10. * moving files from ide-redesign/components/help -> ide-react/components/rail * ide-redesign/components/breadcrumbs → features/source-editor/extensions * ide-redesign/components/editor.tsx → ide-react/components/layout * ide-redesign/components/full-project-search-panel.tsx → ide-react/components/rail/full-project-search-panel.tsx * removing old-editor-warning-tooltip * ide-redesign/components/tooltip-promo.tsx → shared/components/tooltip-promo.tsx make cleanup_unused_locales * extract-translations GitOrigin-RevId: b9f44c4820bb4e0a7eef4f6f9a58ff96fd007bf9
82 lines
1.9 KiB
TypeScript
82 lines
1.9 KiB
TypeScript
import Close from '@/shared/components/close'
|
|
import useTutorial from '@/shared/hooks/promotions/use-tutorial'
|
|
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
|
|
import classNames from 'classnames'
|
|
import { useCallback, useEffect } from 'react'
|
|
import { Overlay, OverlayProps, Popover } from 'react-bootstrap'
|
|
|
|
/** @knipignore keep this file around even when there is no current promo using it */
|
|
export default function TooltipPromotion({
|
|
target,
|
|
tutorialKey,
|
|
eventData,
|
|
className,
|
|
content,
|
|
header,
|
|
placement = 'bottom',
|
|
splitTestName,
|
|
}: {
|
|
target: HTMLElement | null
|
|
tutorialKey: string
|
|
eventData: Record<string, any>
|
|
className?: string
|
|
content: string
|
|
header?: string
|
|
placement?: OverlayProps['placement']
|
|
splitTestName?: string
|
|
}) {
|
|
const {
|
|
showPopup,
|
|
tryShowingPopup,
|
|
hideUntilReload,
|
|
dismissTutorial,
|
|
checkCompletion,
|
|
} = useTutorial(tutorialKey, eventData)
|
|
|
|
useEffect(() => {
|
|
if (!checkCompletion()) {
|
|
tryShowingPopup()
|
|
}
|
|
}, [tryShowingPopup, checkCompletion, tutorialKey])
|
|
|
|
const isInSplitTestIfNeeded = splitTestName
|
|
? isSplitTestEnabled(splitTestName)
|
|
: true
|
|
|
|
const onHide = useCallback(() => {
|
|
hideUntilReload()
|
|
}, [hideUntilReload])
|
|
|
|
const onDismiss = useCallback(() => {
|
|
dismissTutorial()
|
|
}, [dismissTutorial])
|
|
|
|
if (!target || !isInSplitTestIfNeeded) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<Overlay
|
|
placement={placement}
|
|
show={showPopup}
|
|
target={target}
|
|
rootClose
|
|
onHide={onHide}
|
|
>
|
|
<Popover>
|
|
{header && (
|
|
<Popover.Header>
|
|
{header}
|
|
<Close variant="dark" onDismiss={onDismiss} />
|
|
</Popover.Header>
|
|
)}
|
|
|
|
<Popover.Body className={classNames(className)}>
|
|
{content}
|
|
{!header && <Close variant="dark" onDismiss={onDismiss} />}
|
|
</Popover.Body>
|
|
</Popover>
|
|
</Overlay>
|
|
)
|
|
}
|