Skip to content

Commit

Permalink
Update button types (#1709)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieTheWagner authored Nov 26, 2024
1 parent c164e86 commit d816592
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 4 additions & 5 deletions ember-shepherd/src/services/tour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ export default class TourService extends Service.extend(Evented) {
* @returns {Promise} Promise that resolves when everything has been set up and shepherd is ready to use
* @public
*/
addSteps(steps: Array<StepOptions>) {
addSteps(
steps: Array<StepOptions & { buttons: Array<EmberShepherdButton> }>,
) {
return this._initialize().then(() => {
const tour = this.tourObject;

Expand All @@ -276,10 +278,7 @@ export default class TourService extends Service.extend(Evented) {

steps.forEach((step) => {
if (step.buttons) {
step.buttons = (step.buttons as Array<EmberShepherdButton>).map(
makeButton.bind(this),
this,
);
step.buttons = step.buttons.map(makeButton.bind(this), this);
}

tour.addStep(step);
Expand Down
6 changes: 5 additions & 1 deletion ember-shepherd/src/utils/buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export type EmberShepherdButton = StepOptionsButton & {
* @private
* @return {{action: *, classes: *, text: *}} Description here
*/
export function makeButton(this: TourService, button: EmberShepherdButton): StepOptionsButton {
export function makeButton(
this: TourService,
button: EmberShepherdButton,
): EmberShepherdButton {
const { classes, disabled, label, secondary, text, type } = button;
const builtInButtonTypes = ['back', 'cancel', 'next'];

Expand All @@ -45,5 +48,6 @@ export function makeButton(this: TourService, button: EmberShepherdButton): Step
label,
secondary,
text,
type,
};
}

0 comments on commit d816592

Please sign in to comment.