Sha256: 627db33d5a6b01549a514f438cb68c2e5237add8a75c53c0cadb391fddea1663

Contents?: true

Size: 880 Bytes

Versions: 6

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true
module Decidim
  # Module to add the attribute `aria-selected` to links when they are
  # pointing to the current path. Uses the `active_link_to` gem to calculate
  # this.
  #
  module AriaSelectedLinkToHelper
    # Adds the `aria-selected` attribute to a link when it's pointing to the
    # current path. The API is the same than the `link_to` one, and uses this
    # helper internally.
    #
    # text - a String with the link text
    # link - Where the link should point to. Accepts the same value than
    #   `link_to` helper.
    # options - An options Hash that will be passed to `link_to`.
    def aria_selected_link_to(text, link, options = {})
      link_to(
        text,
        link,
        options.merge(
          "aria-selected": is_active_link?(link, options[:aria_link_type] || :inclusive)
        )
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-core-0.1.0 app/helpers/decidim/aria_selected_link_to_helper.rb
decidim-core-0.0.8.1 app/helpers/decidim/aria_selected_link_to_helper.rb
decidim-core-0.0.7 app/helpers/decidim/aria_selected_link_to_helper.rb
decidim-core-0.0.6 app/helpers/decidim/aria_selected_link_to_helper.rb
decidim-core-0.0.5 app/helpers/decidim/aria_selected_link_to_helper.rb
decidim-core-0.0.3 app/helpers/decidim/aria_selected_link_to_helper.rb