11import React from "react" ;
22import { createPortal } from "react-dom" ;
3- import { Classes as BlueprintClasses } from "@blueprintjs/core" ;
4- import { createPopper } from "@popperjs/core" ;
53
64import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
75import {
@@ -14,6 +12,7 @@ import {
1412 CardHeader ,
1513 CardOptions ,
1614 CardTitle ,
15+ DecoupledOverlay ,
1716 IconButton ,
1817 Markdown ,
1918 ModalSize ,
@@ -292,25 +291,6 @@ interface StepPopoverProps {
292291
293292/** Popover that is displayed and points at the highlighted element. */
294293const StepPopover = ( { highlightedElement, step, titleOption, actionButtons } : StepPopoverProps ) => {
295- const tooltipRef = React . useCallback (
296- ( tooltip : HTMLDivElement | null ) => {
297- if ( tooltip ) {
298- createPopper ( highlightedElement , tooltip , {
299- placement : "auto" ,
300- modifiers : [
301- {
302- name : "offset" ,
303- options : {
304- offset : [ 0 , 15 ] ,
305- } ,
306- } ,
307- ] ,
308- } ) ;
309- }
310- } ,
311- [ highlightedElement ]
312- ) ;
313-
314294 const backdropRef = React . useCallback (
315295 ( backdrop : HTMLDivElement | null ) => {
316296 const highlightStencil = ( ) => {
@@ -340,39 +320,39 @@ const StepPopover = ({ highlightedElement, step, titleOption, actionButtons }: S
340320 [ highlightedElement ]
341321 ) ;
342322
323+ // map to only tooltip size because the `DecoupledOverlay` only supports them
324+ let overlaySize : TooltipSize = "large" ;
325+ switch ( step . size ) {
326+ case "tiny" :
327+ overlaySize = "small" ;
328+ break ;
329+ case "regular" :
330+ overlaySize = "medium" ;
331+ break ;
332+ case "xlarge" :
333+ case "fullscreen" :
334+ overlaySize = "large" ;
335+ break ;
336+ }
337+
343338 return createPortal (
344339 < div className = { `${ eccgui } -visual-tour` } >
345340 < div className = { `${ eccgui } -visual-tour__focushelper` } ref = { backdropRef } />
346341 < div >
347342 < div className = { `${ eccgui } -visual-tour__backdrop` } />
348343 </ div >
349- < div
350- className = {
351- `${ eccgui } -visual-tour__overlay` +
352- ` ${ eccgui } -visual-tour__overlay--${ step . size ?? "large" } ` +
353- ` ${ BlueprintClasses . POPOVER } `
354- }
355- role = "tooltip"
356- ref = { tooltipRef }
357- >
358- < div
359- className = { `${ eccgui } -visual-tour__arrow ${ BlueprintClasses . POPOVER_ARROW } ` }
360- data-popper-arrow
361- aria-hidden
362- />
363- < div className = { `${ BlueprintClasses . POPOVER_CONTENT } ${ eccgui } -visual-tour__overlay__content` } >
364- < Card isOnlyLayout elevation = { - 1 } whitespaceAmount = "small" >
365- < CardHeader >
366- < CardTitle > { step . title } </ CardTitle >
367- < CardOptions > { titleOption } </ CardOptions >
368- </ CardHeader >
369- < CardContent >
370- < StepContent step = { step } />
371- </ CardContent >
372- < CardActions inverseDirection > { actionButtons } </ CardActions >
373- </ Card >
374- </ div >
375- </ div >
344+ < DecoupledOverlay targetSelectorOrElement = { highlightedElement } size = { overlaySize } usePortal = { false } >
345+ < Card isOnlyLayout elevation = { - 1 } whitespaceAmount = "small" >
346+ < CardHeader >
347+ < CardTitle > { step . title } </ CardTitle >
348+ < CardOptions > { titleOption } </ CardOptions >
349+ </ CardHeader >
350+ < CardContent >
351+ < StepContent step = { step } />
352+ </ CardContent >
353+ < CardActions inverseDirection > { actionButtons } </ CardActions >
354+ </ Card >
355+ </ DecoupledOverlay >
376356 </ div > ,
377357 document . body
378358 ) ;
0 commit comments