Skip to content

Commit 396e01b

Browse files
Add image to tour step
1 parent 506812c commit 396e01b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/components/VisualTour/VisualTour.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export interface VisualTourStep {
2727
highlightElementQuery?: string;
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>;
30+
/** An image URL. This will be displayed in the step description. */
31+
image?: string
3032
}
3133

3234
/** This should be used for defining steps in a separate object/file. Use with 'satisfies' after the object definition. */
@@ -117,6 +119,14 @@ interface StepModalProps {
117119
actionButtons: (React.JSX.Element | null)[];
118120
}
119121

122+
// 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+
}
129+
120130
/** Modal that is displayed for a step. */
121131
const StepModal = ({ step, titleSuffix, onClose, actionButtons }: StepModalProps) => {
122132
return (
@@ -127,7 +137,7 @@ const StepModal = ({ step, titleSuffix, onClose, actionButtons }: StepModalProps
127137
onClose={onClose}
128138
actions={actionButtons}
129139
>
130-
{typeof step.content === "string" ? step.content : step.content()}
140+
<StepContent step={step} />
131141
</SimpleDialog>
132142
);
133143
};
@@ -176,7 +186,9 @@ const StepPopover = ({ highlightedElement, step, titleSuffix, actionButtons }: S
176186
<CardHeader>
177187
<CardTitle>{`${step.title} ${titleSuffix}`}</CardTitle>
178188
</CardHeader>
179-
<CardContent>{typeof step.content === "string" ? step.content : step.content()}</CardContent>
189+
<CardContent>
190+
<StepContent step={step} />
191+
</CardContent>
180192
<CardActions>{actionButtons}</CardActions>
181193
</Card>
182194
</div>

0 commit comments

Comments
 (0)