class GovukPublishingComponents::Presenters::StepByStepNavHelper
@private Only used by the step by step component
Public Instance Methods
Private Instance Methods
create_context(context)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 82 def create_context(context) content_tag(:span, context, class: "gem-c-step-nav__context") if context end
create_list_item_content(link)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 56 def create_list_item_content(link) if link[:href] @link_index += 1 href = link_href(link[:active], link[:href]) text = capture do concat link_text(link[:active], link[:text]) concat " " concat create_context(link[:context]) end link_to( href, rel: ("external" if href.start_with?("http")), data: { position: "#{@options[:step_index] + 1}.#{@link_index}", }, class: "gem-c-step-nav__link js-link", ) do text end else link[:text] end end
external_url?(href)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 101 def external_url?(href) href.start_with?("http") end
get_list_element(style)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 90 def get_list_element(style) style == "choice" ? "ul" : "ol" end
get_list_style(style)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 86 def get_list_style(style) "gem-c-step-nav__list--choice" if style == "choice" end
link_active(active)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 120 def link_active(active) "gem-c-step-nav__list-item--active" if active end
link_href(active, href)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 94 def link_href(active, href) return "#content" if active return href if external_url?(href) link_with_step_nav_query_parameter(href) end
link_text(active, text)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 116 def link_text(active, text) active ? content_tag(:span, "You are currently viewing: ", class: "gem-c-step-nav__link-active-context visuallyhidden") + text : text end
list(element)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 35 def list(element) content_tag( get_list_element(element[:style]), class: "gem-c-step-nav__list #{get_list_style(element[:style])}", data: { length: element[:contents].length, }, ) do element[:contents].collect do |contents| concat( content_tag( :li, class: "gem-c-step-nav__list-item js-list-item #{link_active(contents[:active])}", ) do create_list_item_content(contents) end, ) end end end
paragraph(text)
click to toggle source
# File lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb, line 27 def paragraph(text) content_tag( :p, text, class: "gem-c-step-nav__paragraph", ) end