Module: Decidim::IconHelper
- Includes:
- LayoutHelper
- Included in:
- Assemblies::AssembliesHelper, Assemblies::AssemblyStatsPresenter, AttachmentsHelper, Blogs::PostsController, Budgets::ProjectsController, Conferences::ConferenceStatsPresenter, Design::ApplicationHelper, Design::IconographyHelper, FiltersHelper, Decidim::Initiatives::InitiativesController, LastActivitiesController, Meetings::Directory::ApplicationHelper, ParticipatoryProcesses::ParticipatoryProcessGroupStatsPresenter, ParticipatoryProcesses::ParticipatoryProcessHelper, ParticipatoryProcesses::ParticipatoryProcessStatsPresenter, Proposals::CollaborativeDraftsController, ViewModel
- Defined in:
- decidim-core/app/helpers/decidim/icon_helper.rb
Overview
Helpers related to icons
Instance Method Summary collapse
-
#component_icon(component, options = {}) ⇒ Object
Public: Returns an icon given an instance of a Component.
-
#manifest_icon(manifest, options = {}) ⇒ Object
Public: Returns an icon given an instance of a Manifest.
-
#resource_icon(resource, options = {}) ⇒ Object
Public: Finds the correct icon for the given resource.
- #resource_type_icon(resource_type, options = {}) ⇒ Object
- #resource_type_icon_key(resource_type) ⇒ Object
- #text_with_resource_icon(resource_name, text) ⇒ Object
Methods included from LayoutHelper
#_icon_classes, #apple_favicon, #application_path, #current_url, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #role
Methods included from TooltipHelper
Methods included from ModalHelper
#decidim_drawer, #decidim_modal
Methods included from OrganizationHelper
#current_organization_name, #organization_colors, #organization_description_label, #organization_name
Methods included from TranslatableAttributes
Instance Method Details
#component_icon(component, options = {}) ⇒ Object
Public: Returns an icon given an instance of a Component. It defaults to a question mark when no icon is found.
component - The component to generate the icon for. options - a Hash with options
Returns an HTML tag with the icon.
15 16 17 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 15 def component_icon(component, = {}) manifest_icon(component.manifest, ) end |
#manifest_icon(manifest, options = {}) ⇒ Object
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.
26 27 28 29 30 31 32 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 26 def manifest_icon(manifest, = {}) if manifest.respond_to?(:icon) && manifest.icon.present? external_icon manifest.icon, else icon "question-mark", end end |
#resource_icon(resource, options = {}) ⇒ Object
Public: Finds the correct icon for the given resource. If the resource has a Component 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.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 42 def resource_icon(resource, = {}) if resource.instance_of?(Decidim::Comments::Comment) icon "chat-1-line", elsif resource.respond_to?(:component) && resource.component.present? component_icon(resource.component, ) elsif resource.respond_to?(:manifest) && resource.manifest.present? manifest_icon(resource.manifest, ) elsif resource.is_a?(Decidim::User) icon "user-line", else icon "notification-3-line", end end |
#resource_type_icon(resource_type, options = {}) ⇒ Object
56 57 58 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 56 def resource_type_icon(resource_type, = {}) icon resource_type_icon_key(resource_type), end |
#resource_type_icon_key(resource_type) ⇒ Object
60 61 62 63 64 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 60 def resource_type_icon_key(resource_type) return resource_type.to_s if Decidim.icons.all[resource_type.to_s] "other" end |
#text_with_resource_icon(resource_name, text) ⇒ Object
66 67 68 69 70 71 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 66 def text_with_resource_icon(resource_name, text) output = "" output += resource_type_icon resource_name output += content_tag :span, text output.html_safe end |