actmd / abraham

Trackable application tours for Rails with i18n support
MIT License
124 stars 45 forks source link

Custom buttons and actions #30

Closed Buratinator closed 4 years ago

Buratinator commented 4 years ago

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).

jabbett commented 4 years ago

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:

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?

Buratinator commented 4 years ago

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.