Sha256: 8cb8525cad9cd6731f5dbaf76f2ce60e00a95c78f31ddba2be617f8943ba5f5c

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true
module Decidim
  # View helpers related to the layout.
  module LayoutHelper
    def decidim_page_title
      current_organization.name
    end

    # Outputs an SVG-based icon.
    #
    # name    - The String with the icon name.
    # options - The Hash options used to customize the icon (default {}):
    #             :width  - The Number of width in pixels (optional).
    #             :height - The Number of height in pixels (optional).
    #             :aria_label - The String to set as aria label (optional).
    #             :aria_hidden - The Truthy value to enable aria_hidden (optional).
    #             :role - The String to set as the role (optional).
    #             :class - The String to add as a CSS class (optional).
    #
    # Returns a String.
    def icon(name, options = {})
      html_properties = {}

      html_properties["width"] = options[:width]
      html_properties["height"] = options[:height]
      html_properties["aria-label"] = options[:aria_label]
      html_properties["role"] = options[:role]
      html_properties["aria-hidden"] = options[:aria_hidden]
      html_properties["class"] = "icon icon--#{name} #{options[:class]}"

      content_tag :svg, html_properties do
        content_tag :use, nil, "xlink:href" => "#{asset_url("decidim/icons.svg")}#icon-#{name}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-core-0.0.1.alpha9 app/helpers/decidim/layout_helper.rb
decidim-core-0.0.1.alpha8 app/helpers/decidim/layout_helper.rb
decidim-core-0.0.1.alpha7 app/helpers/decidim/layout_helper.rb
decidim-core-0.0.1.alpha6 app/helpers/decidim/layout_helper.rb
decidim-core-0.0.1.alpha5 app/helpers/decidim/layout_helper.rb