Custom buttons and actions
Buratinator opened this issue · 2 comments
Hi. Thank you for porting shepherd to Rails!
I have a question
I see that shepherd shows that buttons with custom actions can be included in tour steps, e.g.:
buttons: [
{
action() {
return this.back();
},
text: 'Back'
},
(from their demo page at https://shepherdjs.dev/)
I can't figure out how to do this with Abraham. I suspect I'm not using the correct syntax, but it's not clear to me what the correct one would be (shepherd's vanilla syntax doesn't seem to work for me).
Hi, @Buratinator,
Thanks for your question!
Abraham is currently designed to be used with little to no custom configuration. As such, each step's buttons are dynamically generated by the _abraham.html.erb
partial:
buttons: [
<% if index == 0 %>
{ text: '<%= t('abraham.later') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
{ text: '<%= t('abraham.continue') %>', action: tour.next }
<% else %>
<% if index == steps.size - 1 %>
{ text: '<%= t('abraham.done') %>', action: tour.complete }
<% else %>
{ text: '<%= t('abraham.exit') %>', action: tour.cancel, classes: 'shepherd-button-secondary' },
{ text: '<%= t('abraham.next') %>', action: tour.next }
<% end %>
<% end %>
]
Or, in human terms:
- On the first step, offer "Later" and "Continue" buttons
- On intermediate steps, offer "Exit" and "Next" buttons
- On the final step, offer a "Done" button
At this time, if you want to implement custom buttons, you'd have to integrate Shepherd from scratch :(
From your snippet, it looks like you're seeking a back button. That seems like a pretty common use case that Abraham has overlooked. Would offering a back button be helpful?
Thank you for your reply. The code snippet was just an example I copied from the shepherd site, so not really a desired feature or anything.