Sha256: ab5a9ec1217b3ea2c86718e5bec6cf5997dda89e78b253868b5a4f3898c95003

Contents?: true

Size: 1.44 KB

Versions: 30

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module Decidim
  # Helpers related to icons
  module IconHelper
    # Public: Returns an icon given an instance of a Feature. It defaults to
    # a question mark when no icon is found.
    #
    # feature - The feature to generate the icon for.
    # options - a Hash with options
    #
    # Returns an HTML tag with the icon.
    def feature_icon(feature, options = {})
      manifest_icon(feature.manifest, options)
    end

    # Public: Returns an icon given an instance of a Manifest. It defaults to
    # a question mark when no icon is found.
    #
    # manifest - The manifest to generate the icon for.
    # options - a Hash with options
    #
    # Returns an HTML tag with the icon.
    def manifest_icon(manifest, options = {})
      if manifest.icon
        external_icon manifest.icon, options
      else
        icon "question-mark", options
      end
    end

    # Public: Finds the correct icon for the given resource. If the resource has a
    # Feature then it uses it to find the icon, otherwise checks for the resource
    # manifest to find the icon.
    #
    # resource - The resource to generate the icon for.
    # options - a Hash with options
    #
    # Returns an HTML tag with the icon.
    def resource_icon(resource, options = {})
      if resource.respond_to?(:feature)
        feature_icon(resource.feature, options)
      else
        manifest_icon(resource.manifest, options)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
decidim-core-0.9.1 app/helpers/decidim/icon_helper.rb
decidim-core-0.9.0 app/helpers/decidim/icon_helper.rb
decidim-core-0.8.4 app/helpers/decidim/icon_helper.rb
decidim-core-0.8.3 app/helpers/decidim/icon_helper.rb
decidim-core-0.8.2 app/helpers/decidim/icon_helper.rb
decidim-core-0.8.1 app/helpers/decidim/icon_helper.rb
decidim-core-0.8.0 app/helpers/decidim/icon_helper.rb
decidim-core-0.7.4 app/helpers/decidim/icon_helper.rb
decidim-core-0.7.3 app/helpers/decidim/icon_helper.rb
decidim-core-0.7.2 app/helpers/decidim/icon_helper.rb
decidim-core-0.7.1 app/helpers/decidim/icon_helper.rb
decidim-core-0.7.0 app/helpers/decidim/icon_helper.rb
decidim-core-0.6.8 app/helpers/decidim/icon_helper.rb
decidim-0.6.8 decidim-core/app/helpers/decidim/icon_helper.rb
decidim-core-0.6.7 app/helpers/decidim/icon_helper.rb
decidim-0.6.7 decidim-core/app/helpers/decidim/icon_helper.rb
decidim-core-0.6.6 app/helpers/decidim/icon_helper.rb
decidim-0.6.6 decidim-core/app/helpers/decidim/icon_helper.rb
decidim-core-0.6.5 app/helpers/decidim/icon_helper.rb
decidim-0.6.5 decidim-core/app/helpers/decidim/icon_helper.rb