Sha256: 166ba9325697b77fb94a1586c2b58d11d0e9255855764d6305a2bfeb941fdf4f

Contents?: true

Size: 1.34 KB

Versions: 31

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module FlashHelperExtensions
    extend ActiveSupport::Concern

    included do
      private

      # Private: Foundation alert box.
      #
      # Overrides the foundation alert box helper for adding accessibility tags.
      #
      # value - The flash message.
      # alert_class - The foundation class of the alert message.
      # closable - A boolean indicating whether the close icon is added.
      #
      # Returns a HTML string.
      def alert_box(value, alert_class, closable)
        options = {
          class: "flash callout #{alert_class}",
          role: "alert",
          aria: { atomic: "true" }
        }
        options[:data] = { closable: "" } if closable
        content_tag(:div, options) do
          concat value
          concat close_link if closable
        end
      end

      # Private: Foudation alert box close link.
      #
      # Overrides the foundation alert box close link helper for the aria-label
      # translations.
      def close_link
        button_tag(
          class: "close-button",
          type: "button",
          data: { close: "" },
          aria: { label: I18n.t("decidim.alert.dismiss") }
        ) do
          content_tag(:span, "×".html_safe, aria: { hidden: true })
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.8 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.7 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.6 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.10 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.9 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.5 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.8 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.4 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.3 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.7 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.5 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.2 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.1 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.4 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.0 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.3 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.0.rc2 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.27.0.rc1 app/helpers/concerns/decidim/flash_helper_extensions.rb
decidim-core-0.26.2 app/helpers/concerns/decidim/flash_helper_extensions.rb