Class: Crm::StickyHeaderComponent::NavItem
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Crm::StickyHeaderComponent::NavItem
- Defined in:
- app/components/crm/sticky_header_component.rb
Overview
Namespace for NavItem ViewComponents.
Delegated Instance Attributes collapse
-
#fa_icon ⇒ Object
Alias for Helpers#fa_icon.
Methods inherited from ApplicationComponent
#cms_link, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(href:, label:, icon: nil, icon_family: nil, active: false, badge: nil, suffix_html: nil) ⇒ NavItem
constructor
A new instance of NavItem.
Methods inherited from ApplicationComponent
Constructor Details
#initialize(href:, label:, icon: nil, icon_family: nil, active: false, badge: nil, suffix_html: nil) ⇒ NavItem
Returns a new instance of NavItem.
77 78 79 80 81 82 83 84 85 86 |
# File 'app/components/crm/sticky_header_component.rb', line 77 def initialize(href:, label:, icon: nil, icon_family: nil, active: false, badge: nil, suffix_html: nil) super() @href = href @label = label @icon = icon @icon_family = icon_family @active = active @badge = badge @suffix_html = suffix_html end |
Instance Method Details
#call ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/components/crm/sticky_header_component.rb', line 88 def call css = %w[nav-link text-nowrap] css << "active" if @active content_tag(:li, class: "nav-item") do content_tag(:a, class: css.join(" "), href: @href) do parts = [] parts << fa_icon(@icon, family: @icon_family, class: 'me-1') if @icon.present? parts << @label parts << content_tag(:span, @badge, class: "badge bg-secondary ms-1") if @badge.present? parts << @suffix_html.html_safe if @suffix_html.present? safe_join(parts) end end end |
#fa_icon ⇒ Object
Alias for Helpers#fa_icon
75 |
# File 'app/components/crm/sticky_header_component.rb', line 75 delegate :fa_icon, to: :helpers |