Module: LocoMotion::Concerns::IconableComponent
- Extended by:
- ActiveSupport::Concern
- Included in:
- Daisy::Actions::ButtonComponent, Daisy::DataDisplay::AvatarComponent, Daisy::DataDisplay::BadgeComponent, Daisy::DataDisplay::StatComponent, Daisy::DataDisplay::TextRotateComponent::ItemComponent, Daisy::Feedback::AlertComponent, Daisy::Navigation::BreadcrumbsComponent::Daisy::Navigation::BreadcrumbItemComponent, Daisy::Navigation::DockComponent::Daisy::Navigation::DockSectionComponent, Daisy::Navigation::LinkComponent
- Defined in:
- lib/loco_motion/concerns/iconable_component.rb
Overview
The IconableComponent concern provides functionality for components that display icons. It supports both left and right icons and allows for customization of their CSS classes and HTML attributes.
Instance Method Summary collapse
-
#has_icons? ⇒ Boolean
Determines if any icons are present in the component.
-
#left_icon_html ⇒ Hash
Returns the HTML attributes for the left icon.
-
#render_left_icon ⇒ String
(also: #render_icon)
Renders the left icon as a Hero::IconComponent instance.
-
#render_right_icon ⇒ String
Renders the right icon using a hero icon.
-
#right_icon_html ⇒ Hash
Returns the HTML attributes for the right icon.
Instance Method Details
#has_icons? ⇒ Boolean
Determines if any icons are present in the component.
108 109 110 |
# File 'lib/loco_motion/concerns/iconable_component.rb', line 108 def has_icons? @left_icon.present? || @right_icon.present? end |
#left_icon_html ⇒ Hash
Returns the HTML attributes for the left icon.
90 91 92 |
# File 'lib/loco_motion/concerns/iconable_component.rb', line 90 def left_icon_html { class: @left_icon_css }.merge(@left_icon_html) end |
#render_left_icon ⇒ String Also known as: render_icon
Renders the left icon as a Hero::IconComponent instance.
117 118 119 120 121 |
# File 'lib/loco_motion/concerns/iconable_component.rb', line 117 def render_left_icon return if @left_icon.blank? hero_icon(@left_icon, css: @left_icon_css, html: @left_icon_html, **@left_icon_options) end |
#render_right_icon ⇒ String
Renders the right icon using a hero icon.
129 130 131 132 133 |
# File 'lib/loco_motion/concerns/iconable_component.rb', line 129 def render_right_icon return if @right_icon.blank? hero_icon(@right_icon, css: @right_icon_css, html: @right_icon_html, **@right_icon_options) end |
#right_icon_html ⇒ Hash
Returns the HTML attributes for the right icon.
99 100 101 |
# File 'lib/loco_motion/concerns/iconable_component.rb', line 99 def right_icon_html { class: @right_icon_css }.merge(@right_icon_html) end |