Class: Daisy::Navigation::BreadcrumbItemComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Navigation::BreadcrumbItemComponent
- Defined in:
- app/components/daisy/navigation/breadcrumbs_component.rb
Overview
Component for a single breadcrumb item in a breadcrumbs trail.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Configure the component before rendering.
- #call ⇒ Object
-
#initialize(title = nil, href = nil, *args, **kws) ⇒ BreadcrumbItemComponent
constructor
Initialize a breadcrumb item component.
-
#render_icon_and_content ⇒ String
Render the icon (if provided) and content.
Methods included from LocoMotion::Concerns::IconableComponent
#has_icons?, #left_icon_html, #render_left_icon, #render_right_icon, #right_icon_html
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
#initialize(title = nil, href = nil, *args, **kws) ⇒ BreadcrumbItemComponent
Initialize a breadcrumb item component.
63 64 65 66 67 68 |
# File 'app/components/daisy/navigation/breadcrumbs_component.rb', line 63 def initialize(title = nil, href = nil, *args, **kws) super @simple_title = config_option(:title, title) @href = config_option(:href, href) end |
Instance Method Details
#before_render ⇒ Object
Configure the component before rendering.
Sets the component tag to be a list item and configures the link part with the href value.
74 75 76 77 78 79 |
# File 'app/components/daisy/navigation/breadcrumbs_component.rb', line 74 def before_render set_tag_name(:component, :li) set_tag_name(:link, "a") add_html(:link, { href: @href }) end |
#call ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/components/daisy/navigation/breadcrumbs_component.rb', line 81 def call part(:component) do if @href part(:link) do render_icon_and_content end else render_icon_and_content end end end |
#render_icon_and_content ⇒ String
Render the icon (if provided) and content.
96 97 98 99 |
# File 'app/components/daisy/navigation/breadcrumbs_component.rb', line 96 def render_icon_and_content concat(render_icon) concat(content || @simple_title) end |