Module: Decidim::IconHelper
- Includes:
- LayoutHelper
- Included in:
- Accountability::ContentBlocks::HighlightedResultsCell, ActivitiesCell, ActivityCell, Admin::ContentBlockCell, Assemblies::AssembliesHelper, Assemblies::AssemblyStatsPresenter, BadgeCell, Budgets::ProjectVotedHintCell, Budgets::ProjectVotesCountCell, CardMetadataCell, Conferences::ConferenceStatsPresenter, ContentBlocks::FooterSubHeroCell, ContentBlocks::HowToParticipateCell, ContentBlocks::SubHeroCell, DateRangeCell, NavbarAdminLinkCell, NotificationCell, ParticipatoryProcessGroups::ContentBlocks::HighlightedParticipatoryProcessesCell, ParticipatoryProcessGroups::ContentBlocks::TitleCell, ParticipatoryProcesses::ParticipatoryProcessGroupStatsPresenter, ParticipatoryProcesses::ParticipatoryProcessHelper, ParticipatoryProcesses::ParticipatoryProcessStatsPresenter, ProfileSidebarCell, RedesignedButtonCell, RedesignedCardCell, Votings::ContentBlocks::LandingPage::AttachmentsAndFoldersCell, Votings::ContentBlocks::LandingPage::PollingStationsCell, Votings::VotingStatsPresenter
- Defined in:
- decidim-core/app/helpers/decidim/icon_helper.rb
Overview
Helpers related to icons
Constant Summary collapse
- DEFAULT_RESOURCE_TYPE_ICONS =
{ "all" => "apps-2-line", "Decidim::Proposals::CollaborativeDraft" => "draft-line", "Decidim::Comments::Comment" => "chat-1-line", "Decidim::Debates::Debate" => "discuss-line", "Decidim::Initiative" => "lightbulb-flash-line", "Decidim::Meetings::Meeting" => "map-pin-line", "Decidim::Blogs::Post" => "pen-nib-line", "Decidim::Proposals::Proposal" => "chat-new-line", "Decidim::Consultations::Question" => "question-mark", "Decidim::Budgets::Order" => "check-double-line", "Decidim::Assembly" => "government-line", "Decidim::ParticipatoryProcess" => "treasure-map-line", "Decidim::Category" => "price-tag-3-line", "Decidim::Scope" => "scan-line", "other" => "question-line", "like" => "heart-add-line", "dislike" => "dislike-line", "follow" => "notification-3-line", "unfollow" => "notification-3-fill", "share" => "share-line" }.freeze
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
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.
38 39 40 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 38 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.
49 50 51 52 53 54 55 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 49 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.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 65 def resource_icon(resource, = {}) if resource.instance_of?(Decidim::Comments::Comment) icon "comment-square", 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 "person", else icon "bell", end end |
#resource_type_icon(resource_type, options = {}) ⇒ Object
79 80 81 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 79 def resource_type_icon(resource_type, = {}) icon resource_type_icon_key(resource_type), end |
#resource_type_icon_key(resource_type) ⇒ Object
83 84 85 |
# File 'decidim-core/app/helpers/decidim/icon_helper.rb', line 83 def resource_type_icon_key(resource_type) DEFAULT_RESOURCE_TYPE_ICONS[resource_type.to_s] || DEFAULT_RESOURCE_TYPE_ICONS["other"] end |