Make the final step Continue button say Finish instead.
This commit is contained in:
parent
76a86eacff
commit
93be9bfca8
|
@ -57,31 +57,33 @@ function startTour(
|
||||||
eventHandlers: TourStepEventHandler[],
|
eventHandlers: TourStepEventHandler[],
|
||||||
runMainAgainAfterComplete: boolean,
|
runMainAgainAfterComplete: boolean,
|
||||||
): void {
|
): void {
|
||||||
|
const defaultButtons: Shepherd.Step.StepOptionsButton[] = [
|
||||||
|
{
|
||||||
|
classes: "btn",
|
||||||
|
text: "Continue",
|
||||||
|
action() {
|
||||||
|
this.next();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
classes: "btn",
|
||||||
|
text: "Back",
|
||||||
|
action() {
|
||||||
|
this.back();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
classes: "btn",
|
||||||
|
text: "Exit",
|
||||||
|
action() {
|
||||||
|
this.cancel();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const tour = new Shepherd.Tour({
|
const tour = new Shepherd.Tour({
|
||||||
defaultStepOptions: {
|
defaultStepOptions: {
|
||||||
buttons: [
|
buttons: [...defaultButtons],
|
||||||
{
|
|
||||||
classes: "btn",
|
|
||||||
text: "Continue",
|
|
||||||
action() {
|
|
||||||
this.next();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
classes: "btn",
|
|
||||||
text: "Back",
|
|
||||||
action() {
|
|
||||||
this.back();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
classes: "btn",
|
|
||||||
text: "Exit",
|
|
||||||
action() {
|
|
||||||
this.cancel();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
useModalOverlay: true,
|
useModalOverlay: true,
|
||||||
});
|
});
|
||||||
|
@ -106,7 +108,14 @@ function startTour(
|
||||||
|
|
||||||
// For every step we have, add it to the tour and subsequently add all the
|
// For every step we have, add it to the tour and subsequently add all the
|
||||||
// event handlers to that step.
|
// event handlers to that step.
|
||||||
for (const stepOptions of steps) {
|
for (const [stepNumber, stepOptions] of steps.entries()) {
|
||||||
|
// If the final step doesn't have buttons defined, set the "Continue" button
|
||||||
|
// text to "Finish".
|
||||||
|
if (stepOptions.buttons === undefined && stepNumber + 1 === steps.length) {
|
||||||
|
stepOptions.buttons = [...defaultButtons];
|
||||||
|
stepOptions.buttons[0].text = "Finish";
|
||||||
|
}
|
||||||
|
|
||||||
const step = tour.addStep(stepOptions);
|
const step = tour.addStep(stepOptions);
|
||||||
|
|
||||||
for (const [targetStepId, [eventName, eventHandler]] of eventHandlers) {
|
for (const [targetStepId, [eventName, eventHandler]] of eventHandlers) {
|
||||||
|
|
Loading…
Reference in New Issue