Module: GuidedTour::ApplicationHelper

Defined in:
app/helpers/guided_tour/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#guide_through(map) ⇒ String

Generate guided tour markup

Parameters:

  • map (Hash)

    target element ids as keys, explantions as values

Returns:

  • (String)

    the html markups as html_safe



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/guided_tour/application_helper.rb', line 8

def guide_through(map)
  tag.div(class: "guided-tour--wrapper", data: {
    controller: "guided-tour--tour",
    guided_tour__tour_next_btn_text_value: t("guided-tour.next-btn-text"),
    guided_tour__tour_prev_btn_text_value: t("guided-tour.prev-btn-text"),
    guided_tour__tour_done_btn_text_value: t("guided-tour.done-btn-text"),
    guided_tour__tour_step_line_text_value: t("guided-tour.step-line")
  }) do
    safe_join([
                tag.div(class: "guided-tour--starter-btn-wrapper") do
                  safe_join([
                              tag.button(type: "button", class: "btn btn-primary ms-auto", id: "guidedTourStarterBtn") do
                                safe_join([
                                            tag.i(class: "bi bi-lightbulb"),
                                            " ".html_safe,
                                            t("guided-tour.starter-button-text")
                                          ])
                              end
                            ])
                end,
                tag.div(class: "guided-tour--overlay", data: {
                  guided_tour__tour_target: "overlay",
                  bs_container: "body",
                  bs_toggle: "popover",
                  bs_placement: "bottom",
                  bs_content: ""
                }),
                tag.ol(class: "d-none") do
                  safe_join(
                    map.map do |id, guide_text|
                      tag.li(guide_text, data: {
                        guided_tour__tour_target: "explanation",
                        target_element: id
                      })
                    end
                  )
                end
              ])
  end.html_safe
end