Skip to content

Commit 7e57c3d

Browse files
Use arrows as pointer for the tour tooltip
1 parent 396e01b commit 7e57c3d

5 files changed

Lines changed: 43 additions & 18 deletions

File tree

src/components/VisualTour/VisualTour.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface VisualTourStep {
2828
/** The texts used in the step, e.g. when custom layouts are rendered, these will be used for the text strings. */
2929
texts?: Record<string, string>;
3030
/** An image URL. This will be displayed in the step description. */
31-
image?: string
31+
image?: string;
3232
}
3333

3434
/** This should be used for defining steps in a separate object/file. Use with 'satisfies' after the object definition. */
@@ -120,12 +120,14 @@ interface StepModalProps {
120120
}
121121

122122
// Main content of a step
123-
const StepContent = ({step}: {step: VisualTourStep}) => {
124-
return <div>
125-
{step.image ? <img src={step.image} width={600} /> : null}
126-
{typeof step.content === "string" ? step.content : step.content()}
127-
</div>
128-
}
123+
const StepContent = ({ step }: { step: VisualTourStep }) => {
124+
return (
125+
<div>
126+
{step.image ? <img src={step.image} width={600} /> : null}
127+
{typeof step.content === "string" ? step.content : step.content()}
128+
</div>
129+
);
130+
};
129131

130132
/** Modal that is displayed for a step. */
131133
const StepModal = ({ step, titleSuffix, onClose, actionButtons }: StepModalProps) => {
@@ -181,7 +183,9 @@ const StepPopover = ({ highlightedElement, step, titleSuffix, actionButtons }: S
181183
role="tooltip"
182184
ref={tooltipRef}
183185
>
184-
<div id="arrow" data-popper-arrow></div>
186+
<div id="arrow" data-popper-arrow>
187+
<span className={`${eccgui}-visual-tour__tooltip__arrow-shape`} />
188+
</div>
185189
<Card>
186190
<CardHeader>
187191
<CardTitle>{`${step.title} ${titleSuffix}`}</CardTitle>

src/components/VisualTour/stories/VisualTour.stories.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const Template: StoryFn<typeof VisualTour> = (args: VisualTourProps) => {
2929
return (
3030
<div style={{ minHeight: "600px", minWidth: "800px" }}>
3131
<Toolbar id={"tourContainer"}>
32-
<ToolbarSection id={"textSection"} canGrow={true}>
33-
Some text
32+
<ToolbarSection canGrow={true}>
33+
<span id={"textSection"}>Some text</span>
3434
</ToolbarSection>
3535
<ToolbarSection id={"buttonSection"}>
3636
<Button id={"actionA"}>Action A</Button>
@@ -86,6 +86,10 @@ const defaultArgs: VisualTourProps = {
8686
...stepDefinitions.highlightElementB,
8787
highlightElementQuery: "#actionB",
8888
},
89+
{
90+
...stepDefinitions.highlightElementLeft,
91+
highlightElementQuery: "#textSection",
92+
},
8993
{
9094
...stepDefinitions.highlightElementC,
9195
highlightElementQuery: "#actionC",

src/components/VisualTour/stories/defaultTour.de.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const definition = {
2121
title: "Element B hervorheben",
2222
content: "Kontextoverlay für ein anderes hervorgehobenes Element.",
2323
},
24+
highlightElementLeft: {
25+
title: "Element auf der linken Seite hervorheben",
26+
content: "Der Tooltip wird dort plaziert, wo er am besten für den Benutzer zu sehen ist.",
27+
},
2428
highlightElementC: {
2529
title: "Element C hervorheben",
2630
content: "Element ist außerhalb des Tourcontainers.",

src/components/VisualTour/stories/defaultTour.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const definition = {
2121
title: "Highlight element B",
2222
content: "Context overlay for another highlighted element.",
2323
},
24+
highlightElementLeft: {
25+
title: "Highlight element on the left",
26+
content: "The tooltip is placed where it is best seen by the user.",
27+
},
2428
highlightElementC: {
2529
title: "Highlight element C",
2630
content: "Element outside tour container.",

src/components/VisualTour/visualTour.scss

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,44 @@
55
// TODO: From https://popper.js.org/docs/v2/tutorial/ until we fine-tune this part
66

77
#arrow,
8-
#arrow::before {
8+
#arrow .#{$eccgui}-visual-tour__tooltip__arrow-shape,
9+
#arrow .#{$eccgui}-visual-tour__tooltip__arrow-shape::before {
910
position: absolute;
10-
width: 8px;
11-
height: 8px;
12-
background: dimgrey;
13-
border-radius: 50%;
11+
border-right: 8px solid transparent;
12+
border-bottom: 8px solid dimgrey;
13+
border-left: 8px solid transparent;
1414
}
1515

1616
#arrow {
1717
visibility: hidden;
1818
}
1919

20-
#arrow::before {
20+
#arrow .#{$eccgui}-visual-tour__tooltip__arrow-shape::before {
2121
visibility: visible;
2222
content: "";
2323
}
2424

2525
.#{$eccgui}-visual-tour__tooltip[data-popper-placement^="top"] > #arrow {
2626
bottom: -8px;
27+
.#{$eccgui}-visual-tour__tooltip__arrow-shape::before {
28+
transform: rotate(180deg);
29+
}
2730
}
2831

2932
.#{$eccgui}-visual-tour__tooltip[data-popper-placement^="bottom"] > #arrow {
3033
top: -8px;
3134
}
3235

3336
.#{$eccgui}-visual-tour__tooltip[data-popper-placement^="left"] > #arrow {
34-
right: -8px;
37+
right: 4px;
38+
.#{$eccgui}-visual-tour__tooltip__arrow-shape::before {
39+
transform: rotate(90deg);
40+
}
3541
}
3642

3743
.#{$eccgui}-visual-tour__tooltip[data-popper-placement^="right"] > #arrow {
38-
left: -8px;
44+
left: -28px;
45+
.#{$eccgui}-visual-tour__tooltip__arrow-shape::before {
46+
transform: rotate(270deg);
47+
}
3948
}

0 commit comments

Comments
 (0)