@hub-kit/core 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,6 +6,7 @@ import { TourCard } from "./tour-card.js";
|
|
|
6
6
|
import { useTour } from "./use-tour.js";
|
|
7
7
|
const SPOTLIGHT_PADDING = 6;
|
|
8
8
|
const MOVE_DURATION = "220ms";
|
|
9
|
+
const CARD_LAYER = "60";
|
|
9
10
|
const TALL_TARGET_GAP = 0.45;
|
|
10
11
|
const MAX_CARD_WIDTH = 352;
|
|
11
12
|
const SCREEN_MARGIN = 32;
|
|
@@ -23,7 +24,6 @@ export function TourOverlay() {
|
|
|
23
24
|
window.addEventListener("resize", readViewport);
|
|
24
25
|
return () => window.removeEventListener("resize", readViewport);
|
|
25
26
|
}, []);
|
|
26
|
-
const cardRef = useRef(null);
|
|
27
27
|
const skipMissingStep = useRef(() => { });
|
|
28
28
|
skipMissingStep.current = tour ? tour.next : () => { };
|
|
29
29
|
useEffect(() => {
|
|
@@ -74,12 +74,6 @@ export function TourOverlay() {
|
|
|
74
74
|
stopMeasuring?.();
|
|
75
75
|
};
|
|
76
76
|
}, [target]);
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
const wrapper = cardRef.current?.closest("[data-radix-popper-content-wrapper]");
|
|
79
|
-
if (wrapper) {
|
|
80
|
-
wrapper.style.transition = `transform ${MOVE_DURATION} ease`;
|
|
81
|
-
}
|
|
82
|
-
}, [target]);
|
|
83
77
|
useEffect(() => {
|
|
84
78
|
if (!tour?.isOpen) {
|
|
85
79
|
return;
|
|
@@ -129,7 +123,7 @@ export function TourOverlay() {
|
|
|
129
123
|
"0 0 0 3px var(--tour-ring-gap, var(--background))",
|
|
130
124
|
"0 0 0 5px var(--tour-accent, var(--primary))",
|
|
131
125
|
].join(", "),
|
|
132
|
-
} }), _jsxs(Popover, { open: true, children: [_jsx(PopoverAnchor, { asChild: true, children: _jsx("div", { className: "absolute", style: { top: rect.top, left: rect.left, width: rect.width, height: rect.height } }) }), _jsxs(PopoverContent, { ref:
|
|
126
|
+
} }), _jsxs(Popover, { open: true, children: [_jsx(PopoverAnchor, { asChild: true, children: _jsx("div", { className: "absolute", style: { top: rect.top, left: rect.left, width: rect.width, height: rect.height } }) }), _jsxs(PopoverContent, { ref: liftCardAboveBackdrop, side: sideForScreen(step.placement, rect, viewport), align: "center", sideOffset: 12, arrowPadding: 16, collisionPadding: 16, className: "w-[min(var(--tour-card-width,22rem),calc(100vw-2rem))] rounded-2xl border-0 px-4 pt-4 pb-2.5 shadow-xl sm:px-5 sm:pt-5 sm:pb-3.5", onOpenAutoFocus: (event) => event.preventDefault(), onEscapeKeyDown: (event) => event.preventDefault(), onPointerDownOutside: (event) => event.preventDefault(), onInteractOutside: (event) => event.preventDefault(), "aria-label": tour.labels.cardTitle, children: [_jsx(TourCard, { step: step, stepIndex: tour.stepIndex, stepCount: tour.stepCount, labels: tour.labels, onNext: tour.next, onSkip: tour.skip }), _jsx(PopoverArrow, { width: 18, height: 9, style: { fill: "var(--popover)" } })] })] })] }));
|
|
133
127
|
}
|
|
134
128
|
function sideForScreen(placement, rect, viewport) {
|
|
135
129
|
if (viewport.width === 0) {
|
|
@@ -180,3 +174,11 @@ function revealTallTarget(element) {
|
|
|
180
174
|
const delta = element.getBoundingClientRect().top - containerTop - gapAbove;
|
|
181
175
|
container.scrollBy({ top: delta, behavior: "smooth" });
|
|
182
176
|
}
|
|
177
|
+
function liftCardAboveBackdrop(node) {
|
|
178
|
+
const wrapper = node?.closest("[data-radix-popper-content-wrapper]");
|
|
179
|
+
if (!wrapper) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
wrapper.style.zIndex = CARD_LAYER;
|
|
183
|
+
wrapper.style.transition = `transform ${MOVE_DURATION} ease`;
|
|
184
|
+
}
|