Skip to content

Commit ab3618a

Browse files
committed
Fix Tour title classname and update TooltipContent
1 parent db2df99 commit ab3618a

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

src/packages/hint/components/HintTooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const HintTooltip = ({
5454
TooltipContent({
5555
text: text || "",
5656
tooltipRenderAsHtml: renderAsHtml,
57-
className: tooltipTextClassName,
57+
container: div({ className: tooltipTextClassName }),
5858
}),
5959
closeButtonEnabled
6060
? a(

src/packages/tooltip/tooltipContent.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import dom from "../dom";
12
import { TooltipContent } from "./tooltipContent";
23

4+
const { div } = dom.tags;
5+
36
describe("TooltipContent", () => {
47
it("renders plain text when tooltipRenderAsHtml is false", () => {
58
const el = TooltipContent({
69
text: "<strong>Bold Text</strong>",
710
tooltipRenderAsHtml: false,
8-
className: "tooltip-text",
11+
container: div(),
912
});
1013

1114
expect(el.innerHTML).toBe("&lt;strong&gt;Bold Text&lt;/strong&gt;");
@@ -16,7 +19,7 @@ describe("TooltipContent", () => {
1619
const el = TooltipContent({
1720
text: "<strong>Bold Text</strong>",
1821
tooltipRenderAsHtml: true,
19-
className: "tooltip-text",
22+
container: div(),
2023
});
2124

2225
expect(el.innerHTML).toBe("<strong>Bold Text</strong>");
@@ -26,7 +29,7 @@ describe("TooltipContent", () => {
2629
it("applies a custom class when provided", () => {
2730
const el = TooltipContent({
2831
text: "Custom class test",
29-
className: "my-custom-tooltip",
32+
container: div({ className: "my-custom-tooltip" }),
3033
});
3134

3235
expect(el.className).toBe("my-custom-tooltip");

src/packages/tooltip/tooltipContent.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import dom from "../dom";
22

3-
const { div } = dom.tags;
4-
5-
export type tooltipContentProps = {
3+
export type TooltipContentProps = {
4+
/**
5+
* The text content to be displayed in the tooltip.
6+
*/
67
text: string;
7-
className: string;
8+
/**
9+
* The container element where the tooltip content will be rendered.
10+
*/
11+
container: HTMLElement;
12+
/**
13+
* If true, the text will be rendered as HTML.
14+
*/
815
tooltipRenderAsHtml?: boolean;
916
};
1017

18+
/**
19+
* TooltipContent component renders the content of a tooltip.
20+
* It can render plain text or HTML based on the `tooltipRenderAsHtml` flag.
21+
*/
1122
export const TooltipContent = ({
1223
text,
24+
container,
1325
tooltipRenderAsHtml,
14-
className,
15-
}: tooltipContentProps) => {
16-
const container = div({
17-
className,
18-
});
19-
26+
}: TooltipContentProps) => {
2027
dom.derive(() => {
2128
const el = container as HTMLElement;
2229
if (!el) return;

src/packages/tour/components/TourTooltip.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ describe("Header", () => {
1111

1212
const h1 = el.querySelector("h1")!;
1313

14-
expect(h1.innerHTML).toBe(
15-
'<div class="introjs-tooltiptext">&lt;strong&gt;Bold Text&lt;/strong&gt;'
16-
);
14+
expect(h1.innerHTML).toBe("&lt;strong&gt;Bold Text&lt;/strong&gt;");
1715
expect(h1.querySelector("strong")).toBeNull();
1816
});
1917

@@ -27,9 +25,7 @@ describe("Header", () => {
2725

2826
const h1 = el.querySelector("h1")!;
2927

30-
expect(h1.innerHTML).toBe(
31-
'<div class="introjs-tooltiptext"><strong>Bold Text</strong>'
32-
);
28+
expect(h1.innerHTML).toBe("<strong>Bold Text</strong>");
3329
expect(h1.querySelector("strong")?.textContent).toBe("Bold Text");
3430
});
3531
});

src/packages/tour/components/TourTooltip.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ export const Header = ({
340340
const titleEl = TooltipContent({
341341
text: title,
342342
tooltipRenderAsHtml: renderAsHtml,
343-
className: tooltipTextClassName,
343+
container: h1({ className: tooltipTitleClassName }),
344344
});
345345
return div({ className: tooltipHeaderClassName }, [
346-
h1({ className: tooltipTitleClassName }, titleEl),
346+
titleEl,
347347
Button({
348348
className: skipButtonClassName,
349349
label: skipLabel,
@@ -463,7 +463,7 @@ export const TourTooltip = ({
463463
TooltipContent({
464464
text,
465465
tooltipRenderAsHtml: renderAsHtml,
466-
className: tooltipTextClassName,
466+
container: div({ className: tooltipTextClassName }),
467467
})
468468
);
469469

0 commit comments

Comments
 (0)