From cfdf3e820a075acc39b38aa9eb3c270899d040ee Mon Sep 17 00:00:00 2001 From: galangel Date: Thu, 26 Nov 2026 10:33:37 +0200 Subject: [PATCH 01/42] feat(tour): render the tour panel in React, with a ReactNode body The tour panel was assembled as an HTML string and injected, so a step could not carry React content. TourPanel now renders it as a React element that the tour passes to the tooltip as its content, keeping every class name and data attribute the delegated click handling, autoFocus and stylesheet rely on. - TourStepContent gains `body: ReactNode | (step) => ReactNode`. `text` is rendered as text by React; `content` stays HTML, injected only into the message element. - TooltipShowOptions.content accepts any React node; `html` applies to strings. - Fixes `text` being escaped twice on a step with no panel features, and navigation labels being inserted as unescaped markup. --- CLAUDE.md | 27 +- src/components/Tooltip/Tooltip.tsx | 2 +- .../Tooltip/__tests__/Tooltip.test.tsx | 17 + src/context/TipMagicContext.tsx | 4 +- src/hooks/useTooltipAPI.ts | 8 +- src/hooks/useTour/TourPanel.tsx | 221 +++++++ .../useTour/__tests__/TourPanel.test.tsx | 355 +++++++++++ .../__tests__/buildTourContent.test.ts | 567 ------------------ .../useTour/__tests__/progressRing.test.ts | 23 + src/hooks/useTour/__tests__/tourSteps.test.ts | 58 ++ .../__tests__/useTour.integration.test.tsx | 142 +++++ src/hooks/useTour/useTour.ts | 41 +- src/hooks/useTour/utils/buildTourContent.ts | 259 -------- src/hooks/useTour/utils/index.ts | 16 +- src/hooks/useTour/utils/progressRing.ts | 45 ++ src/hooks/useTour/utils/tourSteps.ts | 39 +- src/types/index.ts | 13 +- src/types/tour.ts | 57 +- 18 files changed, 997 insertions(+), 897 deletions(-) create mode 100644 src/hooks/useTour/TourPanel.tsx create mode 100644 src/hooks/useTour/__tests__/TourPanel.test.tsx delete mode 100644 src/hooks/useTour/__tests__/buildTourContent.test.ts create mode 100644 src/hooks/useTour/__tests__/progressRing.test.ts delete mode 100644 src/hooks/useTour/utils/buildTourContent.ts create mode 100644 src/hooks/useTour/utils/progressRing.ts diff --git a/CLAUDE.md b/CLAUDE.md index 9ec947b..861e371 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,6 +19,7 @@ npm run build # library (dist/index.mjs, .cjs, styles.css) | -------------------------- | ------------------------------------------------------------------------------------------------------------- | | `src/components/` | React components. `Tooltip` renders the single tooltip; the rest are internals mounted by `TipMagicProvider`. | | `src/hooks/` | Public hooks and the API objects behind `useTipMagic()`. | +| `src/hooks/useTour/` | `useTour`, and `TourPanel`, the React component it passes to the tooltip as content. | | `src/hooks/useTour/utils/` | Tour helpers: DOM managers (classes) and pure functions. | | `src/utils/` | Pure helpers shared across components. Tests in `__tests__/` beside them. | | `src/types/` | All public types. `tour.ts` re-exports through `index.ts`. | @@ -49,9 +50,10 @@ on the next push rather than stranding the bump. **`dangerouslySetInnerHTML` is re-applied on every render.** React rewrites the subtree even when the html string is byte-identical. Anything focused inside it is dropped to -``, an `` or autoplaying `