Skip to content

Commit 3fa9ad5

Browse files
committed
feat: Guided Tours Framework 2
1 parent 019a78f commit 3fa9ad5

5 files changed

Lines changed: 475 additions & 11 deletions

File tree

src/components/Learn/tours/registry.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,33 @@ import type { StepType } from "@reactour/tour";
33
import { publicAsset } from "@/utils/publicAsset";
44

55
export type TourStep = StepType & {
6-
interaction?: "undock-window" | "redock-window" | "select-task";
6+
interaction?:
7+
| "undock-window"
8+
| "redock-window"
9+
| "select-task"
10+
| "add-task"
11+
| "add-input"
12+
| "add-output"
13+
| "connect-edge"
14+
| "expand-folder"
15+
| "library-search"
16+
| "set-argument";
717
targetWindowId?: string;
18+
targetFolderName?: string;
19+
targetArgumentName?: string;
20+
targetSearchTerm?: string;
21+
targetTaskName?: string;
22+
targetComponentName?: string;
23+
targetEdge?: {
24+
sourceTaskName: string;
25+
sourcePortName: string;
26+
targetTaskName?: string;
27+
targetPortName?: string;
28+
};
29+
ringSelectors?: string[];
30+
resetLibrarySearch?: boolean;
31+
ensureWindowRestored?: string;
32+
requiresTaskSelected?: string;
833
fallbackContent?: string;
934
};
1035

src/providers/TourProvider/TourPopover.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export const POPOVER_STYLES = {
4242
...base,
4343
rx: 6,
4444
}),
45+
clickArea: (base: object) => ({
46+
...base,
47+
pointerEvents: "none" as const,
48+
}),
4549
highlightedArea: (
4650
base: object,
4751
state?: { width?: number; height?: number },
@@ -86,20 +90,30 @@ export function computeDefaultPopoverPosition(
8690
props: PositionProps,
8791
): ResolvedPosition {
8892
const targetHeight = props.bottom - props.top;
93+
const isTallStrip = targetHeight > props.windowHeight * 0.5;
94+
const margin = 16;
8995

90-
const isFullHeightRightStrip =
91-
props.right >= props.windowWidth - 4 &&
92-
targetHeight > props.windowHeight * 0.5;
93-
94-
if (isFullHeightRightStrip) {
96+
// Right-anchored full-height strip (e.g. right sidebar): place popover to
97+
// its LEFT. Reactour's "left" fallback can swap to "top"/"bottom" for tall
98+
// targets, so we return explicit coords.
99+
if (isTallStrip && props.right >= props.windowWidth - 4) {
95100
const popoverWidth = props.width || 380;
96-
const margin = 16;
97101
return [
98102
Math.max(margin, props.left - popoverWidth - margin),
99103
Math.max(props.top + margin, 64),
100104
];
101105
}
102106

107+
// Left-anchored full-height strip (e.g. left dock): place popover to its
108+
// RIGHT. Same reason — reactour's "right" fallback drops to "top" for tall
109+
// targets even when there's plenty of room horizontally. We test the
110+
// target's right edge against the viewport midline rather than its left
111+
// edge against zero, so a dock that isn't flush to the window edge still
112+
// qualifies.
113+
if (isTallStrip && props.right < props.windowWidth * 0.5) {
114+
return [props.right + margin, Math.max(props.top + margin, 64)];
115+
}
116+
103117
return "bottom";
104118
}
105119

0 commit comments

Comments
 (0)