import * as React from 'react'; import { Popover } from '@patternfly/react-core'; import { POSITION_MAP } from '../consts'; import { useTargetElement } from '../hooks/useTargetElement'; import { PopoverPosition } from '../types'; import './HighlightStep.scss'; import { StepNavigation } from './StepNavigation'; interface HighlightStepProps { title: string; content: string; target: string; position?: PopoverPosition; currentStep: number; totalSteps: number; isFirstStep: boolean; isLastStep: boolean; onNext: () => void; onPrev: () => void; onSkip: () => void; onDone: () => void; } const HIGHLIGHT_CLASS = 'guided-tours__highlight-ring'; export const HighlightStep: React.FC = ({ title, content, target, position = 'auto', currentStep, totalSteps, isFirstStep, isLastStep, onNext, onPrev, onSkip, onDone, }) => { const { targetEl, triggerRef } = useTargetElement(target); // Add/remove highlight ring class React.useLayoutEffect(() => { if (!targetEl) return undefined; targetEl.classList.add(HIGHLIGHT_CLASS); return () => { targetEl.classList.remove(HIGHLIGHT_CLASS); }; }, [targetEl]); if (!targetEl) { return null; } return ( } shouldClose={onSkip} position={POSITION_MAP[position]} triggerRef={triggerRef} headerContent={title} bodyContent={content} appendTo={() => document.querySelector('#hacDev-modal-container') ?? document.body} data-test="tour-highlight-step" /> ); };